PageSourceSearch

https://pose-animator-demo.firebaseapp.com/camera.283d5d54.js

js pose-animator-demo.firebaseapp.com collected 2026-10-03 14:07:15 UTC 2,679,101 bytes, 75,645 lines download raw bytes

vendor: 15,442 bytes, lines 1-593
1// modules are defined as an array
2// [ module function, map of requires ]
3//
4// map of requires is short require name -> numeric require
5//
6// anything defined in a previous bundle is accessed via the
7// orig method which is the require for previous bundles
8parcelRequire = (function (modules, cache, entry, globalName) {
9  // Save the require from previous bundle to this closure if any
10  var previousRequire = typeof parcelRequire === 'function' && parcelRequire;
11  var nodeRequire = typeof require === 'function' && require;
12
13  function newRequire(name, jumped) {
14    if (!cache[name]) {
15      if (!modules[name]) {
16        // if we cannot find the module within our internal map or
17        // cache jump to the current global require ie. the last bundle
18        // that was added to the page.
19        var currentRequire = typeof parcelRequire === 'function' && parcelRequire;
20        if (!jumped && currentRequire) {
21          return currentRequire(name, true);
22        }
23
24        // If there are other bundles on this page the require from the
25        // previous one is saved to 'previousRequire'. Repeat this as
26        // many times as there are bundles until the module is found or
27        // we exhaust the require chain.
28        if (previousRequire) {
29          return previousRequire(name, true);
30        }
31
32        // Try the node require function if it exists.
33        if (nodeRequire && typeof name === 'string') {
34          return nodeRequire(name);
35        }
36
37        var err = new Error('Cannot find module \'' + name + '\'');
38        err.code = 'MODULE_NOT_FOUND';
39        throw err;
40      }
41
42      localRequire.resolve = resolve;
43      localRequire.cache = {};
44
45      var module = cache[name] = new newRequire.Module(name);
46
47      modules[name][0].call(module.exports, localRequire, module, module.exports, this);
48    }
49
50    return cache[name].exports;
51
52    function localRequire(x){
53      return newRequire(localRequire.resolve(x));
54    }
55
56    function resolve(x){
57      return modules[name][1][x] || x;
58    }
59  }
60
61  function Module(moduleName) {
62    this.id = moduleName;
63    this.bundle = newRequire;
64    this.exports = {};
65  }
66
67  newRequire.isParcelRequire = true;
68  newRequire.Module = Module;
69  newRequire.modules = modules;
70  newRequire.cache = cache;
71  newRequire.parent = previousRequire;
72  newRequire.register = function (id, exports) {
73    modules[id] = [function (require, module) {
74      module.exports = exports;
75    }, {}];
76  };
77
78  var error;
79  for (var i = 0; i < entry.length; i++) {
80    try {
81      newRequire(entry[i]);
82    } catch (e) {
83      // Save first error but execute all entries
84      if (!error) {
85        error = e;
86      }
87    }
88  }
89
90  if (entry.length) {
91    // Expose entry point to Node, AMD or browser globals
92    // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
93    var mainExports = newRequire(entry[entry.length - 1]);
94
95    // CommonJS
96    if (typeof exports === "object" && typeof module !== "undefined") {
97      module.exports = mainExports;
98
99    // RequireJS
100    } else if (typeof define === "function" && define.amd) {
101     define(function () {
102       return mainExports;
103     });
104
105    // <script>
106    } else if (globalName) {
107      this[globalName] = mainExports;
108    }
109  }
110
111  // Override the current require with this new one
112  parcelRequire = newRequire;
113
114  if (error) {
115    // throw error from earlier, _after updating parcelRequire_
116    throw error;
117  }
118
119  return newRequire;
120})({"node_modules/parcel-bundler/src/builtins/_empty.js":[function(require,module,exports) {
121
122},{}],"node_modules/process/browser.js":[function(require,module,exports) {
123
124// shim for using process in browser
125var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it
126// don't break things.  But we need to wrap it in a try catch in case it is
127// wrapped in strict mode code which doesn't define any globals.  It's inside a
128// function because try/catches deoptimize in certain engines.
129
130var cachedSetTimeout;
131var cachedClearTimeout;
132
133function defaultSetTimout() {
134  throw new Error('setTimeout has not been defined');
135}
136
137function defaultClearTimeout() {
138  throw new Error('clearTimeout has not been defined');
139}
140
141(function () {
142  try {
143    if (typeof setTimeout === 'function') {
144      cachedSetTimeout = setTimeout;
145    } else {
146      cachedSetTimeout = defaultSetTimout;
147    }
148  } catch (e) {
149    cachedSetTimeout = defaultSetTimout;
150  }
151
152  try {
153    if (typeof clearTimeout === 'function') {
154      cachedClearTimeout = clearTimeout;
155    } else {
156      cachedClearTimeout = defaultClearTimeout;
157    }
158  } catch (e) {
159    cachedClearTimeout = defaultClearTimeout;
160  }
161})();
162
163function runTimeout(fun) {
164  if (cachedSetTimeout === setTimeout) {
165    //normal enviroments in sane situations
166    return setTimeout(fun, 0);
167  } // if setTimeout wasn't available but was latter defined
168
169
170  if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
171    cachedSetTimeout = setTimeout;
172    return setTimeout(fun, 0);
173  }
174
175  try {
176    // when when somebody has screwed with setTimeout but no I.E. maddness
177    return cachedSetTimeout(fun, 0);
178  } catch (e) {
179    try {
180      // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
181      return cachedSetTimeout.call(null, fun, 0);
182    } catch (e) {
183      // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
184      return cachedSetTimeout.call(this, fun, 0);
185    }
186  }
187}
188
189function runClearTimeout(marker) {
190  if (cachedClearTimeout === clearTimeout) {
191    //normal enviroments in sane situations
192    return clearTimeout(marker);
193  } // if clearTimeout wasn't available but was latter defined
194
195
196  if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
197    cachedClearTimeout = clearTimeout;
198    return clearTimeout(marker);
199  }
200
201  try {
202    // when when somebody has screwed with setTimeout but no I.E. maddness
203    return cachedClearTimeout(marker);
204  } catch (e) {
205    try {
206      // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
207      return cachedClearTimeout.call(null, marker);
208    } catch (e) {
209      // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
210      // Some versions of I.E. have different rules for clearTimeout vs setTimeout
211      return cachedClearTimeout.call(this, marker);
212    }
213  }
214}
215
216var queue = [];
217var draining = false;
218var currentQueue;
219var queueIndex = -1;
220
221function cleanUpNextTick() {
222  if (!draining || !currentQueue) {
223    return;
224  }
225
226  draining = false;
227
228  if (currentQueue.length) {
229    queue = currentQueue.concat(queue);
230  } else {
231    queueIndex = -1;
232  }
233
234  if (queue.length) {
235    drainQueue();
236  }
237}
238
239function drainQueue() {
240  if (draining) {
241    return;
242  }
243
244  var timeout = runTimeout(cleanUpNextTick);
245  draining = true;
246  var len = queue.length;
247
248  while (len) {
249    currentQueue = queue;
250    queue = [];
251
252    while (++queueIndex < len) {
253      if (currentQueue) {
254        currentQueue[queueIndex].run();
255      }
256    }
257
258    queueIndex = -1;
259    len = queue.length;
260  }
261
262  currentQueue = null;
263  draining = false;
264  runClearTimeout(timeout);
265}
266
267process.nextTick = function (fun) {
268  var args = new Array(arguments.length - 1);
269
270  if (arguments.length > 1) {
271    for (var i = 1; i < arguments.length; i++) {
272      args[i - 1] = arguments[i];
273    }
274  }
275
276  queue.push(new Item(fun, args));
277
278  if (queue.length === 1 && !draining) {
279    runTimeout(drainQueue);
280  }
281}; // v8 likes predictible objects
282
283
284function Item(fun, array) {
285  this.fun = fun;
286  this.array = array;
287}
288
289Item.prototype.run = function () {
290  this.fun.apply(null, this.array);
291};
292
293process.title = 'browser';
294process.env = {};
295process.argv = [];
296process.version = ''; // empty string to avoid regexp issues
297
298process.versions = {};
299
300function noop() {}
301
302process.on = noop;
303process.addListener = noop;
304process.once = noop;
305process.off = noop;
306process.removeListener = noop;
307process.removeAllListeners = noop;
308process.emit = noop;
309process.prependListener = noop;
310process.prependOnceListener = noop;
311
312process.listeners = function (name) {
313  return [];
314};
315
316process.binding = function (name) {
317  throw new Error('process.binding is not supported');
318};
319
320process.cwd = function () {
321  return '/';
322};
323
324process.chdir = function (dir) {
325  throw new Error('process.chdir is not supported');
326};
327
328process.umask = function () {
329  return 0;
330};
331},{}],"node_modules/base64-js/index.js":[function(require,module,exports) {
332'use strict'
333
334exports.byteLength = byteLength
335exports.toByteArray = toByteArray
336exports.fromByteArray = fromByteArray
337
338var lookup = []
339var revLookup = []
340var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
341
342var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
343for (var i = 0, len = code.length; i < len; ++i) {
344  lookup[i] = code[i]
345  revLookup[code.charCodeAt(i)] = i
346}
347
348// Support decoding URL-safe base64 strings, as Node.js does.
349// See: https://en.wikipedia.org/wiki/Base64#URL_applications
350revLookup['-'.charCodeAt(0)] = 62
351revLookup['_'.charCodeAt(0)] = 63
352
353function getLens (b64) {
354  var len = b64.length
355
356  if (len % 4 > 0) {
357    throw new Error('Invalid string. Length must be a multiple of 4')
358  }
359
360  // Trim off extra bytes after placeholder bytes are found
361  // See: https://github.com/beatgammit/base64-js/issues/42
362  var validLen = b64.indexOf('=')
363  if (validLen === -1) validLen = len
364
365  var placeHoldersLen = validLen === len
366    ? 0
367    : 4 - (validLen % 4)
368
369  return [validLen, placeHoldersLen]
370}
371
372// base64 is 4/3 + up to two characters of the original data
373function byteLength (b64) {
374  var lens = getLens(b64)
375  var validLen = lens[0]
376  var placeHoldersLen = lens[1]
377  return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
378}
379
380function _byteLength (b64, validLen, placeHoldersLen) {
381  return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
382}
383
384function toByteArray (b64) {
385  var tmp
386  var lens = getLens(b64)
387  var validLen = lens[0]
388  var placeHoldersLen = lens[1]
389
390  var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
391
392  var curByte = 0
393
394  // if there are placeholders, only get up to the last complete 4 chars
395  var len = placeHoldersLen > 0
396    ? validLen - 4
397    : validLen
398
399  var i
400  for (i = 0; i < len; i += 4) {
401    tmp =
402      (revLookup[b64.charCodeAt(i)] << 18) |
403      (revLookup[b64.charCodeAt(i + 1)] << 12) |
404      (revLookup[b64.charCodeAt(i + 2)] << 6) |
405      revLookup[b64.charCodeAt(i + 3)]
406    arr[curByte++] = (tmp >> 16) & 0xFF
407    arr[curByte++] = (tmp >> 8) & 0xFF
408    arr[curByte++] = tmp & 0xFF
409  }
410
411  if (placeHoldersLen === 2) {
412    tmp =
413      (revLookup[b64.charCodeAt(i)] << 2) |
414      (revLookup[b64.charCodeAt(i + 1)] >> 4)
415    arr[curByte++] = tmp & 0xFF
416  }
417
418  if (placeHoldersLen === 1) {
419    tmp =
420      (revLookup[b64.charCodeAt(i)] << 10) |
421      (revLookup[b64.charCodeAt(i + 1)] << 4) |
422      (revLookup[b64.charCodeAt(i + 2)] >> 2)
423    arr[curByte++] = (tmp >> 8) & 0xFF
424    arr[curByte++] = tmp & 0xFF
425  }
426
427  return arr
428}
429
430function tripletToBase64 (num) {
431  return lookup[num >> 18 & 0x3F] +
432    lookup[num >> 12 & 0x3F] +
433    lookup[num >> 6 & 0x3F] +
434    lookup[num & 0x3F]
435}
436
437function encodeChunk (uint8, start, end) {
438  var tmp
439  var output = []
440  for (var i = start; i < end; i += 3) {
441    tmp =
442      ((uint8[i] << 16) & 0xFF0000) +
443      ((uint8[i + 1] << 8) & 0xFF00) +
444      (uint8[i + 2] & 0xFF)
445    output.push(tripletToBase64(tmp))
446  }
447  return output.join('')
448}
449
450function fromByteArray (uint8) {
451  var tmp
452  var len = uint8.length
453  var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
454  var parts = []
455  var maxChunkLength = 16383 // must be multiple of 3
456
457  // go through the array every three bytes, we'll deal with trailing stuff later
458  for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
459    parts.push(encodeChunk(
460      uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
461    ))
462  }
463
464  // pad the end with zeros, but make sure to not forget the extra bytes
465  if (extraBytes === 1) {
466    tmp = uint8[len - 1]
467    parts.push(
468      lookup[tmp >> 2] +
469      lookup[(tmp << 4) & 0x3F] +
470      '=='
471    )
472  } else if (extraBytes === 2) {
473    tmp = (uint8[len - 2] << 8) + uint8[len - 1]
474    parts.push(
475      lookup[tmp >> 10] +
476      lookup[(tmp >> 4) & 0x3F] +
477      lookup[(tmp << 2) & 0x3F] +
478      '='
479    )
480  }
481
482  return parts.join('')
483}
484
485},{}],"node_modules/ieee754/index.js":[function(require,module,exports) {
486exports.read = function (buffer, offset, isLE, mLen, nBytes) {
487  var e, m
488  var eLen = (nBytes * 8) - mLen - 1
489  var eMax = (1 << eLen) - 1
490  var eBias = eMax >> 1
491  var nBits = -7
492  var i = isLE ? (nBytes - 1) : 0
493  var d = isLE ? -1 : 1
494  var s = buffer[offset + i]
495
496  i += d
497
498  e = s & ((1 << (-nBits)) - 1)
499  s >>= (-nBits)
500  nBits += eLen
501  for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
502
503  m = e & ((1 << (-nBits)) - 1)
504  e >>= (-nBits)
505  nBits += mLen
506  for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
507
508  if (e === 0) {
509    e = 1 - eBias
510  } else if (e === eMax) {
511    return m ? NaN : ((s ? -1 : 1) * Infinity)
512  } else {
513    m = m + Math.pow(2, mLen)
514    e = e - eBias
515  }
516  return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
517}
518
519exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
520  var e, m, c
521  var eLen = (nBytes * 8) - mLen - 1
522  var eMax = (1 << eLen) - 1
523  var eBias = eMax >> 1
524  var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
525  var i = isLE ? 0 : (nBytes - 1)
526  var d = isLE ? 1 : -1
527  var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
528
529  value = Math.abs(value)
530
531  if (isNaN(value) || value === Infinity) {
532    m = isNaN(value) ? 1 : 0
533    e = eMax
534  } else {
535    e = Math.floor(Math.log(value) / Math.LN2)
536    if (value * (c = Math.pow(2, -e)) < 1) {
537      e--
538      c *= 2
539    }
540    if (e + eBias >= 1) {
541      value += rt / c
542    } else {
543      value += rt * Math.pow(2, 1 - eBias)
544    }
545    if (value * c >= 2) {
546      e++
547      c /= 2
548    }
549
550    if (e + eBias >= eMax) {
551      m = 0
552      e = eMax
553    } else if (e + eBias >= 1) {
554      m = ((value * c) - 1) * Math.pow(2, mLen)
555      e = e + eBias
556    } else {
557      m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
558      e = 0
559    }
560  }
561
562  for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
563
564  e = (e << mLen) | m
565  eLen += mLen
566  for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
567
568  buffer[offset + i - d] |= s * 128
569}
570
571},{}],"node_modules/isarray/index.js":[function(require,module,exports) {
572var toString = {}.toString;
573
574module.exports = Array.isArray || function (arr) {
575  return toString.call(arr) == '[object Array]';
576};
577
578},{}],"node_modules/buffer/index.js":[function(require,module,exports) {
579
580var global = arguments[3];
581/*!
582 * The buffer module from node.js, for the browser.
583 *
584 * @author   Feross Aboukhadijeh <http://feross.org>
585 * @license  MIT
586 */
587/* eslint-disable no-proto */
588
589'use strict'
590
591var base64 = require('base64-js')
592var ieee754 = require('ieee754')
593var isArray = require('isarray'
vendor: 48,315 bytes, lines 593-2370
593)
594
595exports.Buffer = Buffer
596exports.SlowBuffer = SlowBuffer
597exports.INSPECT_MAX_BYTES = 50
598
599/**
600 * If `Buffer.TYPED_ARRAY_SUPPORT`:
601 *   === true    Use Uint8Array implementation (fastest)
602 *   === false   Use Object implementation (most compatible, even IE6)
603 *
604 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
605 * Opera 11.6+, iOS 4.2+.
606 *
607 * Due to various browser bugs, sometimes the Object implementation will be used even
608 * when the browser supports typed arrays.
609 *
610 * Note:
611 *
612 *   - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
613 *     See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
614 *
615 *   - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
616 *
617 *   - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
618 *     incorrect length in some situations.
619
620 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
621 * get the Object implementation, which is slower but behaves correctly.
622 */
623Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
624  ? global.TYPED_ARRAY_SUPPORT
625  : typedArraySupport()
626
627/*
628 * Export kMaxLength after typed array support is determined.
629 */
630exports.kMaxLength = kMaxLength()
631
632function typedArraySupport () {
633  try {
634    var arr = new Uint8Array(1)
635    arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
636    return arr.foo() === 42 && // typed array instances can be augmented
637        typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
638        arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
639  } catch (e) {
640    return false
641  }
642}
643
644function kMaxLength () {
645  return Buffer.TYPED_ARRAY_SUPPORT
646    ? 0x7fffffff
647    : 0x3fffffff
648}
649
650function createBuffer (that, length) {
651  if (kMaxLength() < length) {
652    throw new RangeError('Invalid typed array length')
653  }
654  if (Buffer.TYPED_ARRAY_SUPPORT) {
655    // Return an augmented `Uint8Array` instance, for best performance
656    that = new Uint8Array(length)
657    that.__proto__ = Buffer.prototype
658  } else {
659    // Fallback: Return an object instance of the Buffer class
660    if (that === null) {
661      that = new Buffer(length)
662    }
663    that.length = length
664  }
665
666  return that
667}
668
669/**
670 * The Buffer constructor returns instances of `Uint8Array` that have their
671 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
672 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
673 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
674 * returns a single octet.
675 *
676 * The `Uint8Array` prototype remains unmodified.
677 */
678
679function Buffer (arg, encodingOrOffset, length) {
680  if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
681    return new Buffer(arg, encodingOrOffset, length)
682  }
683
684  // Common case.
685  if (typeof arg === 'number') {
686    if (typeof encodingOrOffset === 'string') {
687      throw new Error(
688        'If encoding is specified then the first argument must be a string'
689      )
690    }
691    return allocUnsafe(this, arg)
692  }
693  return from(this, arg, encodingOrOffset, length)
694}
695
696Buffer.poolSize = 8192 // not used by this implementation
697
698// TODO: Legacy, not needed anymore. Remove in next major version.
699Buffer._augment = function (arr) {
700  arr.__proto__ = Buffer.prototype
701  return arr
702}
703
704function from (that, value, encodingOrOffset, length) {
705  if (typeof value === 'number') {
706    throw new TypeError('"value" argument must not be a number')
707  }
708
709  if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
710    return fromArrayBuffer(that, value, encodingOrOffset, length)
711  }
712
713  if (typeof value === 'string') {
714    return fromString(that, value, encodingOrOffset)
715  }
716
717  return fromObject(that, value)
718}
719
720/**
721 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
722 * if value is a number.
723 * Buffer.from(str[, encoding])
724 * Buffer.from(array)
725 * Buffer.from(buffer)
726 * Buffer.from(arrayBuffer[, byteOffset[, length]])
727 **/
728Buffer.from = function (value, encodingOrOffset, length) {
729  return from(null, value, encodingOrOffset, length)
730}
731
732if (Buffer.TYPED_ARRAY_SUPPORT) {
733  Buffer.prototype.__proto__ = Uint8Array.prototype
734  Buffer.__proto__ = Uint8Array
735  if (typeof Symbol !== 'undefined' && Symbol.species &&
736      Buffer[Symbol.species] === Buffer) {
737    // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
738    Object.defineProperty(Buffer, Symbol.species, {
739      value: null,
740      configurable: true
741    })
742  }
743}
744
745function assertSize (size) {
746  if (typeof size !== 'number') {
747    throw new TypeError('"size" argument must be a number')
748  } else if (size < 0) {
749    throw new RangeError('"size" argument must not be negative')
750  }
751}
752
753function alloc (that, size, fill, encoding) {
754  assertSize(size)
755  if (size <= 0) {
756    return createBuffer(that, size)
757  }
758  if (fill !== undefined) {
759    // Only pay attention to encoding if it's a string. This
760    // prevents accidentally sending in a number that would
761    // be interpretted as a start offset.
762    return typeof encoding === 'string'
763      ? createBuffer(that, size).fill(fill, encoding)
764      : createBuffer(that, size).fill(fill)
765  }
766  return createBuffer(that, size)
767}
768
769/**
770 * Creates a new filled Buffer instance.
771 * alloc(size[, fill[, encoding]])
772 **/
773Buffer.alloc = function (size, fill, encoding) {
774  return alloc(null, size, fill, encoding)
775}
776
777function allocUnsafe (that, size) {
778  assertSize(size)
779  that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
780  if (!Buffer.TYPED_ARRAY_SUPPORT) {
781    for (var i = 0; i < size; ++i) {
782      that[i] = 0
783    }
784  }
785  return that
786}
787
788/**
789 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
790 * */
791Buffer.allocUnsafe = function (size) {
792  return allocUnsafe(null, size)
793}
794/**
795 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
796 */
797Buffer.allocUnsafeSlow = function (size) {
798  return allocUnsafe(null, size)
799}
800
801function fromString (that, string, encoding) {
802  if (typeof encoding !== 'string' || encoding === '') {
803    encoding = 'utf8'
804  }
805
806  if (!Buffer.isEncoding(encoding)) {
807    throw new TypeError('"encoding" must be a valid string encoding')
808  }
809
810  var length = byteLength(string, encoding) | 0
811  that = createBuffer(that, length)
812
813  var actual = that.write(string, encoding)
814
815  if (actual !== length) {
816    // Writing a hex string, for example, that contains invalid characters will
817    // cause everything after the first invalid character to be ignored. (e.g.
818    // 'abxxcd' will be treated as 'ab')
819    that = that.slice(0, actual)
820  }
821
822  return that
823}
824
825function fromArrayLike (that, array) {
826  var length = array.length < 0 ? 0 : checked(array.length) | 0
827  that = createBuffer(that, length)
828  for (var i = 0; i < length; i += 1) {
829    that[i] = array[i] & 255
830  }
831  return that
832}
833
834function fromArrayBuffer (that, array, byteOffset, length) {
835  array.byteLength // this throws if `array` is not a valid ArrayBuffer
836
837  if (byteOffset < 0 || array.byteLength < byteOffset) {
838    throw new RangeError('\'offset\' is out of bounds')
839  }
840
841  if (array.byteLength < byteOffset + (length || 0)) {
842    throw new RangeError('\'length\' is out of bounds')
843  }
844
845  if (byteOffset === undefined && length === undefined) {
846    array = new Uint8Array(array)
847  } else if (length === undefined) {
848    array = new Uint8Array(array, byteOffset)
849  } else {
850    array = new Uint8Array(array, byteOffset, length)
851  }
852
853  if (Buffer.TYPED_ARRAY_SUPPORT) {
854    // Return an augmented `Uint8Array` instance, for best performance
855    that = array
856    that.__proto__ = Buffer.prototype
857  } else {
858    // Fallback: Return an object instance of the Buffer class
859    that = fromArrayLike(that, array)
860  }
861  return that
862}
863
864function fromObject (that, obj) {
865  if (Buffer.isBuffer(obj)) {
866    var len = checked(obj.length) | 0
867    that = createBuffer(that, len)
868
869    if (that.length === 0) {
870      return that
871    }
872
873    obj.copy(that, 0, 0, len)
874    return that
875  }
876
877  if (obj) {
878    if ((typeof ArrayBuffer !== 'undefined' &&
879        obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
880      if (typeof obj.length !== 'number' || isnan(obj.length)) {
881        return createBuffer(that, 0)
882      }
883      return fromArrayLike(that, obj)
884    }
885
886    if (obj.type === 'Buffer' && isArray(obj.data)) {
887      return fromArrayLike(that, obj.data)
888    }
889  }
890
891  throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
892}
893
894function checked (length) {
895  // Note: cannot use `length < kMaxLength()` here because that fails when
896  // length is NaN (which is otherwise coerced to zero.)
897  if (length >= kMaxLength()) {
898    throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
899                         'size: 0x' + kMaxLength().toString(16) + ' bytes')
900  }
901  return length | 0
902}
903
904function SlowBuffer (length) {
905  if (+length != length) { // eslint-disable-line eqeqeq
906    length = 0
907  }
908  return Buffer.alloc(+length)
909}
910
911Buffer.isBuffer = function isBuffer (b) {
912  return !!(b != null && b._isBuffer)
913}
914
915Buffer.compare = function compare (a, b) {
916  if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
917    throw new TypeError('Arguments must be Buffers')
918  }
919
920  if (a === b) return 0
921
922  var x = a.length
923  var y = b.length
924
925  for (var i = 0, len = Math.min(x, y); i < len; ++i) {
926    if (a[i] !== b[i]) {
927      x = a[i]
928      y = b[i]
929      break
930    }
931  }
932
933  if (x < y) return -1
934  if (y < x) return 1
935  return 0
936}
937
938Buffer.isEncoding = function isEncoding (encoding) {
939  switch (String(encoding).toLowerCase()) {
940    case 'hex':
941    case 'utf8':
942    case 'utf-8':
943    case 'ascii':
944    case 'latin1':
945    case 'binary':
946    case 'base64':
947    case 'ucs2':
948    case 'ucs-2':
949    case 'utf16le':
950    case 'utf-16le':
951      return true
952    default:
953      return false
954  }
955}
956
957Buffer.concat = function concat (list, length) {
958  if (!isArray(list)) {
959    throw new TypeError('"list" argument must be an Array of Buffers')
960  }
961
962  if (list.length === 0) {
963    return Buffer.alloc(0)
964  }
965
966  var i
967  if (length === undefined) {
968    length = 0
969    for (i = 0; i < list.length; ++i) {
970      length += list[i].length
971    }
972  }
973
974  var buffer = Buffer.allocUnsafe(length)
975  var pos = 0
976  for (i = 0; i < list.length; ++i) {
977    var buf = list[i]
978    if (!Buffer.isBuffer(buf)) {
979      throw new TypeError('"list" argument must be an Array of Buffers')
980    }
981    buf.copy(buffer, pos)
982    pos += buf.length
983  }
984  return buffer
985}
986
987function byteLength (string, encoding) {
988  if (Buffer.isBuffer(string)) {
989    return string.length
990  }
991  if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
992      (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
993    return string.byteLength
994  }
995  if (typeof string !== 'string') {
996    string = '' + string
997  }
998
999  var len = string.length
1000  if (len === 0) return 0
1001
1002  // Use a for loop to avoid recursion
1003  var loweredCase = false
1004  for (;;) {
1005    switch (encoding) {
1006      case 'ascii':
1007      case 'latin1':
1008      case 'binary':
1009        return len
1010      case 'utf8':
1011      case 'utf-8':
1012      case undefined:
1013        return utf8ToBytes(string).length
1014      case 'ucs2':
1015      case 'ucs-2':
1016      case 'utf16le':
1017      case 'utf-16le':
1018        return len * 2
1019      case 'hex':
1020        return len >>> 1
1021      case 'base64':
1022        return base64ToBytes(string).length
1023      default:
1024        if (loweredCase) return utf8ToBytes(string).length // assume utf8
1025        encoding = ('' + encoding).toLowerCase()
1026        loweredCase = true
1027    }
1028  }
1029}
1030Buffer.byteLength = byteLength
1031
1032function slowToString (encoding, start, end) {
1033  var loweredCase = false
1034
1035  // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
1036  // property of a typed array.
1037
1038  // This behaves neither like String nor Uint8Array in that we set start/end
1039  // to their upper/lower bounds if the value passed is out of range.
1040  // undefined is handled specially as per ECMA-262 6th Edition,
1041  // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
1042  if (start === undefined || start < 0) {
1043    start = 0
1044  }
1045  // Return early if start > this.length. Done here to prevent potential uint32
1046  // coercion fail below.
1047  if (start > this.length) {
1048    return ''
1049  }
1050
1051  if (end === undefined || end > this.length) {
1052    end = this.length
1053  }
1054
1055  if (end <= 0) {
1056    return ''
1057  }
1058
1059  // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
1060  end >>>= 0
1061  start >>>= 0
1062
1063  if (end <= start) {
1064    return ''
1065  }
1066
1067  if (!encoding) encoding = 'utf8'
1068
1069  while (true) {
1070    switch (encoding) {
1071      case 'hex':
1072        return hexSlice(this, start, end)
1073
1074      case 'utf8':
1075      case 'utf-8':
1076        return utf8Slice(this, start, end)
1077
1078      case 'ascii':
1079        return asciiSlice(this, start, end)
1080
1081      case 'latin1':
1082      case 'binary':
1083        return latin1Slice(this, start, end)
1084
1085      case 'base64':
1086        return base64Slice(this, start, end)
1087
1088      case 'ucs2':
1089      case 'ucs-2':
1090      case 'utf16le':
1091      case 'utf-16le':
1092        return utf16leSlice(this, start, end)
1093
1094      default:
1095        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1096        encoding = (encoding + '').toLowerCase()
1097        loweredCase = true
1098    }
1099  }
1100}
1101
1102// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
1103// Buffer instances.
1104Buffer.prototype._isBuffer = true
1105
1106function swap (b, n, m) {
1107  var i = b[n]
1108  b[n] = b[m]
1109  b[m] = i
1110}
1111
1112Buffer.prototype.swap16 = function swap16 () {
1113  var len = this.length
1114  if (len % 2 !== 0) {
1115    throw new RangeError('Buffer size must be a multiple of 16-bits')
1116  }
1117  for (var i = 0; i < len; i += 2) {
1118    swap(this, i, i + 1)
1119  }
1120  return this
1121}
1122
1123Buffer.prototype.swap32 = function swap32 () {
1124  var len = this.length
1125  if (len % 4 !== 0) {
1126    throw new RangeError('Buffer size must be a multiple of 32-bits')
1127  }
1128  for (var i = 0; i < len; i += 4) {
1129    swap(this, i, i + 3)
1130    swap(this, i + 1, i + 2)
1131  }
1132  return this
1133}
1134
1135Buffer.prototype.swap64 = function swap64 () {
1136  var len = this.length
1137  if (len % 8 !== 0) {
1138    throw new RangeError('Buffer size must be a multiple of 64-bits')
1139  }
1140  for (var i = 0; i < len; i += 8) {
1141    swap(this, i, i + 7)
1142    swap(this, i + 1, i + 6)
1143    swap(this, i + 2, i + 5)
1144    swap(this, i + 3, i + 4)
1145  }
1146  return this
1147}
1148
1149Buffer.prototype.toString = function toString () {
1150  var length = this.length | 0
1151  if (length === 0) return ''
1152  if (arguments.length === 0) return utf8Slice(this, 0, length)
1153  return slowToString.apply(this, arguments)
1154}
1155
1156Buffer.prototype.equals = function equals (b) {
1157  if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
1158  if (this === b) return true
1159  return Buffer.compare(this, b) === 0
1160}
1161
1162Buffer.prototype.inspect = function inspect () {
1163  var str = ''
1164  var max = exports.INSPECT_MAX_BYTES
1165  if (this.length > 0) {
1166    str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
1167    if (this.length > max) str += ' ... '
1168  }
1169  return '<Buffer ' + str + '>'
1170}
1171
1172Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
1173  if (!Buffer.isBuffer(target)) {
1174    throw new TypeError('Argument must be a Buffer')
1175  }
1176
1177  if (start === undefined) {
1178    start = 0
1179  }
1180  if (end === undefined) {
1181    end = target ? target.length : 0
1182  }
1183  if (thisStart === undefined) {
1184    thisStart = 0
1185  }
1186  if (thisEnd === undefined) {
1187    thisEnd = this.length
1188  }
1189
1190  if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
1191    throw new RangeError('out of range index')
1192  }
1193
1194  if (thisStart >= thisEnd && start >= end) {
1195    return 0
1196  }
1197  if (thisStart >= thisEnd) {
1198    return -1
1199  }
1200  if (start >= end) {
1201    return 1
1202  }
1203
1204  start >>>= 0
1205  end >>>= 0
1206  thisStart >>>= 0
1207  thisEnd >>>= 0
1208
1209  if (this === target) return 0
1210
1211  var x = thisEnd - thisStart
1212  var y = end - start
1213  var len = Math.min(x, y)
1214
1215  var thisCopy = this.slice(thisStart, thisEnd)
1216  var targetCopy = target.slice(start, end)
1217
1218  for (var i = 0; i < len; ++i) {
1219    if (thisCopy[i] !== targetCopy[i]) {
1220      x = thisCopy[i]
1221      y = targetCopy[i]
1222      break
1223    }
1224  }
1225
1226  if (x < y) return -1
1227  if (y < x) return 1
1228  return 0
1229}
1230
1231// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
1232// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
1233//
1234// Arguments:
1235// - buffer - a Buffer to search
1236// - val - a string, Buffer, or number
1237// - byteOffset - an index into `buffer`; will be clamped to an int32
1238// - encoding - an optional encoding, relevant is val is a string
1239// - dir - true for indexOf, false for lastIndexOf
1240function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
1241  // Empty buffer means no match
1242  if (buffer.length === 0) return -1
1243
1244  // Normalize byteOffset
1245  if (typeof byteOffset === 'string') {
1246    encoding = byteOffset
1247    byteOffset = 0
1248  } else if (byteOffset > 0x7fffffff) {
1249    byteOffset = 0x7fffffff
1250  } else if (byteOffset < -0x80000000) {
1251    byteOffset = -0x80000000
1252  }
1253  byteOffset = +byteOffset  // Coerce to Number.
1254  if (isNaN(byteOffset)) {
1255    // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
1256    byteOffset = dir ? 0 : (buffer.length - 1)
1257  }
1258
1259  // Normalize byteOffset: negative offsets start from the end of the buffer
1260  if (byteOffset < 0) byteOffset = buffer.length + byteOffset
1261  if (byteOffset >= buffer.length) {
1262    if (dir) return -1
1263    else byteOffset = buffer.length - 1
1264  } else if (byteOffset < 0) {
1265    if (dir) byteOffset = 0
1266    else return -1
1267  }
1268
1269  // Normalize val
1270  if (typeof val === 'string') {
1271    val = Buffer.from(val, encoding)
1272  }
1273
1274  // Finally, search either indexOf (if dir is true) or lastIndexOf
1275  if (Buffer.isBuffer(val)) {
1276    // Special case: looking for empty string/buffer always fails
1277    if (val.length === 0) {
1278      return -1
1279    }
1280    return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
1281  } else if (typeof val === 'number') {
1282    val = val & 0xFF // Search for a byte value [0-255]
1283    if (Buffer.TYPED_ARRAY_SUPPORT &&
1284        typeof Uint8Array.prototype.indexOf === 'function') {
1285      if (dir) {
1286        return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
1287      } else {
1288        return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
1289      }
1290    }
1291    return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
1292  }
1293
1294  throw new TypeError('val must be string, number or Buffer')
1295}
1296
1297function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
1298  var indexSize = 1
1299  var arrLength = arr.length
1300  var valLength = val.length
1301
1302  if (encoding !== undefined) {
1303    encoding = String(encoding).toLowerCase()
1304    if (encoding === 'ucs2' || encoding === 'ucs-2' ||
1305        encoding === 'utf16le' || encoding === 'utf-16le') {
1306      if (arr.length < 2 || val.length < 2) {
1307        return -1
1308      }
1309      indexSize = 2
1310      arrLength /= 2
1311      valLength /= 2
1312      byteOffset /= 2
1313    }
1314  }
1315
1316  function read (buf, i) {
1317    if (indexSize === 1) {
1318      return buf[i]
1319    } else {
1320      return buf.readUInt16BE(i * indexSize)
1321    }
1322  }
1323
1324  var i
1325  if (dir) {
1326    var foundIndex = -1
1327    for (i = byteOffset; i < arrLength; i++) {
1328      if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
1329        if (foundIndex === -1) foundIndex = i
1330        if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
1331      } else {
1332        if (foundIndex !== -1) i -= i - foundIndex
1333        foundIndex = -1
1334      }
1335    }
1336  } else {
1337    if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
1338    for (i = byteOffset; i >= 0; i--) {
1339      var found = true
1340      for (var j = 0; j < valLength; j++) {
1341        if (read(arr, i + j) !== read(val, j)) {
1342          found = false
1343          break
1344        }
1345      }
1346      if (found) return i
1347    }
1348  }
1349
1350  return -1
1351}
1352
1353Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
1354  return this.indexOf(val, byteOffset, encoding) !== -1
1355}
1356
1357Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
1358  return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
1359}
1360
1361Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
1362  return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
1363}
1364
1365function hexWrite (buf, string, offset, length) {
1366  offset = Number(offset) || 0
1367  var remaining = buf.length - offset
1368  if (!length) {
1369    length = remaining
1370  } else {
1371    length = Number(length)
1372    if (length > remaining) {
1373      length = remaining
1374    }
1375  }
1376
1377  // must be an even number of digits
1378  var strLen = string.length
1379  if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
1380
1381  if (length > strLen / 2) {
1382    length = strLen / 2
1383  }
1384  for (var i = 0; i < length; ++i) {
1385    var parsed = parseInt(string.substr(i * 2, 2), 16)
1386    if (isNaN(parsed)) return i
1387    buf[offset + i] = parsed
1388  }
1389  return i
1390}
1391
1392function utf8Write (buf, string, offset, length) {
1393  return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
1394}
1395
1396function asciiWrite (buf, string, offset, length) {
1397  return blitBuffer(asciiToBytes(string), buf, offset, length)
1398}
1399
1400function latin1Write (buf, string, offset, length) {
1401  return asciiWrite(buf, string, offset, length)
1402}
1403
1404function base64Write (buf, string, offset, length) {
1405  return blitBuffer(base64ToBytes(string), buf, offset, length)
1406}
1407
1408function ucs2Write (buf, string, offset, length) {
1409  return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
1410}
1411
1412Buffer.prototype.write = function write (string, offset, length, encoding) {
1413  // Buffer#write(string)
1414  if (offset === undefined) {
1415    encoding = 'utf8'
1416    length = this.length
1417    offset = 0
1418  // Buffer#write(string, encoding)
1419  } else if (length === undefined && typeof offset === 'string') {
1420    encoding = offset
1421    length = this.length
1422    offset = 0
1423  // Buffer#write(string, offset[, length][, encoding])
1424  } else if (isFinite(offset)) {
1425    offset = offset | 0
1426    if (isFinite(length)) {
1427      length = length | 0
1428      if (encoding === undefined) encoding = 'utf8'
1429    } else {
1430      encoding = length
1431      length = undefined
1432    }
1433  // legacy write(string, encoding, offset, length) - remove in v0.13
1434  } else {
1435    throw new Error(
1436      'Buffer.write(string, encoding, offset[, length]) is no longer supported'
1437    )
1438  }
1439
1440  var remaining = this.length - offset
1441  if (length === undefined || length > remaining) length = remaining
1442
1443  if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
1444    throw new RangeError('Attempt to write outside buffer bounds')
1445  }
1446
1447  if (!encoding) encoding = 'utf8'
1448
1449  var loweredCase = false
1450  for (;;) {
1451    switch (encoding) {
1452      case 'hex':
1453        return hexWrite(this, string, offset, length)
1454
1455      case 'utf8':
1456      case 'utf-8':
1457        return utf8Write(this, string, offset, length)
1458
1459      case 'ascii':
1460        return asciiWrite(this, string, offset, length)
1461
1462      case 'latin1':
1463      case 'binary':
1464        return latin1Write(this, string, offset, length)
1465
1466      case 'base64':
1467        // Warning: maxLength not taken into account in base64Write
1468        return base64Write(this, string, offset, length)
1469
1470      case 'ucs2':
1471      case 'ucs-2':
1472      case 'utf16le':
1473      case 'utf-16le':
1474        return ucs2Write(this, string, offset, length)
1475
1476      default:
1477        if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
1478        encoding = ('' + encoding).toLowerCase()
1479        loweredCase = true
1480    }
1481  }
1482}
1483
1484Buffer.prototype.toJSON = function toJSON () {
1485  return {
1486    type: 'Buffer',
1487    data: Array.prototype.slice.call(this._arr || this, 0)
1488  }
1489}
1490
1491function base64Slice (buf, start, end) {
1492  if (start === 0 && end === buf.length) {
1493    return base64.fromByteArray(buf)
1494  } else {
1495    return base64.fromByteArray(buf.slice(start, end))
1496  }
1497}
1498
1499function utf8Slice (buf, start, end) {
1500  end = Math.min(buf.length, end)
1501  var res = []
1502
1503  var i = start
1504  while (i < end) {
1505    var firstByte = buf[i]
1506    var codePoint = null
1507    var bytesPerSequence = (firstByte > 0xEF) ? 4
1508      : (firstByte > 0xDF) ? 3
1509      : (firstByte > 0xBF) ? 2
1510      : 1
1511
1512    if (i + bytesPerSequence <= end) {
1513      var secondByte, thirdByte, fourthByte, tempCodePoint
1514
1515      switch (bytesPerSequence) {
1516        case 1:
1517          if (firstByte < 0x80) {
1518            codePoint = firstByte
1519          }
1520          break
1521        case 2:
1522          secondByte = buf[i + 1]
1523          if ((secondByte & 0xC0) === 0x80) {
1524            tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
1525            if (tempCodePoint > 0x7F) {
1526              codePoint = tempCodePoint
1527            }
1528          }
1529          break
1530        case 3:
1531          secondByte = buf[i + 1]
1532          thirdByte = buf[i + 2]
1533          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
1534            tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
1535            if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
1536              codePoint = tempCodePoint
1537            }
1538          }
1539          break
1540        case 4:
1541          secondByte = buf[i + 1]
1542          thirdByte = buf[i + 2]
1543          fourthByte = buf[i + 3]
1544          if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
1545            tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
1546            if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
1547              codePoint = tempCodePoint
1548            }
1549          }
1550      }
1551    }
1552
1553    if (codePoint === null) {
1554      // we did not generate a valid codePoint so insert a
1555      // replacement char (U+FFFD) and advance only 1 byte
1556      codePoint = 0xFFFD
1557      bytesPerSequence = 1
1558    } else if (codePoint > 0xFFFF) {
1559      // encode to utf16 (surrogate pair dance)
1560      codePoint -= 0x10000
1561      res.push(codePoint >>> 10 & 0x3FF | 0xD800)
1562      codePoint = 0xDC00 | codePoint & 0x3FF
1563    }
1564
1565    res.push(codePoint)
1566    i += bytesPerSequence
1567  }
1568
1569  return decodeCodePointsArray(res)
1570}
1571
1572// Based on http://stackoverflow.com/a/22747272/680742, the browser with
1573// the lowest limit is Chrome, with 0x10000 args.
1574// We go 1 magnitude less, for safety
1575var MAX_ARGUMENTS_LENGTH = 0x1000
1576
1577function decodeCodePointsArray (codePoints) {
1578  var len = codePoints.length
1579  if (len <= MAX_ARGUMENTS_LENGTH) {
1580    return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
1581  }
1582
1583  // Decode in chunks to avoid "call stack size exceeded".
1584  var res = ''
1585  var i = 0
1586  while (i < len) {
1587    res += String.fromCharCode.apply(
1588      String,
1589      codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
1590    )
1591  }
1592  return res
1593}
1594
1595function asciiSlice (buf, start, end) {
1596  var ret = ''
1597  end = Math.min(buf.length, end)
1598
1599  for (var i = start; i < end; ++i) {
1600    ret += String.fromCharCode(buf[i] & 0x7F)
1601  }
1602  return ret
1603}
1604
1605function latin1Slice (buf, start, end) {
1606  var ret = ''
1607  end = Math.min(buf.length, end)
1608
1609  for (var i = start; i < end; ++i) {
1610    ret += String.fromCharCode(buf[i])
1611  }
1612  return ret
1613}
1614
1615function hexSlice (buf, start, end) {
1616  var len = buf.length
1617
1618  if (!start || start < 0) start = 0
1619  if (!end || end < 0 || end > len) end = len
1620
1621  var out = ''
1622  for (var i = start; i < end; ++i) {
1623    out += toHex(buf[i])
1624  }
1625  return out
1626}
1627
1628function utf16leSlice (buf, start, end) {
1629  var bytes = buf.slice(start, end)
1630  var res = ''
1631  for (var i = 0; i < bytes.length; i += 2) {
1632    res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
1633  }
1634  return res
1635}
1636
1637Buffer.prototype.slice = function slice (start, end) {
1638  var len = this.length
1639  start = ~~start
1640  end = end === undefined ? len : ~~end
1641
1642  if (start < 0) {
1643    start += len
1644    if (start < 0) start = 0
1645  } else if (start > len) {
1646    start = len
1647  }
1648
1649  if (end < 0) {
1650    end += len
1651    if (end < 0) end = 0
1652  } else if (end > len) {
1653    end = len
1654  }
1655
1656  if (end < start) end = start
1657
1658  var newBuf
1659  if (Buffer.TYPED_ARRAY_SUPPORT) {
1660    newBuf = this.subarray(start, end)
1661    newBuf.__proto__ = Buffer.prototype
1662  } else {
1663    var sliceLen = end - start
1664    newBuf = new Buffer(sliceLen, undefined)
1665    for (var i = 0; i < sliceLen; ++i) {
1666      newBuf[i] = this[i + start]
1667    }
1668  }
1669
1670  return newBuf
1671}
1672
1673/*
1674 * Need to make sure that buffer isn't trying to write out of bounds.
1675 */
1676function checkOffset (offset, ext, length) {
1677  if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
1678  if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
1679}
1680
1681Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
1682  offset = offset | 0
1683  byteLength = byteLength | 0
1684  if (!noAssert) checkOffset(offset, byteLength, this.length)
1685
1686  var val = this[offset]
1687  var mul = 1
1688  var i = 0
1689  while (++i < byteLength && (mul *= 0x100)) {
1690    val += this[offset + i] * mul
1691  }
1692
1693  return val
1694}
1695
1696Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
1697  offset = offset | 0
1698  byteLength = byteLength | 0
1699  if (!noAssert) {
1700    checkOffset(offset, byteLength, this.length)
1701  }
1702
1703  var val = this[offset + --byteLength]
1704  var mul = 1
1705  while (byteLength > 0 && (mul *= 0x100)) {
1706    val += this[offset + --byteLength] * mul
1707  }
1708
1709  return val
1710}
1711
1712Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
1713  if (!noAssert) checkOffset(offset, 1, this.length)
1714  return this[offset]
1715}
1716
1717Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
1718  if (!noAssert) checkOffset(offset, 2, this.length)
1719  return this[offset] | (this[offset + 1] << 8)
1720}
1721
1722Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
1723  if (!noAssert) checkOffset(offset, 2, this.length)
1724  return (this[offset] << 8) | this[offset + 1]
1725}
1726
1727Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
1728  if (!noAssert) checkOffset(offset, 4, this.length)
1729
1730  return ((this[offset]) |
1731      (this[offset + 1] << 8) |
1732      (this[offset + 2] << 16)) +
1733      (this[offset + 3] * 0x1000000)
1734}
1735
1736Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
1737  if (!noAssert) checkOffset(offset, 4, this.length)
1738
1739  return (this[offset] * 0x1000000) +
1740    ((this[offset + 1] << 16) |
1741    (this[offset + 2] << 8) |
1742    this[offset + 3])
1743}
1744
1745Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
1746  offset = offset | 0
1747  byteLength = byteLength | 0
1748  if (!noAssert) checkOffset(offset, byteLength, this.length)
1749
1750  var val = this[offset]
1751  var mul = 1
1752  var i = 0
1753  while (++i < byteLength && (mul *= 0x100)) {
1754    val += this[offset + i] * mul
1755  }
1756  mul *= 0x80
1757
1758  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1759
1760  return val
1761}
1762
1763Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
1764  offset = offset | 0
1765  byteLength = byteLength | 0
1766  if (!noAssert) checkOffset(offset, byteLength, this.length)
1767
1768  var i = byteLength
1769  var mul = 1
1770  var val = this[offset + --i]
1771  while (i > 0 && (mul *= 0x100)) {
1772    val += this[offset + --i] * mul
1773  }
1774  mul *= 0x80
1775
1776  if (val >= mul) val -= Math.pow(2, 8 * byteLength)
1777
1778  return val
1779}
1780
1781Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
1782  if (!noAssert) checkOffset(offset, 1, this.length)
1783  if (!(this[offset] & 0x80)) return (this[offset])
1784  return ((0xff - this[offset] + 1) * -1)
1785}
1786
1787Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
1788  if (!noAssert) checkOffset(offset, 2, this.length)
1789  var val = this[offset] | (this[offset + 1] << 8)
1790  return (val & 0x8000) ? val | 0xFFFF0000 : val
1791}
1792
1793Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
1794  if (!noAssert) checkOffset(offset, 2, this.length)
1795  var val = this[offset + 1] | (this[offset] << 8)
1796  return (val & 0x8000) ? val | 0xFFFF0000 : val
1797}
1798
1799Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
1800  if (!noAssert) checkOffset(offset, 4, this.length)
1801
1802  return (this[offset]) |
1803    (this[offset + 1] << 8) |
1804    (this[offset + 2] << 16) |
1805    (this[offset + 3] << 24)
1806}
1807
1808Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
1809  if (!noAssert) checkOffset(offset, 4, this.length)
1810
1811  return (this[offset] << 24) |
1812    (this[offset + 1] << 16) |
1813    (this[offset + 2] << 8) |
1814    (this[offset + 3])
1815}
1816
1817Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
1818  if (!noAssert) checkOffset(offset, 4, this.length)
1819  return ieee754.read(this, offset, true, 23, 4)
1820}
1821
1822Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
1823  if (!noAssert) checkOffset(offset, 4, this.length)
1824  return ieee754.read(this, offset, false, 23, 4)
1825}
1826
1827Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
1828  if (!noAssert) checkOffset(offset, 8, this.length)
1829  return ieee754.read(this, offset, true, 52, 8)
1830}
1831
1832Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
1833  if (!noAssert) checkOffset(offset, 8, this.length)
1834  return ieee754.read(this, offset, false, 52, 8)
1835}
1836
1837function checkInt (buf, value, offset, ext, max, min) {
1838  if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
1839  if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
1840  if (offset + ext > buf.length) throw new RangeError('Index out of range')
1841}
1842
1843Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
1844  value = +value
1845  offset = offset | 0
1846  byteLength = byteLength | 0
1847  if (!noAssert) {
1848    var maxBytes = Math.pow(2, 8 * byteLength) - 1
1849    checkInt(this, value, offset, byteLength, maxBytes, 0)
1850  }
1851
1852  var mul = 1
1853  var i = 0
1854  this[offset] = value & 0xFF
1855  while (++i < byteLength && (mul *= 0x100)) {
1856    this[offset + i] = (value / mul) & 0xFF
1857  }
1858
1859  return offset + byteLength
1860}
1861
1862Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
1863  value = +value
1864  offset = offset | 0
1865  byteLength = byteLength | 0
1866  if (!noAssert) {
1867    var maxBytes = Math.pow(2, 8 * byteLength) - 1
1868    checkInt(this, value, offset, byteLength, maxBytes, 0)
1869  }
1870
1871  var i = byteLength - 1
1872  var mul = 1
1873  this[offset + i] = value & 0xFF
1874  while (--i >= 0 && (mul *= 0x100)) {
1875    this[offset + i] = (value / mul) & 0xFF
1876  }
1877
1878  return offset + byteLength
1879}
1880
1881Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
1882  value = +value
1883  offset = offset | 0
1884  if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
1885  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
1886  this[offset] = (value & 0xff)
1887  return offset + 1
1888}
1889
1890function objectWriteUInt16 (buf, value, offset, littleEndian) {
1891  if (value < 0) value = 0xffff + value + 1
1892  for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
1893    buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
1894      (littleEndian ? i : 1 - i) * 8
1895  }
1896}
1897
1898Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
1899  value = +value
1900  offset = offset | 0
1901  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1902  if (Buffer.TYPED_ARRAY_SUPPORT) {
1903    this[offset] = (value & 0xff)
1904    this[offset + 1] = (value >>> 8)
1905  } else {
1906    objectWriteUInt16(this, value, offset, true)
1907  }
1908  return offset + 2
1909}
1910
1911Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
1912  value = +value
1913  offset = offset | 0
1914  if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
1915  if (Buffer.TYPED_ARRAY_SUPPORT) {
1916    this[offset] = (value >>> 8)
1917    this[offset + 1] = (value & 0xff)
1918  } else {
1919    objectWriteUInt16(this, value, offset, false)
1920  }
1921  return offset + 2
1922}
1923
1924function objectWriteUInt32 (buf, value, offset, littleEndian) {
1925  if (value < 0) value = 0xffffffff + value + 1
1926  for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
1927    buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
1928  }
1929}
1930
1931Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
1932  value = +value
1933  offset = offset | 0
1934  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1935  if (Buffer.TYPED_ARRAY_SUPPORT) {
1936    this[offset + 3] = (value >>> 24)
1937    this[offset + 2] = (value >>> 16)
1938    this[offset + 1] = (value >>> 8)
1939    this[offset] = (value & 0xff)
1940  } else {
1941    objectWriteUInt32(this, value, offset, true)
1942  }
1943  return offset + 4
1944}
1945
1946Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
1947  value = +value
1948  offset = offset | 0
1949  if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
1950  if (Buffer.TYPED_ARRAY_SUPPORT) {
1951    this[offset] = (value >>> 24)
1952    this[offset + 1] = (value >>> 16)
1953    this[offset + 2] = (value >>> 8)
1954    this[offset + 3] = (value & 0xff)
1955  } else {
1956    objectWriteUInt32(this, value, offset, false)
1957  }
1958  return offset + 4
1959}
1960
1961Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
1962  value = +value
1963  offset = offset | 0
1964  if (!noAssert) {
1965    var limit = Math.pow(2, 8 * byteLength - 1)
1966
1967    checkInt(this, value, offset, byteLength, limit - 1, -limit)
1968  }
1969
1970  var i = 0
1971  var mul = 1
1972  var sub = 0
1973  this[offset] = value & 0xFF
1974  while (++i < byteLength && (mul *= 0x100)) {
1975    if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1976      sub = 1
1977    }
1978    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
1979  }
1980
1981  return offset + byteLength
1982}
1983
1984Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
1985  value = +value
1986  offset = offset | 0
1987  if (!noAssert) {
1988    var limit = Math.pow(2, 8 * byteLength - 1)
1989
1990    checkInt(this, value, offset, byteLength, limit - 1, -limit)
1991  }
1992
1993  var i = byteLength - 1
1994  var mul = 1
1995  var sub = 0
1996  this[offset + i] = value & 0xFF
1997  while (--i >= 0 && (mul *= 0x100)) {
1998    if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1999      sub = 1
2000    }
2001    this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
2002  }
2003
2004  return offset + byteLength
2005}
2006
2007Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
2008  value = +value
2009  offset = offset | 0
2010  if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
2011  if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
2012  if (value < 0) value = 0xff + value + 1
2013  this[offset] = (value & 0xff)
2014  return offset + 1
2015}
2016
2017Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
2018  value = +value
2019  offset = offset | 0
2020  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
2021  if (Buffer.TYPED_ARRAY_SUPPORT) {
2022    this[offset] = (value & 0xff)
2023    this[offset + 1] = (value >>> 8)
2024  } else {
2025    objectWriteUInt16(this, value, offset, true)
2026  }
2027  return offset + 2
2028}
2029
2030Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
2031  value = +value
2032  offset = offset | 0
2033  if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
2034  if (Buffer.TYPED_ARRAY_SUPPORT) {
2035    this[offset] = (value >>> 8)
2036    this[offset + 1] = (value & 0xff)
2037  } else {
2038    objectWriteUInt16(this, value, offset, false)
2039  }
2040  return offset + 2
2041}
2042
2043Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
2044  value = +value
2045  offset = offset | 0
2046  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2047  if (Buffer.TYPED_ARRAY_SUPPORT) {
2048    this[offset] = (value & 0xff)
2049    this[offset + 1] = (value >>> 8)
2050    this[offset + 2] = (value >>> 16)
2051    this[offset + 3] = (value >>> 24)
2052  } else {
2053    objectWriteUInt32(this, value, offset, true)
2054  }
2055  return offset + 4
2056}
2057
2058Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
2059  value = +value
2060  offset = offset | 0
2061  if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
2062  if (value < 0) value = 0xffffffff + value + 1
2063  if (Buffer.TYPED_ARRAY_SUPPORT) {
2064    this[offset] = (value >>> 24)
2065    this[offset + 1] = (value >>> 16)
2066    this[offset + 2] = (value >>> 8)
2067    this[offset + 3] = (value & 0xff)
2068  } else {
2069    objectWriteUInt32(this, value, offset, false)
2070  }
2071  return offset + 4
2072}
2073
2074function checkIEEE754 (buf, value, offset, ext, max, min) {
2075  if (offset + ext > buf.length) throw new RangeError('Index out of range')
2076  if (offset < 0) throw new RangeError('Index out of range')
2077}
2078
2079function writeFloat (buf, value, offset, littleEndian, noAssert) {
2080  if (!noAssert) {
2081    checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
2082  }
2083  ieee754.write(buf, value, offset, littleEndian, 23, 4)
2084  return offset + 4
2085}
2086
2087Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
2088  return writeFloat(this, value, offset, true, noAssert)
2089}
2090
2091Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
2092  return writeFloat(this, value, offset, false, noAssert)
2093}
2094
2095function writeDouble (buf, value, offset, littleEndian, noAssert) {
2096  if (!noAssert) {
2097    checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
2098  }
2099  ieee754.write(buf, value, offset, littleEndian, 52, 8)
2100  return offset + 8
2101}
2102
2103Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
2104  return writeDouble(this, value, offset, true, noAssert)
2105}
2106
2107Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
2108  return writeDouble(this, value, offset, false, noAssert)
2109}
2110
2111// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
2112Buffer.prototype.copy = function copy (target, targetStart, start, end) {
2113  if (!start) start = 0
2114  if (!end && end !== 0) end = this.length
2115  if (targetStart >= target.length) targetStart = target.length
2116  if (!targetStart) targetStart = 0
2117  if (end > 0 && end < start) end = start
2118
2119  // Copy 0 bytes; we're done
2120  if (end === start) return 0
2121  if (target.length === 0 || this.length === 0) return 0
2122
2123  // Fatal error conditions
2124  if (targetStart < 0) {
2125    throw new RangeError('targetStart out of bounds')
2126  }
2127  if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
2128  if (end < 0) throw new RangeError('sourceEnd out of bounds')
2129
2130  // Are we oob?
2131  if (end > this.length) end = this.length
2132  if (target.length - targetStart < end - start) {
2133    end = target.length - targetStart + start
2134  }
2135
2136  var len = end - start
2137  var i
2138
2139  if (this === target && start < targetStart && targetStart < end) {
2140    // descending copy from end
2141    for (i = len - 1; i >= 0; --i) {
2142      target[i + targetStart] = this[i + start]
2143    }
2144  } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
2145    // ascending copy from start
2146    for (i = 0; i < len; ++i) {
2147      target[i + targetStart] = this[i + start]
2148    }
2149  } else {
2150    Uint8Array.prototype.set.call(
2151      target,
2152      this.subarray(start, start + len),
2153      targetStart
2154    )
2155  }
2156
2157  return len
2158}
2159
2160// Usage:
2161//    buffer.fill(number[, offset[, end]])
2162//    buffer.fill(buffer[, offset[, end]])
2163//    buffer.fill(string[, offset[, end]][, encoding])
2164Buffer.prototype.fill = function fill (val, start, end, encoding) {
2165  // Handle string cases:
2166  if (typeof val === 'string') {
2167    if (typeof start === 'string') {
2168      encoding = start
2169      start = 0
2170      end = this.length
2171    } else if (typeof end === 'string') {
2172      encoding = end
2173      end = this.length
2174    }
2175    if (val.length === 1) {
2176      var code = val.charCodeAt(0)
2177      if (code < 256) {
2178        val = code
2179      }
2180    }
2181    if (encoding !== undefined && typeof encoding !== 'string') {
2182      throw new TypeError('encoding must be a string')
2183    }
2184    if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
2185      throw new TypeError('Unknown encoding: ' + encoding)
2186    }
2187  } else if (typeof val === 'number') {
2188    val = val & 255
2189  }
2190
2191  // Invalid ranges are not set to a default, so can range check early.
2192  if (start < 0 || this.length < start || this.length < end) {
2193    throw new RangeError('Out of range index')
2194  }
2195
2196  if (end <= start) {
2197    return this
2198  }
2199
2200  start = start >>> 0
2201  end = end === undefined ? this.length : end >>> 0
2202
2203  if (!val) val = 0
2204
2205  var i
2206  if (typeof val === 'number') {
2207    for (i = start; i < end; ++i) {
2208      this[i] = val
2209    }
2210  } else {
2211    var bytes = Buffer.isBuffer(val)
2212      ? val
2213      : utf8ToBytes(new Buffer(val, encoding).toString())
2214    var len = bytes.length
2215    for (i = 0; i < end - start; ++i) {
2216      this[i + start] = bytes[i % len]
2217    }
2218  }
2219
2220  return this
2221}
2222
2223// HELPER FUNCTIONS
2224// ================
2225
2226var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
2227
2228function base64clean (str) {
2229  // Node strips out invalid characters like \n and \t from the string, base64-js does not
2230  str = stringtrim(str).replace(INVALID_BASE64_RE, '')
2231  // Node converts strings with length < 2 to ''
2232  if (str.length < 2) return ''
2233  // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
2234  while (str.length % 4 !== 0) {
2235    str = str + '='
2236  }
2237  return str
2238}
2239
2240function stringtrim (str) {
2241  if (str.trim) return str.trim()
2242  return str.replace(/^\s+|\s+$/g, '')
2243}
2244
2245function toHex (n) {
2246  if (n < 16) return '0' + n.toString(16)
2247  return n.toString(16)
2248}
2249
2250function utf8ToBytes (string, units) {
2251  units = units || Infinity
2252  var codePoint
2253  var length = string.length
2254  var leadSurrogate = null
2255  var bytes = []
2256
2257  for (var i = 0; i < length; ++i) {
2258    codePoint = string.charCodeAt(i)
2259
2260    // is surrogate component
2261    if (codePoint > 0xD7FF && codePoint < 0xE000) {
2262      // last char was a lead
2263      if (!leadSurrogate) {
2264        // no lead yet
2265        if (codePoint > 0xDBFF) {
2266          // unexpected trail
2267          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2268          continue
2269        } else if (i + 1 === length) {
2270          // unpaired lead
2271          if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2272          continue
2273        }
2274
2275        // valid lead
2276        leadSurrogate = codePoint
2277
2278        continue
2279      }
2280
2281      // 2 leads in a row
2282      if (codePoint < 0xDC00) {
2283        if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2284        leadSurrogate = codePoint
2285        continue
2286      }
2287
2288      // valid surrogate pair
2289      codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
2290    } else if (leadSurrogate) {
2291      // valid bmp char, but last char was a lead
2292      if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
2293    }
2294
2295    leadSurrogate = null
2296
2297    // encode utf8
2298    if (codePoint < 0x80) {
2299      if ((units -= 1) < 0) break
2300      bytes.push(codePoint)
2301    } else if (codePoint < 0x800) {
2302      if ((units -= 2) < 0) break
2303      bytes.push(
2304        codePoint >> 0x6 | 0xC0,
2305        codePoint & 0x3F | 0x80
2306      )
2307    } else if (codePoint < 0x10000) {
2308      if ((units -= 3) < 0) break
2309      bytes.push(
2310        codePoint >> 0xC | 0xE0,
2311        codePoint >> 0x6 & 0x3F | 0x80,
2312        codePoint & 0x3F | 0x80
2313      )
2314    } else if (codePoint < 0x110000) {
2315      if ((units -= 4) < 0) break
2316      bytes.push(
2317        codePoint >> 0x12 | 0xF0,
2318        codePoint >> 0xC & 0x3F | 0x80,
2319        codePoint >> 0x6 & 0x3F | 0x80,
2320        codePoint & 0x3F | 0x80
2321      )
2322    } else {
2323      throw new Error('Invalid code point')
2324    }
2325  }
2326
2327  return bytes
2328}
2329
2330function asciiToBytes (str) {
2331  var byteArray = []
2332  for (var i = 0; i < str.length; ++i) {
2333    // Node's code seems to be doing this and not & 0x7F..
2334    byteArray.push(str.charCodeAt(i) & 0xFF)
2335  }
2336  return byteArray
2337}
2338
2339function utf16leToBytes (str, units) {
2340  var c, hi, lo
2341  var byteArray = []
2342  for (var i = 0; i < str.length; ++i) {
2343    if ((units -= 2) < 0) break
2344
2345    c = str.charCodeAt(i)
2346    hi = c >> 8
2347    lo = c % 256
2348    byteArray.push(lo)
2349    byteArray.push(hi)
2350  }
2351
2352  return byteArray
2353}
2354
2355function base64ToBytes (str) {
2356  return base64.toByteArray(base64clean(str))
2357}
2358
2359function blitBuffer (src, dst, offset, length) {
2360  for (var i = 0; i < length; ++i) {
2361    if ((i + offset >= dst.length) || (i >= src.length)) break
2362    dst[i + offset] = src[i]
2363  }
2364  return i
2365}
2366
2367function isnan (val) {
2368  return val !== val // eslint-disable-line no-self-compare
2369}
2370
2371},{"base64-js":"node_modules/base64-js/index.js","ieee754":"node_modules/ieee754/index.js","isarray":"node_modules/isarray/index.js","buffer":"node_modules/buffer/index.js"}],"node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js":[function(require,module,exports) {
2372var global = arguments[3];
2373var process = require("process");
2374var Buffer = require("buffer").Buffer;
2375"use strict";
2376
2377Object.defineProperty(exports, "__esModule", {
2378  value: true
2379});
2380exports.backend = hn;
2381exports.buffer = er;
2382exports.customGrad = ea;
2383exports.deprecationWarn = Xe;
2384exports.disableDeprecationWarnings = je;
2385exports.dispose = tn;
2386exports.disposeVariables = Ye;
2387exports.enableDebugMode = Ke;
2388exports.enableProdMode = qe;
2389exports.engine = $e;
2390exports.env = i;
2391exports.fill = Hn;
2392exports.findBackend = un;
2393exports.findBackendFactory = cn;
2394exports.getBackend = an;
2395exports.getGradient = h;
2396exports.getKernel = l;
2397exports.getKernelsForBackend = f;
2398exports.grad = $o;
2399exports.grads = Qo;
2400exports.keep = en;
2401exports.linspace = qn;
2402exports.memory = Qe;
2403exports.nextFrame = Hd;
2404exports.ones = zn;
2405exports.op = An;
2406exports.print = nr;
2407exports.profile = Je;
2408exports.range = Kn;
2409exports.ready = on;
2410exports.registerBackend = ln;
2411exports.registerGradient = p;
2412exports.registerKernel = d;
2413exports.removeBackend = sn;
2414exports.scalar = On;
2415exports.setBackend = rn;
2416exports.setPlatform = fn;
2417exports.sumOutType = Dt;
2418exports.tensor = Fn;
2419exports.tensor1d = Mn;
2420exports.tensor2d = Bn;
2421exports.tensor3d = Pn;
2422exports.tensor4d = Ln;
2423exports.tensor5d = Wn;
2424exports.tensor6d = Un;
2425exports.tidy = Ze;
2426exports.time = nn;
2427exports.unregisterGradient = m;
2428exports.unregisterKernel = v;
2429exports.valueAndGrad = Jo;
2430exports.valueAndGrads = Zo;
2431exports.variable = Vn;
2432exports.variableGrads = ta;
2433exports.zeros = Gn;
2434exports.inTopKAsync = exports.image = exports.imag = exports.ifft = exports.hannWindow = exports.hammingWindow = exports.greaterStrict = exports.greaterEqualStrict = exports.greaterEqual = exports.greater = exports.gather_util = exports.gatherND = exports.gather = exports.fused = exports.frame = exports.floorDiv = exports.floor = exports.fft = exports.eye = exports.expm1 = exports.expandDims = exports.exp = exports.erf = exports.equalStrict = exports.equal = exports.elu = exports.dropout = exports.dot = exports.divStrict = exports.divNoNan = exports.div = exports.diag = exports.depthwiseConv2d = exports.depthToSpace = exports.cumsum = exports.cosh = exports.cos = exports.conv3dTranspose = exports.conv3d = exports.conv2dTranspose = exports.conv2d = exports.conv1d = exports.concat4d = exports.concat3d = exports.concat2d = exports.concat1d = exports.concat = exports.complex = exports.clone = exports.clipByValue = exports.ceil = exports.cast = exports.browser = exports.broadcastTo = exports.booleanMaskAsync = exports.batchToSpaceND = exports.batchNormalization4d = exports.batchNormalization3d = exports.batchNormalization2d = exports.batchNormalization = exports.batchNorm4d = exports.batchNorm3d = exports.batchNorm2d = exports.batchNorm = exports.basicLSTMCell = exports.backend_util = exports.avgPool3d = exports.avgPool = exports.atanh = exports.atan2 = exports.atan = exports.asinh = exports.asin = exports.argMin = exports.argMax = exports.any = exports.all = exports.addStrict = exports.addN = exports.add = exports.acosh = exports.acos = exports.abs = exports.Variable = exports.TensorBuffer = exports.Tensor = exports.SGDOptimizer = exports.Reduction = exports.Rank = exports.RMSPropOptimizer = exports.Optimizer = exports.MomentumOptimizer = exports.KernelBackend = exports.Environment = exports.ENV = exports.DataStorage = exports.AdamaxOptimizer = exports.AdamOptimizer = exports.AdagradOptimizer = exports.AdadeltaOptimizer = void 0;
2435exports.square = exports.sqrt = exports.split = exports.spectral = exports.sparseToDense = exports.spaceToBatchND = exports.softplus = exports.softmax = exports.slice_util = exports.slice4d = exports.slice3d = exports.slice2d = exports.slice1d = exports.slice = exports.sinh = exports.sin = exports.signal = exports.sign = exports.sigmoid = exports.setdiff1dAsync = exports.serialization = exports.separableConv2d = exports.selu = exports.scatter_util = exports.scatterND = exports.rsqrt = exports.round = exports.rfft = exports.reverse4d = exports.reverse3d = exports.reverse2d = exports.reverse1d = exports.reverse = exports.reshape = exports.relu6 = exports.relu = exports.reciprocal = exports.real = exports.randomUniform = exports.randomNormal = exports.randomGamma = exports.rand = exp
2435orts.prod = exports.prelu = exports.powStrict = exports.pow = exports.pool = exports.pad4d = exports.pad3d = exports.pad2d = exports.pad1d = exports.pad = exports.outerProduct = exports.onesLike = exports.oneHot = exports.notEqualStrict = exports.notEqual = exports.norm = exports.neg = exports.multinomial = exports.multiRNNCell = exports.mulStrict = exports.mul = exports.movingAverage = exports.moments = exports.modStrict = exports.mod = exports.minimumStrict = exports.minimum = exports.min = exports.mean = exports.maximumStrict = exports.maximum = exports.maxPool3d = exports.maxPool = exports.max = exp
2435orts.math = exports.matMul = exports.losses = exports.logicalXor = exports.logicalOr = exports.logicalNot = exports.logicalAnd = exports.logSumExp = exports.logSoftmax = exports.logSigmoid = exports.log1p = exports.log = exports.localResponseNormalization = exports.linalg = exports.lessStrict = exports.lessEqualStrict = exports.lessEqual = exports.less = exports.leakyRelu = exports.isNaN = exports.isInf = exports.isFinite = exports.irfft = exports.io = void 0;
2436exports.zerosLike = exports.whereAsync = exports.where = exports.webgl = exports.version_core = exports.util = exports.unstack = exports.unsortedSegmentSum = exports.truncatedNormal = exports.transpose = exports.train = exports.topk = exports.tile = exports.test_util = exports.tensor_util = exports.tanh = exports.tan = exports.sum = exports.subStrict = exports.sub = exports.stridedSlice = exports.stft = exports.step = exports.stack = exports.squeeze = exports.squaredDifferenceStrict = exports.squaredDifference = void 0;
2437
2438/**
2439 * @license
2440 * Copyright 2020 Google LLC. All Rights Reserved.
2441 * Licensed under the Apache License, Version 2.0 (the "License");
2442 * you may not use this file except in compliance with the License.
2443 * You may obtain a copy of the License at
2444 *
2445 * http://www.apache.org/licenses/LICENSE-2.0
2446 *
2447 * Unless required by applicable law or agreed to in writing, software
2448 * distributed under the License is distributed on an "AS IS" BASIS,
2449 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2450 * See the License for the specific language governing permissions and
2451 * limitations under the License.
2452 * =============================================================================
2453 */
2454var t = function (e, n) {
2455  return (t = Object.setPrototypeOf || {
2456    __proto__: []
2457  } instanceof Array && function (t, e) {
2458    t.__proto__ = e;
2459  } || function (t, e) {
2460    for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
2461  })(e, n);
2462};
2463
2464function e(e, n) {
2465  function r() {
2466    this.constructor = e;
2467  }
2468
2469  t(e, n), e.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, new r());
2470}
2471
2472function n(t, e, n, r) {
2473  return new (n || (n = Promise))(function (o, a) {
2474    function i(t) {
2475      try {
2476        u(r.next(t));
2477      } catch (t) {
2478        a(t);
2479      }
2480    }
2481
2482    function s(t) {
2483      try {
2484        u(r.throw(t));
2485      } catch (t) {
2486        a(t);
2487      }
2488    }
2489
2490    function u(t) {
2491      t.done ? o(t.value) : new n(function (e) {
2492        e(t.value);
2493      }).then(i, s);
2494    }
2495
2496    u((r = r.apply(t, e || [])).next());
2497  });
2498}
2499
2500function r(t, e) {
2501  var n,
2502      r,
2503      o,
2504      a,
2505      i = {
2506    label: 0,
2507    sent: function () {
2508      if (1 & o[0]) throw o[1];
2509      return o[1];
2510    },
2511    trys: [],
2512    ops: []
2513  };
2514  return a = {
2515    next: s(0),
2516    throw: s(1),
2517    return: s(2)
2518  }, "function" == typeof Symbol && (a[Symbol.iterator] = function () {
2519    return this;
2520  }), a;
2521
2522  function s(a) {
2523    return function (s) {
2524      return function (a) {
2525        if (n) throw new TypeError("Generator is already executing.");
2526
2527        for (; i;) try {
2528          if (n = 1, r && (o = 2 & a[0] ? r.return : a[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, a[1])).done) return o;
2529
2530          switch (r = 0, o && (a = [2 & a[0], o.value]), a[0]) {
2531            case 0:
2532            case 1:
2533              o = a;
2534              break;
2535
2536            case 4:
2537              return i.label++, {
2538                value: a[1],
2539                done: !1
2540              };
2541
2542            case 5:
2543              i.label++, r = a[1], a = [0];
2544              continue;
2545
2546            case 7:
2547              a = i.ops.pop(), i.trys.pop();
2548              continue;
2549
2550            default:
2551              if (!(o = (o = i.trys).length > 0 && o[o.length - 1]) && (6 === a[0] || 2 === a[0])) {
2552                i = 0;
2553                continue;
2554              }
2555
2556              if (3 === a[0] && (!o || a[1] > o[0] && a[1] < o[3])) {
2557                i.label = a[1];
2558                break;
2559              }
2560
2561              if (6 === a[0] && i.label < o[1]) {
2562                i.label = o[1], o = a;
2563                break;
2564              }
2565
2566              if (o && i.label < o[2]) {
2567                i.label = o[2], i.ops.push(a);
2568                break;
2569              }
2570
2571              o[2] && i.ops.pop(), i.trys.pop();
2572              continue;
2573          }
2574
2575          a = e.call(t, i);
2576        } catch (t) {
2577          a = [6, t], r = 0;
2578        } finally {
2579          n = o = 0;
2580        }
2581
2582        if (5 & a[0]) throw a[1];
2583        return {
2584          value: a[0] ? a[1] : void 0,
2585          done: !0
2586        };
2587      }([a, s]);
2588    };
2589  }
2590}
2591
2592var o = function () {
2593  function t(t) {
2594    this.global = t, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.populateURLFlags();
2595  }
2596
2597  return t.prototype.setPlatform = function (t, e) {
2598    null != this.platform && console.warn("Platform " + this.platformName + " has already been set. Overwriting the platform with " + e + "."), this.platformName = t, this.platform = e;
2599  }, t.prototype.registerFlag = function (t, e, n) {
2600    if (this.flagRegistry[t] = {
2601      evaluationFn: e,
2602      setHook: n
2603    }, null != this.urlFlags[t]) {
2604      var r = this.urlFlags[t];
2605      console.warn("Setting feature override from URL " + t + ": " + r + "."), this.set(t, r);
2606    }
2607  }, t.prototype.get = function (t) {
2608    return t in this.flags ? this.flags[t] : (this.flags[t] = this.evaluateFlag(t), this.flags[t]);
2609  }, t.prototype.getNumber = function (t) {
2610    return this.get(t);
2611  }, t.prototype.getBool = function (t) {
2612    return this.get(t);
2613  }, t.prototype.getFlags = function () {
2614    return this.flags;
2615  }, Object.defineProperty(t.prototype, "features", {
2616    get: function () {
2617      return this.flags;
2618    },
2619    enumerable: !0,
2620    configurable: !0
2621  }), t.prototype.set = function (t, e) {
2622    if (null == this.flagRegistry[t]) throw new Error("Cannot set flag " + t + " as it has not been registered.");
2623    this.flags[t] = e, null != this.flagRegistry[t].setHook && this.flagRegistry[t].setHook(e);
2624  }, t.prototype.evaluateFlag = function (t) {
2625    if (null == this.flagRegistry[t]) throw new Error("Cannot evaluate flag '" + t + "': no evaluation function found.");
2626    return this.flagRegistry[t].evaluationFn();
2627  }, t.prototype.setFlags = function (t) {
2628    this.flags = Object.assign({}, t);
2629  }, t.prototype.reset = function () {
2630    this.flags = {}, this.urlFlags = {}, this.populateURLFlags();
2631  }, t.prototype.populateURLFlags = function () {
2632    var t = this;
2633
2634    if (void 0 !== this.global && void 0 !== this.global.location && void 0 !== this.global.location.search) {
2635      var e,
2636          n,
2637          r = (e = this.global.location.search, n = {}, e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, function (t) {
2638        for (var e = [], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r];
2639
2640        return a(n, e[0], e[1]), e.join("=");
2641      }), n);
2642      if ("tfjsflags" in r) r.tfjsflags.split(",").forEach(function (e) {
2643        var n = e.split(":"),
2644            r = n[0],
2645            o = n[1];
2646
2647        t.urlFlags[r] = function (t, e) {
2648          if ("true" === (e = e.toLowerCase()) || "false" === e) return "true" === e;
2649          if ("" + +e === e) return +e;
2650          throw new Error("Could not parse value flag value " + e + " for flag " + t + ".");
2651        }(r, o);
2652      });
2653    }
2654  }, t;
2655}();
2656
2657exports.Environment = o;
2658
2659function a(t, e, n) {
2660  t[decodeURIComponent(e)] = decodeURIComponent(n || "");
2661}
2662
2663function i() {
2664  return s;
2665}
2666
2667var s = null;
2668exports.ENV = s;
2669var u = new Map(),
2670    c = new Map();
2671
2672function l(t, e) {
2673  var n = g(t, e);
2674  return u.get(n);
2675}
2676
2677function h(t) {
2678  return c.get(t);
2679}
2680
2681function f(t) {
2682  for (var e = u.entries(), n = [];;) {
2683    var r = e.next(),
2684        o = r.done,
2685        a = r.value;
2686    if (o) break;
2687    var i = a[0],
2688        s = a[1];
2689    i.split("_")[0] === t && n.push(s);
2690  }
2691
2692  return n;
2693}
2694
2695function d(t) {
2696  var e = t.kernelName,
2697      n = t.backendName,
2698      r = g(e, n);
2699  if (u.has(r)) throw new Error("The kernel '" + e + "' for backend '" + n + "' is already registered");
2700  u.set(r, t);
2701}
2702
2703function p(t) {
2704  var e = t.kernelName;
2705  c.has(e) && console.warn("Overriding the gradient for '" + e + "'"), c.set(e, t);
2706}
2707
2708function v(t, e) {
2709  var n = g(t, e);
2710  if (!u.has(n)) throw new Error("The kernel '" + t + "' for backend '" + e + "' is not registered");
2711  u.delete(n);
2712}
2713
2714function m(t) {
2715  if (!c.has(t)) throw new Error("The gradient '" + t + "' for backend is not registered");
2716  c.delete(t);
2717}
2718
2719function g(t, e) {
2720  return e + "_" + t;
2721}
2722
2723function y(t) {
2724  for (var e = t.length, n = 0, r = 0; e > 0;) r = Math.random() * e | 0, n = t[--e], t[e] = t[r], t[r] = n;
2725}
2726
2727function x(t, e, n) {
2728  return Math.max(t, Math.min(e, n));
2729}
2730
2731function b(t) {
2732  return t % 2 == 0 ? t : t + 1;
2733}
2734
2735function w(t) {
2736  for (var e = 0, n = 0; n < t.length; n++) e += t[n];
2737
2738  return e;
2739}
2740
2741function C(t, e) {
2742  if (!t) throw new Error("string" == typeof e ? e : e());
2743}
2744
2745function E(t, e, n) {
2746  void 0 === n && (n = ""), C(S(t, e), function () {
2747    return n + " Shapes " + t + " and " + e + " must match";
2748  });
2749}
2750
2751function R(t) {
2752  C(null != t, function () {
2753    return "The input to the tensor constructor must be a non-null value.";
2754  });
2755}
2756
2757function I(t, e, n) {
2758  if (void 0 === e && (e = []), void 0 === n && (n = !1), null == e && (e = []), Array.isArray(t) || V(t) && !n) for (var r = 0; r < t.length; ++r) I(t[r], e, n);else e.push(t);
2759  return e;
2760}
2761
2762function k(t) {
2763  if (0 === t.length) return 1;
2764
2765  for (var e = t[0], n = 1; n < t.length; n++) e *= t[n];
2766
2767  return e;
2768}
2769
2770function S(t, e) {
2771  if (t === e) return !0;
2772  if (null == t || null == e) return !1;
2773  if (t.length !== e.length) return !1;
2774
2775  for (var n = 0; n < t.length; n++) if (t[n] !== e[n]) return !1;
2776
2777  return !0;
2778}
2779
2780function A(t) {
2781  return t % 1 == 0;
2782}
2783
2784function T(t) {
2785  if (null != Math.tanh) return Math.tanh(t);
2786  if (t === 1 / 0) return 1;
2787  if (t === -1 / 0) return -1;
2788  var e = Math.exp(2 * t);
2789  return (e - 1) / (e + 1);
2790}
2791
2792function D(t) {
2793  var e = Math.ceil(Math.sqrt(t));
2794  return [e, Math.ceil(t / e)];
2795}
2796
2797function N(t, e) {
2798  return e <= t.length ? t : t + " ".repeat(e - t.length);
2799}
2800
2801function F(t, e, n) {
2802  return void 0 === e && (e = function (t) {
2803    return 0;
2804  }), new Promise(function (r, o) {
2805    var a = 0,
2806        i = function () {
2807      if (t()) r();else {
2808        a++;
2809        var s = e(a);
2810        null != n && a >= n ? o() : setTimeout(i, s);
2811      }
2812    };
2813
2814    i();
2815  });
2816}
2817
2818function _(t, e) {
2819  for (var n = 1, r = -1, o = 0; o < t.length; ++o) if (t[o] >= 0) n *= t[o];else if (-1 === t[o]) {
2820    if (-1 !== r) throw Error("Shapes can only have 1 implicit size. Found -1 at dim " + r + " and dim " + o);
2821    r = o;
2822  } else if (t[o] < 0) throw Error("Shapes can not be < 0. Found " + t[o] + " at dim " + o);
2823
2824  if (-1 === r) {
2825    if (e > 0 && e !== n) throw Error("Size(" + e + ") must match the product of shape " + t);
2826    return t;
2827  }
2828
2829  if (0 === n) throw Error("Cannot infer the missing size in [" + t + "] when there are 0 elements");
2830  if (e % n != 0) throw Error("The implicit shape can't be a fractional number. Got " + e + " / " + n);
2831  var a = t.slice();
2832  return a[r] = e / n, a;
2833}
2834
2835function O(t, e) {
2836  var n = e.length;
2837  return C((t = null == t ? e.map(function (t, e) {
2838    return e;
2839  }) : [].concat(t)).every(function (t) {
2840    return t >= -n && t < n;
2841  }), function () {
2842    return "All values in axis param must be in range [-" + n + ", " + n + ") but got axis " + t;
2843  }), C(t.every(function (t) {
2844    return A(t);
2845  }), function () {
2846    return "All values in axis param must be integers but got axis " + t;
2847  }), t.map(function (t) {
2848    return t < 0 ? n + t : t;
2849  });
2850}
2851
2852function M(t, e) {
2853  for (var n = [], r = [], o = null != e && Array.isArray(e) && 0 === e.length, a = null == e || o ? null : O(e, t).sort(), i = 0, s = 0; s < t.length; ++s) {
2854    if (null != a) {
2855      if (a[i] === s && 1 !== t[s]) throw new Error("Can't squeeze axis " + s + " since its dim '" + t[s] + "' is not 1");
2856      (null == a[i] || a[i] > s) && 1 === t[s] && (n.push(t[s]), r.push(s)), a[i] <= s && i++;
2857    }
2858
2859    1 !== t[s] && (n.push(t[s]), r.push(s));
2860  }
2861
2862  return {
2863    newShape: n,
2864    keptDims: r
2865  };
2866}
2867
2868function B(t, e) {
2869  var n = null;
2870  if (null == t || "float32" === t) n = new Float32Array(e);else if ("int32" === t) n = new Int32Array(e);else {
2871    if ("bool" !== t) throw new Error("Unknown data type " + t);
2872    n = new Uint8Array(e);
2873  }
2874  return n;
2875}
2876
2877function P(t, e) {
2878  var n = null;
2879  if (null == t || "float32" === t) n = new Float32Array(e);else if ("int32" === t) n = new Int32Array(e);else if ("bool" === t) n = new Uint8Array(e);else {
2880    if ("string" !== t) throw new Error("Unknown data type " + t);
2881    n = new Array(e);
2882  }
2883  return n;
2884}
2885
2886function L(t, e) {
2887  for (var n = 0; n < t.length; n++) {
2888    var r = t[n];
2889    if (isNaN(r) || !isFinite(r)) throw Error("A tensor of type " + e + " being uploaded contains " + r + ".");
2890  }
2891}
2892
2893function W(t) {
2894  return "bool" === t || "complex64" === t || "float32" === t || "int32" === t || "string" === t;
2895}
2896
2897function U(t, e) {
2898  return "complex64" !== e && ("float32" !== e || "complex64" === t) && ("int32" !== e || "float32" === t || "complex64" === t) && ("bool" !== e || "bool" !== t);
2899}
2900
2901function V(t) {
2902  return t instanceof Float32Array || t instanceof Int32Array || t instanceof Uint8Array;
2903}
2904
2905function z(t) {
2906  if ("float32" === t || "int32" === t) return 4;
2907  if ("complex64" === t) return 8;
2908  if ("bool" === t) return 1;
2909  throw new Error("Unknown dtype " + t);
2910}
2911
2912function G(t) {
2913  if (null == t) return 0;
2914  var e = 0;
2915  return t.forEach(function (t) {
2916    return e += t.length;
2917  }), e;
2918}
2919
2920function H(t) {
2921  return "string" == typeof t || t instanceof String;
2922}
2923
2924function q(t) {
2925  return "boolean" == typeof t;
2926}
2927
2928function K(t) {
2929  return "number" == typeof t;
2930}
2931
2932function j(t) {
2933  return Array.isArray(t) ? j(t[0]) : t instanceof Float32Array ? "float32" : t instanceof Int32Array || t instanceof Uint8Array ? "int32" : K(t) ? "float32" : H(t) ? "string" : q(t) ? "bool" : "float32";
2934}
2935
2936function X(t) {
2937  return !!(t && t.constructor && t.call && t.apply);
2938}
2939
2940function Y(t, e) {
2941  for (var n = e; n < t; ++n) if (t % n == 0) return n;
2942
2943  return t;
2944}
2945
2946function $(t) {
2947  var e = t.length;
2948  if (e < 2) return [];
2949  var n = new Array(e - 1);
2950  n[e - 2] = t[e - 1];
2951
2952  for (var r = e - 3; r >= 0; --r) n[r] = n[r + 1] * t[r + 1];
2953
2954  return n;
2955}
2956
2957function Q(t, e, n) {
2958  if ("string" === e) throw new Error("Cannot convert a string[] to a TypedArray");
2959  if (Array.isArray(t) && (t = I(t)), n && L(t, e), function (t, e) {
2960    return t instanceof Float32Array && "float32" === e || t instanceof Int32Array && "int32" === e || t instanceof Uint8Array && "bool" === e;
2961  }(t, e)) return t;
2962  if (null == e || "float32" === e || "complex64" === e) return new Float32Array(t);
2963  if ("int32" === e) return new Int32Array(t);
2964
2965  if ("bool" === e) {
2966    for (var r = new Uint8Array(t.length), o = 0; o < r.length; ++o) 0 !== Math.round(t[o]) && (r[o] = 1);
2967
2968    return r;
2969  }
2970
2971  throw new Error("Unknown data type " + e);
2972}
2973
2974function J(t, e) {
2975  if (0 === t.length) return e[0];
2976  var n = t.reduce(function (t, e) {
2977    return t * e;
2978  });
2979  if (0 === n) return [];
2980  if (n !== e.length) throw new Error("[" + t + "] does not match the input size.");
2981  return function t(e, n, r) {
2982    var o = new Array();
2983    if (1 === n.length) for (var a = n[0], i = 0; i < a; i++) o[i] = r[e + i];else {
2984      a = n[0];
2985      var s = n.slice(1),
2986          u = s.reduce(function (t, e) {
2987        return t * e;
2988      });
2989
2990      for (i = 0; i < a; i++) o[i] = t(e + i * u, s, r);
2991    }
2992    return o;
2993  }(0, t, e);
2994}
2995
2996function Z(t, e) {
2997  for (var n = tt(t, e), r = 0; r < n.length; r++) n[r] = 1;
2998
2999  return n;
3000}
3001
3002function tt(t, e) {
3003  if (null == e || "float32" === e || "complex64" === e) return new Float32Array(t);
3004  if ("int32" === e) return new Int32Array(t);
3005  if ("bool" === e) return new Uint8Array(t);
3006  throw new Error("Unknown data type " + e);
3007}
3008
3009function et() {
3010  return i().platform.now();
3011}
3012
3013function nt(t) {
3014  t.forEach(function (e) {
3015    C(Number.isInteger(e) && e >= 0, function () {
3016      return "Tensor must have a shape comprised of positive integers but got shape [" + t + "].";
3017    });
3018  });
3019}
3020
3021function rt(t, e) {
3022  return void 0 === e && (e = "utf-8"), e = e || "utf-8", i().platform.encode(t, e);
3023}
3024
3025function ot(t, e) {
3026  return void 0 === e && (e = "utf-8"), e = e || "utf-8", i().platform.decode(t, e);
3027}
3028
3029function at(t, e, n) {
3030  if (0 === e) return 0;
3031  if (1 === e) return t[0];
3032
3033  for (var r = t[t.length - 1], o = 0; o < t.length - 1; ++o) r += n[o] * t[o];
3034
3035  return r;
3036}
3037
3038function it(t, e, n) {
3039  if (0 === e) return [];
3040  if (1 === e) return [t];
3041
3042  for (var r = new Array(e), o = 0; o < r.length - 1;
3042 ++o) r[o] = Math.floor(t / n[o]), t -= r[o] * n[o];
3043
3044  return r[r.length - 1] = t, r;
3045}
3046
3047var st = Object.freeze({
3048  shuffle: y,
3049  clamp: x,
3050  nearestLargerEven: b,
3051  sum: w,
3052  randUniform: function (t, e) {
3053    var n = Math.random();
3054    return e * n + (1 - n) * t;
3055  },
3056  distSquared: function (t, e) {
3057    for (var n = 0, r = 0; r < t.length; r++) {
3058      var o = Number(t[r]) - Number(e[r]);
3059      n += o * o;
3060    }
3061
3062    return n;
3063  },
3064  assert: C,
3065  assertShapesMatch: E,
3066  assertNonNull: R,
3067  flatten: I,
3068  sizeFromShape: k,
3069  isScalarShape: function (t) {
3070    return 0 === t.length;
3071  },
3072  arraysEqual: S,
3073  isInt: A,
3074  tanh: T,
3075  sizeToSquarishShape: D,
3076  createShuffledIndices: function (t) {
3077    for (var e = new Uint32Array(t), n = 0; n < t; ++n) e[n] = n;
3078
3079    return y(e), e;
3080  },
3081  rightPad: N,
3082  repeatedTry: F,
3083  inferFromImplicitShape: _,
3084  parseAxisParam: O,
3085  squeezeShape: M,
3086  getTypedArrayFromDType: B,
3087  getArrayFromDType: P,
3088  checkConversionForErrors: L,
3089  isValidDtype: W,
3090  hasEncodingLoss: U,
3091  isTypedArray: V,
3092  bytesPerElement: z,
3093  bytesFromStringArray: G,
3094  isString: H,
3095  isBoolean: q,
3096  isNumber: K,
3097  inferDtype: j,
3098  isFunction: X,
3099  nearestDivisor: Y,
3100  computeStrides: $,
3101  toTypedArray: Q,
3102  toNestedArray: J,
3103  makeOnesTypedArray: Z,
3104  makeZerosTypedArray: tt,
3105  now: et,
3106  assertNonNegativeIntegerDimensions: nt,
3107  fetch: function (t, e) {
3108    return i().platform.fetch(t, e);
3109  },
3110  encodeString: rt,
3111  decodeString: ot,
3112  locToIndex: at,
3113  indexToLoc: it
3114}),
3115    ut = function () {
3116  function t(t, e) {
3117    this.backendTimer = t, this.logger = e, null == e && (this.logger = new ct());
3118  }
3119
3120  return t.prototype.profileKernel = function (t, e, n) {
3121    var r,
3122        o = this,
3123        a = this.backendTimer.time(function () {
3124      r = n();
3125    });
3126    return r.forEach(function (n) {
3127      n.data().then(function (r) {
3128        !function (t, e, n) {
3129          if ("float32" !== e) return !1;
3130
3131          for (var r = 0; r < t.length; r++) {
3132            var o = t[r];
3133            if (isNaN(o) || !isFinite(o)) return console.warn("Found " + o + " in the result of '" + n + "'"), !0;
3134          }
3135        }(r, n.dtype, t), a.then(function (a) {
3136          var i = "";
3137          null != a.getExtraProfileInfo && (i = a.getExtraProfileInfo()), o.logger.logKernelProfile(t, n, r, a.kernelMs, e, i);
3138        });
3139      });
3140    }), r;
3141  }, t;
3142}();
3143
3144exports.util = st;
3145
3146var ct = function () {
3147  function t() {}
3148
3149  return t.prototype.logKernelProfile = function (t, e, n, r, o, a) {
3150    var i = "number" == typeof r ? N(r + "ms", 9) : r.error,
3151        s = N(t, 25),
3152        u = e.rank,
3153        c = e.size,
3154        l = N(e.shape.toString(), 14),
3155        h = "";
3156
3157    for (var f in o) {
3158      var d = o[f].shape || e.shape,
3159          p = d.length;
3160      h += f + ": " + p + "D " + (p > 0 ? d : "") + " ";
3161    }
3162
3163    console.log("%c" + s + "\t%c" + i + "\t%c" + u + "D " + l + "\t%c" + c + "\t%c" + h + "\t%c" + a, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue");
3164  }, t;
3165}();
3166
3167var lt = 20,
3168    ht = 3,
3169    ft = 7;
3170
3171function dt(t, e, n, r) {
3172  var o = $(e),
3173      a = function (t, e, n, r) {
3174    var o = k(e),
3175        a = r[r.length - 1],
3176        i = new Array(a).fill(0),
3177        s = e.length,
3178        u = "complex64" === n ? mt(t) : t;
3179    if (s > 1) for (var c = 0; c < o / a; c++) for (var l = c * a, h = 0; h < a; h++) i[h] = Math.max(i[h], pt(u[l + h], 0, n).length);
3180    return i;
3181  }(t, e, n, o),
3182      i = e.length,
3183      s = function t(e, n, r, o, a, i) {
3184    void 0 === i && (i = !0);
3185    var s = "complex64" === r ? 2 : 1,
3186        u = n[0],
3187        c = n.length;
3188
3189    if (0 === c) {
3190      return "complex64" === r ? [pt(mt(e)[0], 0, r)] : "bool" === r ? [vt(e[0])] : [e[0].toString()];
3191    }
3192
3193    if (1 === c) {
3194      if (u > lt) {
3195        var l = ht * s,
3196            h = Array.from(e.slice(0, l)),
3197            f = Array.from(e.slice((u - ht) * s, u * s));
3198        return "complex64" === r && (h = mt(h), f = mt(f)), ["[" + h.map(function (t, e) {
3199          return pt(t, a[e], r);
3200        }).join(", ") + ", ..., " + f.map(function (t, e) {
3201          return pt(t, a[u - ht + e], r);
3202        }).join(", ") + "]"];
3203      }
3204
3205      return ["[" + ("complex64" === r ? mt(e) : Array.from(e)).map(function (t, e) {
3206        return pt(t, a[e], r);
3207      }).join(", ") + "]"];
3208    }
3209
3210    var d = n.slice(1),
3211        p = o.slice(1),
3212        v = o[0] * s,
3213        m = [];
3214
3215    if (u > lt) {
3216      for (var g = 0; g < ht; g++) {
3217        var y = (x = g * v) + v;
3218        m.push.apply(m, t(e.slice(x, y), d, r, p, a, !1));
3219      }
3220
3221      m.push("...");
3222
3223      for (g = u - ht; g < u; g++) {
3224        y = (x = g * v) + v;
3225        m.push.apply(m, t(e.slice(x, y), d, r, p, a, g === u - 1));
3226      }
3227    } else for (g = 0; g < u; g++) {
3228      var x;
3229      y = (x = g * v) + v;
3230      m.push.apply(m, t(e.slice(x, y), d, r, p, a, g === u - 1));
3231    }
3232
3233    var b = 2 === c ? "," : "";
3234    m[0] = "[" + m[0] + b;
3235
3236    for (g = 1; g < m.length - 1; g++) m[g] = " " + m[g] + b;
3237
3238    var w = ",\n";
3239
3240    for (g = 2; g < c; g++) w += "\n";
3241
3242    return m[m.length - 1] = " " + m[m.length - 1] + "]" + (i ? "" : w), m;
3243  }(t, e, n, o, a),
3244      u = ["Tensor"];
3245
3246  return r && (u.push("  dtype: " + n), u.push("  rank: " + i), u.push("  shape: [" + e + "]"), u.push("  values:")), u.push(s.map(function (t) {
3247    return "    " + t;
3248  }).join("\n")), u.join("\n");
3249}
3250
3251function pt(t, e, n) {
3252  return N(Array.isArray(t) ? parseFloat(t[0].toFixed(ft)) + " + " + parseFloat(t[1].toFixed(ft)) + "j" : H(t) ? "'" + t + "'" : "bool" === n ? vt(t) : parseFloat(t.toFixed(ft)).toString(), e);
3253}
3254
3255function vt(t) {
3256  return 0 === t ? "false" : "true";
3257}
3258
3259function mt(t) {
3260  for (var e = [], n = 0; n < t.length;
3260 n += 2) e.push([t[n], t[n + 1]]);
3261
3262  return e;
3263}
3264
3265var gt = function () {
3266  function t(t, e, n) {
3267    var r = this;
3268
3269    if (this.dtype = e, this.shape = t.slice(), this.size = k(t), null != n) {
3270      var o = n.length;
3271      C(o === this.size, function () {
3272        return "Length of values '" + o + "' does not match the size inferred by the shape '" + r.size + "'.";
3273      });
3274    }
3275
3276    if ("complex64" === e) throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");
3277    this.values = n || P(e, this.size), this.strides = $(t);
3278  }
3279
3280  return t.prototype.set = function (t) {
3281    for (var e = this, n = [], r = 1; r < arguments.length; r++) n[r - 1] = arguments[r];
3282
3283    0 === n.length && (n = [0]), C(n.length === this.rank, function () {
3284      return "The number of provided coordinates (" + n.length + ") must match the rank (" + e.rank + ")";
3285    });
3286    var o = this.locToIndex(n);
3287    this.values[o] = t;
3288  }, t.prototype.get = function () {
3289    for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
3290
3291    0 === t.length && (t = [0]);
3292
3293    for (var n = 0, r = 0, o = t; r < o.length; r++) {
3294      var a = o[r];
3295
3296      if (a < 0 || a >= this.shape[n]) {
3297        var i = "Requested out of range element at " + t + ".   Buffer shape=" + this.shape;
3298        throw new Error(i);
3299      }
3300
3301      n++;
3302    }
3303
3304    for (var s = t[t.length - 1], u = 0; u < t.length - 1; ++u) s += this.strides[u] * t[u];
3305
3306    return this.values[s];
3307  }, t.prototype.locToIndex = function (t) {
3308    if (0 === this.rank) return 0;
3309    if (1 === this.rank) return t[0];
3310
3311    for (var e = t[t.length - 1], n = 0; n < t.length - 1; ++n) e += this.strides[n] * t[n];
3312
3313    return e;
3314  }, t.prototype.indexToLoc = function (t) {
3315    if (0 === this.rank) return [];
3316    if (1 === this.rank) return [t];
3317
3318    for (var e = new Array(this.shape.length), n = 0; n < e.length - 1; ++n) e[n] = Math.floor(t / this.strides[n]), t -= e[n] * this.strides[n];
3319
3320    return e[e.length - 1] = t, e;
3321  }, Object.defineProperty(t.prototype, "rank", {
3322    get: function () {
3323      return this.shape.length;
3324    },
3325    enumerable: !0,
3326    configurable: !0
3327  }), t.prototype.toTensor = function () {
3328    return yt().makeTensor(this.values, this.shape, this.dtype);
3329  }, t;
3330}(),
3331    yt = null,
3332    xt = null,
3333    bt = null;
3334
3335exports.TensorBuffer = gt;
3336
3337var wt = function () {
3338  function t(t, e, n, r) {
3339    this.kept = !1, this.isDisposedInternal = !1, this.shape = t.slice(), this.dtype = e || "float32", this.size = k(t), this.strides = $(t), this.dataId = n, this.id = r, this.rankType = this.rank < 5 ? this.rank.toString() : "higher";
3340  }
3341
3342  return t.prototype.flatten = function () {
3343    return this.throwIfDisposed(), this.as1D();
3344  }, t.prototype.asScalar = function () {
3345    return this.throwIfDisposed(), C(1 === this.size, function () {
3346      return "The array must have only 1 element.";
3347    }), this.reshape([]);
3348  }, t.prototype.as1D = function () {
3349    return this.throwIfDisposed(), this.reshape([this.size]);
3350  }, t.prototype.as2D = function (t, e) {
3351    return this.throwIfDisposed(), this.reshape([t, e]);
3352  }, t.prototype.as3D = function (t, e, n) {
3353    return this.throwIfDisposed(), this.reshape([t, e, n]);
3354  }, t.prototype.as4D = function (t, e, n, r) {
3355    return this.throwIfDisposed(), this.reshape([t, e, n, r]);
3356  }, t.prototype.as5D = function (t, e, n, r, o) {
3357    return this.throwIfDisposed(), this.reshape([t, e, n, r, o]);
3358  }, t.prototype.asType = function (t) {
3359    return this.throwIfDisposed(), xt.cast(this, t);
3360  }, Object.defineProperty(t.prototype, "rank", {
3361    get: function () {
3362      return this.shape.length;
3363    },
3364    enumerable: !0,
3365    configurable: !0
3366  }), t.prototype.buffer = function () {
3367    return n(this, void 0, void 0, function () {
3368      var t;
3369      return r(this, function (e) {
3370        switch (e.label) {
3371          case 0:
3372            return [4, this.data()];
3373
3374          case 1:
3375            return t = e.sent(), [2, xt.buffer(this.shape, this.dtype, t)];
3376        }
3377      });
3378    });
3379  }, t.prototype.bufferSync = function () {
3380    return xt.buffer(this.shape, this.dtype, this.dataSync());
3381  }, t.prototype.array = function () {
3382    return n(this, void 0, void 0, function () {
3383      var t;
3384      return r(this, function (e) {
3385        switch (e.label) {
3386          case 0:
3387            return [4, this.data()];
3388
3389          case 1:
3390            return t = e.sent(), [2, J(this.shape, t)];
3391        }
3392      });
3393    });
3394  }, t.prototype.arraySync = function () {
3395    return J(this.shape, this.dataSync());
3396  }, t.prototype.data = function () {
3397    return n(this, void 0, void 0, function () {
3398      var t, e;
3399      return r(this, function (n) {
3400        switch (n.label) {
3401          case 0:
3402            return this.throwIfDisposed(), t = yt().read(this.dataId), "string" !== this.dtype ? [3, 2] : [4, t];
3403
3404          case 1:
3405            e = n.sent();
3406
3407            try {
3408              return [2, e.map(function (t) {
3409                return ot(t);
3410              })];
3411            } catch (t) {
3412              throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");
3413            }
3414
3415            n.label = 2;
3416
3417          case 2:
3418            return [2, t];
3419        }
3420      });
3421    });
3422  }, t.prototype.dataSync = function () {
3423    this.throwIfDisposed();
3424    var t = yt().readSync(this.dataId);
3425    if ("string" === this.dtype) try {
3426      return t.map(function (t) {
3427        return ot(t);
3428      });
3429    } catch (t) {
3430      throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().");
3431    }
3432    return t;
3433  }, t.prototype.bytes = function () {
3434    return n(this, void 0, void 0, function () {
3435      var t;
3436      return r(this, function (e) {
3437        switch (e.label) {
3438          case 0:
3439            return this.throwIfDisposed(), [4, yt().read(this.dataId)];
3440
3441          case 1:
3442            return t = e.sent(), "string" === this.dtype ? [2, t] : [2, new Uint8Array(t.buffer)];
3443        }
3444      });
3445    });
3446  }, t.prototype.dispose = function () {
3447    this.isDisposed || (yt().disposeTensor(this), this.isDisposedInternal = !0);
3448  }, Object.defineProperty(t.prototype, "isDisposed", {
3449    get: function () {
3450      return this.isDisposedInternal;
3451    },
3452    enumerable: !0,
3453    configurable: !0
3454  }), t.prototype.throwIfDisposed = function () {
3455    if (this.isDisposed) throw new Error("Tensor is disposed.");
3456  }, t.prototype.toFloat = function () {
3457    return this.asType("float32");
3458  }, t.prototype.toInt = function () {
3459    return this.asType("int32");
3460  }, t.prototype.toBool = function () {
3461    return this.asType("bool");
3462  }, t.prototype.print = function (t) {
3463    return void 0 === t && (t = !1), xt.print(this, t);
3464  }, t.prototype.reshape = function (t) {
3465    return this.throwIfDisposed(), xt.reshape(this, t);
3466  }, t.prototype.reshapeAs = function (t) {
3467    return this.throwIfDisposed(), this.reshape(t.shape);
3468  }, t.prototype.expandDims = function (t) {
3469    return void 0 === t && (t = 0), xt.expandDims(this, t);
3470  }, t.prototype.cumsum = function (t, e, n) {
3471    return void 0 === t && (t = 0), void 0 === e && (e = !1), void 0 === n && (n = !1), xt.cumsum(this, t, e, n);
3472  }, t.prototype.squeeze = function (t) {
3473    return this.throwIfDisposed(), xt.squeeze(this, t);
3474  }, t.prototype.clone = function () {
3475    return this.throwIfDisposed(), xt.clone(this);
3476  }, t.prototype.toString = function (t) {
3477    return void 0 === t && (t = !1), dt(this.dataSync(), this.shape, this.dtype, t);
3478  }, t.prototype.gather = function (t, e) {
3479    return void 0 === e && (e = 0), this.throwIfDisposed(), xt.gather(this, t, e);
3480  }, t.prototype.matMul = function (t, e, n) {
3481    return void 0 === e && (e = !1), void 0 === n && (n = !1), this.throwIfDisposed(), xt.matMul(this, t, e, n);
3482  }, t.prototype.dot = function (t) {
3483    return this.throwIfDisposed(), xt.dot(this, t);
3484  }, t.prototype.norm = function (t, e, n) {
3485    return void 0 === t && (t = "euclidean"), void 0 === e && (e = null), void 0 === n && (n = !1), this.throwIfDisposed(), xt.norm(this, t, e, n);
3486  }, t.prototype.slice = function (t, e) {
3487    return this.throwIfDisposed(), xt.slice(this, t, e);
3488  }, t.prototype.reverse = function (t) {
3489    return this.throwIfDisposed(), xt.reverse(this, t);
3490  }, t.prototype.concat = function (e, n) {
3491    return void 0 === n && (n = 0), this.throwIfDisposed(), e instanceof t && (e = [e]), xt.concat([this].concat(e), n);
3492  }, t.prototype.split = function (t, e) {
3493    return void 0 === e && (e = 0), this.throwIfDisposed(), xt.split(this, t, e);
3494  }, t.prototype.stack = function (t, e) {
3495    return void 0 === e && (e = 0), xt.stack([this, t], e);
3496  }, t.prototype.unstack = function (t) {
3497    return void 0 === t && (t = 0), xt.unstack(this, t);
3498  }, t.prototype.pad = function (t, e) {
3499    return void 0 === e && (e = 0), xt.pad(this, t, e);
3500  }, t.prototype.batchNormalization = function (t, e, n, r, o) {
3501    return void 0 === n && (n = .001), bt("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon"), this.batchNorm(t, e, o, r, n);
3502  }, t.prototype.batchNorm = function (t, e, n, r, o) {
3503    return void 0 === o && (o = .001), this.throwIfDisposed(), xt.batchNorm(this, t, e, n, r, o);
3504  }, t.prototype.all = function (t, e) {
3505    return void 0 === t && (t = null), void 0 === e && (e = !1), this.throwIfDisposed(), xt.all(this, t, e);
3506  }, t.prototype.any = function (t, e) {
3507    return void 0 === t && (t = null), void 0 === e && (e = !1), this.throwIfDisposed(), xt.any(this, t, e);
3508  }, t.prototype.logSumExp = function (t, e) {
3509    return void 0 === t && (t = null), void 0 === e && (e = !1), this.throwIfDisposed(), xt.logSumExp(this, t, e);
3510  }, t.prototype.sum = function (t, e) {
3511    return void 0 === t && (t = null), void 0 === e && (e = !1), this.throwIfDisposed(), xt.sum(this, t, e);
3512  }, t.prototype.prod = function (t, e) {
3513    return void 0 === t && (t = null), void 0 === e && (e = !1), this.throwIfDisposed(), xt.prod(this, t, e);
3514  }, t.prototype.mean = function (t, e) {
3515    return void 0 === t && (t = null), void 0 === e && (e = !1), this.throwIfDisposed(), xt.mean(this, t, e);
3516  }, t.prototype.min = function (t, e) {
3517    return void 0 === t && (t = null), void 0 === e && (e = !1), this.throwIfDisposed(), xt.min(this, t, e);
3518  }, t.prototype.max = function (t, e) {
3519    return void 0 === t && (t = null), void 0 === e && (e = !1), this.throwIfDisposed(), xt.max(this, t, e);
3520  }, t.prototype.argMin = function (t) {
3521    return void 0 === t && (t = null), this.throwIfDisposed(), xt.argMin(this, t);
3522  }, t.prototype.argMax = function (t) {
3523    return void 0 === t && (t = null), this.throwIfDisposed(), xt.argMax(this, t);
3524  }, t.prototype.cast = function (t) {
3525    return this.throwIfDisposed(), xt.cast(this, t);
3526  }, t.prototype.add = function (t) {
3527    return this.throwIfDisposed(), xt.add(this, t);
3528  }, t.prototype.addStrict = function (t) {
3529    return this.throwIfDisposed(), xt.addStrict(this, t);
3530  }, t.prototype.atan2 = function (t) {
3531    return this.throwIfDisposed(), xt.atan2(this, t);
3532  }, t.prototype.sub = function (t) {
3533    return this.throwIfDisposed(), xt.sub(this, t);
3534  }, t.prototype.subStrict = function (t) {
3535    return this.throwIfDisposed(), xt.subStrict(this, t);
3536  }, t.prototype.pow = function (t) {
3537    return this.throwIfDisposed(), xt.pow(this, t);
3538  }, t.prototype.powStrict = function (t) {
3539    return this.throwIfDisposed(), xt.powStrict(this, t);
3540  }, t.prototype.mul = function (t) {
3541    return this.throwIfDisposed(), xt.mul(this, t);
3542  }, t.prototype.mulStrict = function (t) {
3543    return this.throwIfDisposed(), xt.mulStrict(this, t);
3544  }, t.prototype.floorDiv = function (t) {
3545    return this.throwIfDisposed(), xt.floorDiv(this, t);
3546  }, t.prototype.divStrict = function (t) {
3547    return this.throwIfDisposed(), xt.divStrict(this, t);
3548  }, t.prototype.minimum = function (t) {
3549    return this.throwIfDisposed(), xt.minimum(this, t);
3550  }, t.prototype.minimumStrict = function (t) {
3551    return this.throwIfDisposed(), xt.minimumStrict(this, t);
3552  }, t.prototype.maximum = function (t) {
3553    return this.throwIfDisposed(), xt.maximum(this, t);
3554  }, t.prototype.maximumStrict = function (t) {
3555    return this.throwIfDisposed(), xt.maximumStrict(this, t);
3556  }, t.prototype.mod = function (t) {
3557    return this.throwIfDisposed(), xt.mod(this, t);
3558  }, t.prototype.modStrict = function (t) {
3559    return this.throwIfDisposed(), xt.modStrict(this, t);
3560  }, t.prototype.squaredDifferenceStrict = function (t) {
3561    return this.throwIfDisposed(), xt.squaredDifferenceStrict(this, t);
3562  }, t.prototype.transpose = function (t) {
3563    return this.throwIfDisposed(), xt.transpose(this, t);
3564  }, t.prototype.notEqual = function (t) {
3565    return this.throwIfDisposed(), xt.notEqual(this, t);
3566  }, t.prototype.notEqualStrict = function (t) {
3567    return this.throwIfDisposed(), xt.notEqualStrict(this, t);
3568  }, t.prototype.less = function (t) {
3569    return this.throwIfDisposed(), xt.less(this, t);
3570  }, t.prototype.lessStrict = function (t) {
3571    return this.throwIfDisposed(), xt.lessStrict(this, t);
3572  }, t.prototype.equal = function (t) {
3573    return this.throwIfDisposed(), xt.equal(this, t);
3574  }, t.prototype.equalStrict = function (t) {
3575    return this.throwIfDisposed(), xt.equalStrict(this, t);
3576  }, t.prototype.lessEqual = function (t) {
3577    return this.throwIfDisposed(), xt.lessEqual(this, t);
3578  }, t.prototype.lessEqualStrict = function (t) {
3579    return this.throwIfDisposed(), xt.lessEqualStrict(this, t);
3580  }, t.prototype.greater = function (t) {
3581    return this.throwIfDisposed(), xt.greater(this, t);
3582  }, t.prototype.greaterStrict = function (t) {
3583    return this.throwIfDisposed(), xt.greaterStrict(this, t);
3584  }, t.prototype.greaterEqual = function (t) {
3585    return this.throwIfDisposed(), xt.greaterEqual(this, t);
3586  }, t.prototype.greaterEqualStrict = function (t) {
3587    return this.throwIfDisposed(), xt.greaterEqualStrict(this, t);
3588  }, t.prototype.logicalAnd = function (t) {
3589    return this.throwIfDisposed(), xt.logicalAnd(this, t);
3590  }, t.prototype.logicalOr = function (t) {
3591    return this.throwIfDisposed(), xt.logicalOr(this, t);
3592  }, t.prototype.logicalNot = function () {
3593    return this.throwIfDisposed(), xt.logicalNot(this);
3594  }, t.prototype.logicalXor = function (t) {
3595    return this.throwIfDisposed(), xt.logicalXor(this, t);
3596  }, t.prototype.where = function (t, e) {
3597    return this.throwIfDisposed(), xt.where(t, this, e);
3598  }, t.prototype.neg = function () {
3599    return this.throwIfDisposed(), xt.neg(this);
3600  }, t.prototype.ceil = function () {
3601    return this.throwIfDisposed(), xt.ceil(this);
3602  }, t.prototype.floor = function () {
3603    return this.throwIfDisposed(), xt.floor(this);
3604  }, t.prototype.sign = function () {
3605    return this.throwIfDisposed(), xt.sign(this);
3606  }, t.prototype.isNaN = function () {
3607    return this.throwIfDisposed(), xt.isNaN(this);
3608  }, t.prototype.isInf = function () {
3609    return this.throwIfDisposed(), xt.isInf(this);
3610  }, t.prototype.isFinite = function () {
3611    return this.throwIfDisposed(), xt.isFinite(this);
3612  }, t.prototype.exp = function () {
3613    return this.throwIfDisposed(), xt.exp(this);
3614  }, t.prototype.expm1 = function () {
3615    return this.throwIfDisposed(), xt.expm1(this);
3616  }, t.prototype.log = function () {
3617    return this.throwIfDisposed(), xt.log(this);
3618  }, t.prototype.log1p = function () {
3619    return this.throwIfDisposed(), xt.log1p(this);
3620  }, t.prototype.sqrt = function () {
3621    return this.throwIfDisposed(), xt.sqrt(this);
3622  }, t.prototype.rsqrt = function () {
3623    return this.throwIfDisposed(), xt.rsqrt(this);
3624  }, t.prototype.square = function () {
3625    return this.throwIfDisposed(), xt.square(this);
3626  }, t.prototype.reciprocal = function () {
3627    return this.throwIfDisposed(), xt.reciprocal(this);
3628  }, t.prototype.abs = function () {
3629    return this.throwIfDisposed(), xt.abs(this);
3630  }, t.prototype.clipByValue = function (t, e) {
3631    return this.throwIfDisposed(), xt.clipByValue(this, t, e);
3632  }, t.prototype.relu = function () {
3633    return this.throwIfDisposed(), xt.relu(this);
3634  }, t.prototype.relu6 = function () {
3635    return this.throwIfDisposed(), xt.relu6(this);
3636  }, t.prototype.elu = function () {
3637    return this.throwIfDisposed(), xt.elu(this);
3638  }, t.prototype.selu = function () {
3639    return this.throwIfDisposed(), xt.selu(this);
3640  }, t.prototype.leakyRelu = function (t) {
3641    return void 0 === t && (t = .2), this.throwIfDisposed(), xt.leakyRelu(this, t);
3642  }, t.prototype.prelu = function (t) {
3643    return this.throwIfDisposed(), xt.prelu(this, t);
3644  }, t.prototype.sigmoid = function () {
3645    return this.throwIfDisposed(), xt.sigmoid(this);
3646  }, t.prototype.logSigmoid = function () {
3647    return this.throwIfDisposed(), xt.logSigmoid(this);
3648  }, t.prototype.softplus = function () {
3649    return this.throwIfDisposed(), xt.softplus(this);
3650  }, t.prototype.zerosLike = function () {
3651    return this.throwIfDisposed(), xt.zerosLike(this);
3652  }, t.prototype.onesLike = function () {
3653    return this.throwIfDisposed(), xt.onesLike(this);
3654  }, t.prototype.sin = function () {
3655    return this.throwIfDisposed(), xt.sin(this);
3656  }, t.prototype.cos = function () {
3657    return this.throwIfDisposed(), xt.cos(this);
3658  }, t.prototype.tan = function () {
3659    return this.throwIfDisposed(), xt.tan(this);
3660  }, t.prototype.asin = function () {
3661    return this.throwIfDisposed(), xt.asin(this);
3662  }, t.prototype.acos = function () {
3663    return this.throwIfDisposed(), xt.acos(this);
3664  }, t.prototype.atan = function () {
3665    return this.throwIfDisposed(), xt.atan(this);
3666  }, t.prototype.sinh = function () {
3667    return this.throwIfDisposed(), xt.sinh(this);
3668  }, t.prototype.cosh = function () {
3669    return this.throwIfDisposed(), xt.cosh(this);
3670  }, t.prototype.tanh = function () {
3671    return this.throwIfDisposed(), xt.tanh(this);
3672  }, t.prototype.asinh = function () {
3673    return this.throwIfDisposed(), xt.asinh(this);
3674  }, t.prototype.acosh = function () {
3675    return this.throwIfDisposed(), xt.acosh(this);
3676  }, t.prototype.atanh = function () {
3677    return this.throwIfDisposed(), xt.atanh(this);
3678  }, t.prototype.erf = function () {
3679    return this.throwIfDisposed(), xt.erf(this);
3680  }, t.prototype.round = function () {
3681    return this.throwIfDisposed(), xt.round(this);
3682  }, t.prototype.step = function (t) {
3683    return void 0 === t && (t = 0), this.throwIfDisposed(), xt.step(this, t);
3684  }, t.prototype.softmax = function (t) {
3685    return void 0 === t && (t = -1), this.throwIfDisposed(), xt.softmax(this, t);
3686  }, t.prototype.logSoftmax = function (t) {
3687    return void 0 === t && (t = -1), this.throwIfDisposed(), xt.logSoftmax(this, t);
3688  }, t.prototype.resizeBilinear = function (t, e) {
3689    return void 0 === e && (e = !1), this.throwIfDisposed(), xt.image.resizeBilinear(this, t, e);
3690  }, t.prototype.resizeNearestNeighbor = function (t, e) {
3691    return void 0 === e && (e = !1), this.throwIfDisposed(), xt.image.resizeNearestNeighbor(this, t, e);
3692  }, t.prototype.conv1d = function (t, e, n, r, o, a) {
3693    return void 0 === r && (r = "NWC"), void 0 === o && (o = 1), this.throwIfDisposed(), xt.conv1d(this, t, e, n, r, o, a);
3694  }
3694, t.prototype.conv2d = function (t, e, n, r, o, a) {
3695    return void 0 === r && (r = "NHWC"), void 0 === o && (o = [1, 1]), this.throwIfDisposed(), xt.conv2d(this, t, e, n, r, o, a);
3696  }, t.prototype.conv2dTranspose = function (t, e, n, r, o) {
3697    return this.throwIfDisposed(), xt.conv2dTranspose(this, t, e, n, r, o);
3698  }, t.prototype.depthwiseConv2D = function (t, e, n, r, o, a) {
3699    return void 0 === r && (r = "NHWC"), void 0 === o && (o = [1, 1]), this.throwIfDisposed(), xt.depthwiseConv2d(this, t, e, n, r, o, a);
3700  }, t.prototype.separableConv2d = function (t, e, n, r, o, a) {
3701    return void 0 === o && (o = [1, 1]), void 0 === a && (a = "NHWC"), this.throwIfDisposed(), xt.separableConv2d(this, t, e, n, r, o, a);
3702  }, t.prototype.avgPool = function (t, e, n, r) {
3703    return this.throwIfDisposed(), xt.avgPool(this, t, e, n, r);
3704  }, t.prototype.maxPool = function (t, e, n, r) {
3705    return this.throwIfDisposed(), xt.maxPool(this, t, e, n, r);
3706  }, t.prototype.localResponseNormalization = function (t, e, n, r) {
3707    return void 0 === t && (t = 5), void 0 === e && (e = 1), void 0 === n && (n = 1), void 0 === r && (r = .5), xt.localResponseNormalization(this, t, e, n, r);
3708  }, t.prototype.pool = function (t, e, n, r, o) {
3709    return this.throwIfDisposed(), xt.pool(this, t, e, n, r, o);
3710  }, t.prototype.variable = function (t, e, n) {
3711    return void 0 === t && (t = !0), this.throwIfDisposed(), yt().makeVariable(this, t, e, n);
3712  }, t.prototype.unsortedSegmentSum = function (t, e) {
3713    return this.throwIfDisposed(), xt.unsortedSegmentSum(this, t, e);
3714  }, t.prototype.batchToSpaceND = function (t, e) {
3715    return this.throwIfDisposed(), xt.batchToSpaceND(this, t, e);
3716  }, t.prototype.spaceToBatchND = function (t, e) {
3717    return this.throwIfDisposed(), xt.spaceToBatchND(this, t, e);
3718  }, t.prototype.topk = function (t, e) {
3719    return void 0 === t && (t = 1), void 0 === e && (e = !0), this.throwIfDisposed(), xt.topk(this, t, e);
3720  }, t.prototype.stridedSlice = function (t, e, n, r, o, a, i, s) {
3721    return void 0 === r && (r = 0), void 0 === o && (o = 0), void 0 === a && (a = 0), void 0 === i && (i = 0), void 0 === s && (s = 0), this.throwIfDisposed(), xt.stridedSlice(this, t, e, n, r, o, a, i, s);
3722  }, t.prototype.depthToSpace = function (t, e) {
3723    return this.throwIfDisposed(), xt.depthToSpace(this, t, e);
3724  }, t.prototype.fft = function () {
3725    return this.throwIfDisposed(), xt.spectral.fft(this);
3726  }, t.prototype.ifft = function () {
3727    return this.throwIfDisposed(), xt.spectral.ifft(this);
3728  }, t.prototype.rfft = function () {
3729    return this.throwIfDisposed(), xt.spectral.rfft(this);
3730  }, t.prototype.irfft = function () {
3731    return this.throwIfDisposed(), xt.spectral.irfft(this);
3732  }, t;
3733}();
3734
3735exports.Tensor = wt;
3736Object.defineProperty(wt, Symbol.hasInstance, {
3737  value: function (t) {
3738    return !!t && null != t.dataId && null != t.shape && null != t.dtype;
3739  }
3740});
3741
3742var Ct,
3743    Et,
3744    Rt,
3745    It,
3746    kt,
3747    St = function (t) {
3748  function n(e, n, r, o) {
3749    var a = t.call(this, e.shape, e.dtype, e.dataId, o) || this;
3750    return a.trainable = n, a.name = r, a;
3751  }
3752
3753  return e(n, t), n.prototype.assign = function (t) {
3754    if (t.dtype !== this.dtype) throw new Error("dtype of the new value (" + t.dtype + ") and previous value (" + this.dtype + ") must match");
3755    if (!S(t.shape, this.shape)) throw new Error("shape of the new value (" + t.shape + ") and previous value (" + this.shape + ") must match");
3756    yt().disposeTensor(this), this.dataId = t.dataId, yt().incRef(this, null);
3757  }, n.prototype.dispose = function () {
3758    yt().disposeVariable(this), this.isDisposedInternal = !0;
3759  }, n;
3760}(wt);
3761
3762exports.Variable = St;
3763exports.Rank = Ct;
3764Object.defineProperty(St, Symbol.hasInstance, {
3765  value: function (t) {
3766    return t instanceof wt && null != t.assign && t.assign instanceof Function;
3767  }
3768}), function (t) {
3769  t.R0 = "R0", t.R1 = "R1", t.R2 = "R2", t.R3 = "R3", t.R4 = "R4", t.R5 = "R5", t.R6 = "R6";
3770}(Ct || (exports.Rank = Ct = {})), function (t) {
3771  t.float32 = "float32", t.int32 = "int32", t.bool = "int32", t.complex64 = "complex64";
3772}(Et || (Et = {})), function (t) {
3773  t.float32 = "float32", t.int32 = "int32", t.bool = "bool", t.complex64 = "complex64";
3774}(Rt || (Rt = {})), function (t) {
3775  t.float32 = "float32", t.int32 = "float32", t.bool = "float32", t.complex64 = "complex64";
3776}(It || (It = {})), function (t) {
3777  t.float32 = "complex64", t.int32 = "complex64", t.bool = "complex64", t.complex64 = "complex64";
3778}(kt || (kt = {}));
3779var At = {
3780  float32: It,
3781  int32: Et,
3782  bool: Rt,
3783  complex64: kt
3784};
3785
3786function Tt(t, e) {
3787  if ("string" === t || "string" === e) {
3788    if ("string" === t && "string" === e) return "string";
3789    throw new Error("Can not upcast " + t + " with " + e);
3790  }
3791
3792  return At[t][e];
3793}
3794
3795function Dt(t) {
3796  return Tt(t, "int32");
3797}
3798
3799function Nt(t, e) {
3800  if (t.dtype === e.dtype) return [t, e];
3801  var n = Tt(t.dtype, e.dtype);
3802  return [t.cast(n), e.cast(n)];
3803}
3804
3805function Ft(t, e) {
3806  C(t.dtype === e.dtype, function () {
3807    return "The dtypes of the first(" + t.dtype + ") and second(" + e.dtype + ") input must match";
3808  });
3809}
3810
3811function _t(t) {
3812  var e = [];
3813  return function t(e, n, r) {
3814    if (null == e) return;
3815    if (e instanceof wt) return void n.push(e);
3816    if (o = e, !Array.isArray(o) && "object" != typeof o) return;
3817    var o;
3818    var a = e;
3819
3820    for (var i in a) {
3821      var s = a[i];
3822      r.has(s) || (r.add(s), t(s, n, r));
3823    }
3824  }(t, e, new Set()), e;
3825}
3826
3827var Ot,
3828    Mt = Object.freeze({
3829  makeTypesMatch: Nt,
3830  assertTypesMatch: Ft,
3831  isTensorInList: function (t, e) {
3832    return e.some(function (e) {
3833      return e.id === t.id;
3834    });
3835  },
3836  getTensorsInContainer: _t
3837}),
3838    Bt = function () {
3839  function t() {
3840    this.registeredVariables = {}, this.nextTapeNodeId = 0, this.numBytes = 0, this.numTensors = 0, this.numStringTensors = 0, this.numDataBuffers = 0, this.gradientDepth = 0, this.kernelDepth = 0, this.scopeStack = [], this.numDataMovesStack = [], this.nextScopeId = 0, this.tensorInfo = new WeakMap(), this.profiling = !1, this.activeProfile = {
3841      newBytes: 0,
3842      newTensors: 0,
3843      peakBytes: 0,
3844      kernels: [],
3845      result: null
3846    };
3847  }
3848
3849  return t.prototype.dispose = function () {
3850    for (var t in this.registeredVariables) this.registeredVariables[t].dispose();
3851  }, t;
3852}(),
3853    Pt = function () {
3854  function t(t) {
3855    this.ENV = t, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new Bt();
3856  }
3857
3858  return t.prototype.ready = function () {
3859    return n(this, void 0, void 0, function () {
3860      var t, e, n;
3861      return r(this, function (r) {
3862        switch (r.label) {
3863          case 0:
3864            if (null != this.pendingBackendInit) return [2, this.pendingBackendInit.then(function () {})];
3865            if (null != this.backendInstance) return [2];
3866            t = this.getSortedBackends(), e = 0, r.label = 1;
3867
3868          case 1:
3869            return e < t.length ? (n = t[e], [4, this.initializeBackend(n).success]) : [3, 5];
3870
3871          case 2:
3872            return r.sent() ? [4, this.setBackend(n)] : [3, 4];
3873
3874          case 3:
3875            return r.sent(), [2];
3876
3877          case 4:
3878            return e++, [3, 1];
3879
3880          case 5:
3881            throw new Error("Could not initialize any backends, all backend initializations failed.");
3882        }
3883      });
3884    });
3885  }, Object.defineProperty(t.prototype, "backend", {
3886    get: function () {
3887      if (null != this.pendingBackendInit) throw new Error("Backend '" + this.backendName + "' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");
3888
3889      if (null == this.backendInstance) {
3890        var t = this.initializeBackendsAndReturnBest(),
3891            e = t.name;
3892        if (t.asyncInit) throw new Error("The highest priority backend '" + e + "' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods");
3893        this.setBackend(e);
3894      }
3895
3896      return this.backendInstance;
3897    },
3898    enumerable: !0,
3899    configurable: !0
3900  }), t.prototype.backendNames = function () {
3901    return Object.keys(this.registryFactory);
3902  }, t.prototype.findBackend = function (t) {
3903    if (!(t in this.registry)) {
3904      if (!(t in this.registryFactory)) return null;
3905      if (this.initializeBackend(t).asyncInit) return null;
3906    }
3907
3908    return this.registry[t];
3909  }, t.prototype.findBackendFactory = function (t) {
3910    return t in this.registryFactory ? this.registryFactory[t].factory : null;
3911  }, t.prototype.registerBackend = function (t, e, n) {
3912    return void 0 === n && (n = 1), t in this.registryFactory ? (console.warn(t + " backend was already registered. Reusing existing backend factory."), !1) : (this.registryFactory[t] = {
3913      factory: e,
3914      priority: n
3915    }, !0);
3916  }, t.prototype.setBackend = function (t) {
3917    return n(this, void 0, void 0, function () {
3918      var e, n, o;
3919      return r(this, function (r) {
3920        switch (r.label) {
3921          case 0:
3922            if (null == this.registryFactory[t]) throw new Error("Backend name '" + t + "' not found in registry");
3923            return this.backendName = t, null != this.registry[t] ? [3, 4] : (this.backendInstance = null, e = this.initializeBackend(t), n = e.success, e.asyncInit ? [4, n] : [3, 2]);
3924
3925          case 1:
3926            return o = r.sent(), [3, 3];
3927
3928          case 2:
3929            o = n, r.label = 3;
3930
3931          case 3:
3932            if (!o) return [2, !1];
3933            r.label = 4;
3934
3935          case 4:
3936            return this.backendInstance = this.registry[t], this.setupRegisteredKernels(), this.profiler = new ut(this.backendInstance), [2, !0];
3937        }
3938      });
3939    });
3940  }, t.prototype.setupRegisteredKernels = function () {
3941    var t = this;
3942    f(this.backendName).forEach(function (e) {
3943      null != e.setupFunc && e.setupFunc(t.backendInstance);
3944    });
3945  }, t.prototype.disposeRegisteredKernels = function (t) {
3946    var e = this;
3947    f(t).forEach(function (n) {
3948      null != n.disposeFunc && n.disposeFunc(e.registry[t]);
3949    });
3950  }, t.prototype.initializeBackend = function (t) {
3951    var e = this,
3952        n = this.registryFactory[t];
3953    if (null == n) throw new Error("Cannot initialize backend " + t + ", no registration found.");
3954
3955    try {
3956      var r = n.factory();
3957
3958      if (Promise.resolve(r) === r) {
3959        var o = ++this.pendingBackendInitId,
3960            a = r.then(function (n) {
3961          return !(o < e.pendingBackendInitId) && (e.registry[t] = n, e.pendingBackendInit = null, !0);
3962        }).catch(function (n) {
3963          return !(o < e.pendingBackendInitId) && (e.pendingBackendInit = null, console.warn("Initialization of backend " + t + " failed"), console.warn(n.stack || n.message), !1);
3964        });
3965        return this.pendingBackendInit = a, {
3966          success: a,
3967          asyncInit: !0
3968        };
3969      }
3970
3971      return this.registry[t] = r, {
3972        success: !0,
3973        asyncInit: !1
3974      };
3975    } catch (e) {
3976      return console.warn("Initialization of backend " + t + " failed"), console.warn(e.stack || e.message), {
3977        success: !1,
3978        asyncInit: !1
3979      };
3980    }
3981  }, t.prototype.removeBackend = function (t) {
3982    if (!(t in this.registryFactory)) throw new Error(t + " backend not found in registry");
3983    this.backendName === t && null != this.pendingBackendInit && this.pendingBackendInitId++, t in this.registry && (this.disposeRegisteredKernels(t), this.registry[t].dispose(), delete this.registry[t]), delete this.registryFactory[t], this.backendName === t && (this.pendingBackendInit = null, this.backendName = null, this.backendInstance = null);
3984  }, t.prototype.getSortedBackends = function () {
3985    var t = this;
3986    if (0 === Object.keys(this.registryFactory).length) throw new Error("No backend found in registry.");
3987    return Object.keys(this.registryFactory).sort(function (e, n) {
3988      return t.registryFactory[n].priority - t.registryFactory[e].priority;
3989    });
3990  }, t.prototype.initializeBackendsAndReturnBest = function () {
3991    for (var t = this.getSortedBackends(), e = 0; e < t.length; e++) {
3992      var n = t[e],
3993          r = this.initializeBackend(n),
3994          o = r.success,
3995          a = r.asyncInit;
3996      if (a || o) return {
3997        name: n,
3998        asyncInit: a
3999      };
4000    }
4001
4002    throw new Error("Could not initialize any backends, all backend initializations failed.");
4003  }, t.prototype.moveData = function (t, e) {
4004    var n = this.state.tensorInfo.get(e),
4005        r = n.backend,
4006        o = this.readSync(e);
4007    r.disposeData(e), n.backend = t, t.move(e, o, n.shape, n.dtype), this.shouldCheckForMemLeaks() && this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++;
4008  }, t.prototype.tidy = function (t, e) {
4009    var n,
4010        r = this,
4011        o = null;
4012
4013    if (null == e) {
4014      if ("function" != typeof t) throw new Error("Please provide a function to tidy()");
4015      e = t;
4016    } else {
4017      if ("string" != typeof t && !(t instanceof String)) throw new Error("When calling with two arguments, the first argument to tidy() must be a string");
4018      if ("function" != typeof e) throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");
4019      o = t;
4020    }
4021
4022    return this.scopedRun(function () {
4023      return r.startScope(o);
4024    }, function () {
4025      return r.endScope(n);
4026    }, function () {
4027      return (n = e()) instanceof Promise && console.error("Cannot return a Promise inside of tidy."), n;
4028    });
4029  }, t.prototype.scopedRun = function (t, e, n) {
4030    t();
4031
4032    try {
4033      var r = n();
4034      return e(), r;
4035    } catch (t) {
4036      throw e(), t;
4037    }
4038  }, t.prototype.nextTensorId = function () {
4039    return t.nextTensorId++;
4040  }, t.prototype.nextVariableId = function () {
4041    return t.nextVariableId++;
4042  }, t.prototype.clone = function (t) {
4043    var e = this.makeTensorFromDataId(t.dataId, t.shape, t.dtype),
4044        n = {
4045      x: t
4046    };
4047    return this.addTapeNode(this.state.activeScope.name, n, [e], function (t) {
4048      return {
4049        x: function () {
4050          return t.toFloat();
4051        }
4052      };
4053    }, [], {}), e;
4054  }, t.prototype.runKernel = function (t, e, n, r, o) {
4055    return this.runKernelFunc(null, e, null, t, n, r, o);
4056  }, t.prototype.shouldCheckForMemLeaks = function () {
4057    return this.ENV.getBool("IS_TEST");
4058  }, t.prototype.checkKernelForMemLeak = function (t, e, n) {
4059    var r = this.backend.numDataIds(),
4060        o = 0;
4061    n.forEach(function (t) {
4062      o += "complex64" === t.dtype ? 3 : 1;
4063    });
4064    var a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1],
4065        i = r - e - o - a;
4066    if (i > 0) throw new Error("Backend '" + this.backendName + "' has an internal memory leak (" + i + " data ids) after running '" + t + "'");
4067  }, t.prototype.runKernelFunc = function (t, e, n, r, o, a, i) {
4068    var s,
4069        u = this,
4070        c = [],
4071        h = this.isTapeOn();
4072    null == r && (r = null != this.state.activeScope ? this.state.activeScope.name : "");
4073    var f,
4074        d = this.state.numBytes,
4075        p = this.state.numTensors;
4076    this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0);
4077    var v,
4078        m = l(r, this.backendName);
4079    if (null != m) f = function () {
4080      var t = u.backend.numDataIds();
4081      v = m.kernelFunc({
4082        inputs: e,
4083        attrs: o,
4084        backend: u.backend
4085      });
4086      var n = Array.isArray(v) ? v : [v];
4087      u.shouldCheckForMemLeaks() && u.checkKernelForMemLeak(r, t, n);
4088      var s = n.map(function (t) {
4089        var e = t.dataId,
4090            n = t.shape,
4091            r = t.dtype;
4092        return u.makeTensorFromDataId(e, n, r);
4093      });
4094
4095      if (h) {
4096        var l = u.getTensorsForGradient(r, e, s);
4097
4098        if (null == l) {
4099          null == i && (i = []);
4100          var f = s.filter(function (t, e) {
4101            return i[e];
4102          });
4103          l = (a || []).slice().concat(f);
4104        }
4105
4106        c = u.saveTensorsForBackwardMode(l);
4107      }
4108
4109      return s;
4110    };else {
4111      var g = function (t) {
4112        h && (c = t.map(function (t) {
4113          return u.keep(u.clone(t));
4114        }));
4115      };
4116
4117      f = function () {
4118        var e = u.backend.numDataIds();
4119        v = u.tidy(function () {
4120          return t(u.backend, g);
4121        });
4122        var n = Array.isArray(v) ? v : [v];
4123        return u.shouldCheckForMemLeaks() && u.checkKernelForMemLeak(r, e, n), n;
4124      };
4125    }
4126    return this.scopedRun(function () {
4127      return u.state.kernelDepth++;
4128    }, function () {
4129      return u.state.kernelDepth--;
4130    }, function () {
4131      s = u.ENV.getBool("DEBUG") ? u.profiler.profileKernel(r, e, function () {
4132        return f();
4133      }) : f();
4134    }), h && this.addTapeNode(r, e, s, n, c, o), this.state.profiling && this.state.activeProfile.kernels.push({
4135      name: r,
4136      bytesAdded: this.state.numBytes - d,
4137      totalBytesSnapshot: this.state.numBytes,
4138      tensorsAdded: this.state.numTensors - p,
4139      totalTensorsSnapshot: this.state.numTensors,
4140      inputShapes: Object.keys(e).map(function (t) {
4141        return e[t].shape;
4142      }),
4143      outputShapes: s.map(function (t) {
4144        return t.shape;
4145      })
4146    }), Array.isArray(v) ? s : s[0];
4147  }, t.prototype.saveTensorsForBackwardMode = function (t) {
4148    var e = this;
4149    return t.map(function (t) {
4150      return e.keep(e.clone(t));
4151    });
4152  }, t.prototype.getTensorsForGradient = function (t, e, n) {
4153    var r = h(t);
4154
4155    if (null != r) {
4156      var o = r.inputsToSave || [],
4157          a = r.outputsToSave || [],
4158          i = o.map(function (t) {
4159        return e[t];
4160      }),
4161          s = n.filter(function (t, e) {
4162        return a[e];
4163      });
4164      return i.concat(s);
4165    }
4166
4167    return null;
4168  }, t.prototype.makeTensor = function (t, e, n, r) {
4169    if (null == t) throw new Error("Values passed to engine.makeTensor() are null");
4170    n = n || "float32", r = r || this.backend;
4171    var o = t;
4172    "string" === n && H(t[0]) && (o = t.map(function (t) {
4173      return rt(t);
4174    }));
4175    var a = r.write(o, e, n),
4176        i = new wt(e, n, a, this.nextTensorId());
4177
4178    if (this.incRef(i, r), "string" === n) {
4179      var s = this.state.tensorInfo.get(a),
4180          u = G(o);
4181      this.state.numBytes += u - s.bytes, s.bytes = u;
4182    }
4183
4184    return i;
4185  }, t.prototype.makeTensorFromDataId = function (t, e, n, r) {
4186    var o = new wt(e, n = n || "float32", t, this.nextTensorId());
4187    return this.incRef(o, r), o;
4188  }, t.prototype.makeVariable = function (t, e, n, r) {
4189    void 0 === e && (e = !0), n = n || this.nextVariableId().toString(), null != r && r !== t.dtype && (t = t.asType(r));
4190    var o = new St(t, e, n, this.nextTensorId());
4191    if (null != this.state.registeredVariables[o.name]) throw new Error("Variable with name " + o.name + " was already registered");
4192    return this.state.registeredVariables[o.name] = o, this.incRef(o, this.backend), o;
4193  }, t.prototype.incRef = function (t, e) {
4194    var n = this.state.tensorInfo.has(t.dataId) ? this.state.tensorInfo.get(t.dataId).refCount : 0;
4195
4196    if (this.state.numTensors++, "string" === t.dtype && this.state.numStringTensors++, 0 === n) {
4197      this.state.numDataBuffers++;
4198      var r = 0;
4199      "complex64" !== t.dtype && "string" !== t.dtype && (r = t.size * z(t.dtype)), this.state.tensorInfo.set(t.dataId, {
4200        backend: e || this.backend,
4201        dtype: t.dtype,
4202        shape: t.shape,
4203        bytes: r,
4204        refCount: 0
4205      }), this.state.numBytes += r;
4206    }
4207
4208    this.state.tensorInfo.get(t.dataId).refCount++, t instanceof St || this.track(t);
4209  }, t.prototype.disposeTensor = function (t) {
4210    if (this.state.tensorInfo.has(t.dataId)) {
4211      this.state.numTensors--, "string" === t.dtype && this.state.numStringTensors--;
4212      var e = this.state.tensorInfo.get(t.dataId);
4213      e.refCount <= 1 ? ("complex64" !== t.dtype && (this.state.numBytes -= e.bytes), this.state.numDataBuffers--, e.backend.disposeData(t.dataId), this.state.tensorInfo.delete(t.dataId)) : this.state.tensorInfo.get(t.dataId).refCount--;
4214    }
4215  }, t.prototype.disposeVariables = function () {
4216    for (var t in this.state.registeredVariables) {
4217      var e = this.state.registeredVariables[t];
4218      this.disposeVariable(e);
4219    }
4220  }, t.prototype.disposeVariable = function (t) {
4221    this.disposeTensor(t), null != this.state.registeredVariables[t.name] && delete this.state.registeredVariables[t.name];
4222  }, t.prototype.memory = function () {
4223    var t = this.backend.memory();
4224    return t.numTensors = this.state.numTensors, t.numDataBuffers = this.state.numDataBuffers, t.numBytes = this.state.numBytes, this.state.numStringTensors > 0 && (t.unreliable = !0, null == t.reasons && (t.reasons = []), t.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")), t;
4225  }, t.prototype.profile = function (t) {
4226    return n(this, void 0, void 0, function () {
4227      var e, n;
4228      return r(this, function (r) {
4229        return this.state.profiling = !0, e = this.state.numBytes, n = this.state.numTensors, this.state.activeProfile.kernels = [], this.state.activeProfile.result = t(), this.state.profiling = !1, this.state.activeProfile.peakBytes = Math.max.apply(Math, this.state.activeProfile.kernels.map(function (t) {
4230          return t.totalBytesSnapshot;
4231        })), this.state.activeProfile.newBytes = this.state.numBytes - e, this.state.activeProfile.newTensors = this.state.numTensors - n, [2, this.state.activeProfile];
4232      });
4233    });
4234  }, t.prototype.isTapeOn = function () {
4235    return this.state.gradientDepth > 0 && 0 === this.state.kernelDepth;
4236  }, t.prototype.addTapeNode = function (t, e, n, r, o, a) {
4237    var i = this,
4238        s = {
4239      id: this.state.nextTapeNodeId++,
4240      kernelName: t,
4241      inputs: e,
4242      outputs: n,
4243      saved: o
4244    },
4245        u = h(t);
4246    null != u && (r = u.gradFunc), null != r && (s.gradient = function (t) {
4247      return t = t.map(function (t, e) {
4248        if (null == t) {
4249          var r = n[e],
4250              o = tt(r.size, r.dtype);
4251          return i.makeTensor(o, r.shape, r.dtype);
4252        }
4253
4254        return t;
4255      }), r(t.length > 1 ? t : t[0], o, a);
4256    }), this.state.activeTape.push(s);
4257  }, t.prototype.keep = function (t) {
4258    return t.kept = !0, t;
4259  }, t.prototype.startTape = function () {
4260    0 === this.state.gradientDepth && (this.state.activeTape = []), this.state.gradientDepth++;
4261  }, t.prototype.endTape = function () {
4262    this.state.gradientDepth--;
4263  }, t.prototype.startScope = function (t) {
4264    var e = {
4265      track: [],
4266      name: "unnamed scope",
4267      id: this.state.nextScopeId++
4268    };
4269    t && (e.name = t), this.state.scopeStack.push(e), this.state.activeScope = e;
4270  }, t.prototype.endScope = function (t) {
4271    for (var e = this, n = _t(t), r = new Set(n.map(function (t) {
4272      return t.id;
4273    })), o = 0; o < this.state.activeScope.track.length; o++) {
4274      var a = this.state.activeScope.track[o];
4275      a.kept || r.has(a.id) || a.dispose();
4276    }
4277
4278    var i = this.state.scopeStack.pop();
4279    this.state.activeScope = 0 === this.state.scopeStack.length ? null : this.state.scopeStack[this.state.scopeStack.length - 1], n.forEac
4279h(function (t) {
4280      t.kept || t.scopeId !== i.id || e.track(t);
4281    });
4282  }, t.prototype.gradients = function (t, e, n, r) {
4283    var o = this;
4284    if (void 0 === r && (r = !1), C(e.length > 0, function () {
4285      return "gradients() received an empty list of xs.";
4286    }), null != n && "float32" !== n.dtype) throw new Error("dy must have 'float32' dtype, but has '" + n.dtype + "'");
4287    var a = this.scopedRun(function () {
4288      return o.startTape();
4289    }, function () {
4290      return o.endTape();
4291    }, function () {
4292      return o.tidy("forward", t);
4293    });
4294    C(a instanceof wt, function () {
4295      return "The result y returned by f() must be a tensor.";
4296    });
4297
4298    var i = function (t, e, n) {
4299      for (var r = {}, o = {}, a = 0; a < e.length; a++) r[e[a].id] = !0;
4300
4301      for (a = 0; a < t.length; a++) {
4302        var i = (p = t[a]).inputs;
4303
4304        for (var s in i) {
4305          for (var u = i[s], c = !1, l = 0; l < e.length; l++) if (r[u.id]) {
4306            p.outputs.forEach(function (t) {
4307              return r[t.id] = !0;
4308            }), c = !0, o[p.id] = !0;
4309            break;
4310          }
4311
4312          if (c) break;
4313        }
4314      }
4315
4316      var h = {};
4317      h[n.id] = !0;
4318      var f = {};
4319
4320      for (a = t.length - 1; a >= 0; a--) for (i = (p = t[a]).inputs, l = 0; l < p.outputs.length; l++) if (h[p.outputs[l].id]) {
4321        for (var s in i) h[i[s].id] = !0, f[p.id] = !0;
4322
4323        break;
4324      }
4325
4326      var d = [];
4327
4328      for (a = 0; a < t.length; a++) {
4329        var p;
4330
4331        if (o[(p = t[a]).id] && f[p.id]) {
4332          var v = {};
4333
4334          for (var s in p.inputs) {
4335            var m = p.inputs[s];
4336            r[m.id] && (v[s] = m);
4337          }
4338
4339          var g = Object.assign({}, p);
4340          g.inputs = v, g.outputs = p.outputs, d.push(g);
4341        }
4342      }
4343
4344      return d;
4345    }(this.state.activeTape, e, a);
4346
4347    if (!r && 0 === i.length && e.length > 0) throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");
4348    return this.tidy("backward", function () {
4349      var t,
4350          r,
4351          s = {};
4352      s[a.id] = null == n ? (t = a.shape, r = Z(k(t), "float32"), Lt.makeTensor(r, t, "float32")) : n, function (t, e, n) {
4353        for (var r = function (r) {
4354          var o = e[r],
4355              a = [];
4356          if (o.outputs.forEach(function (e) {
4357            var n = t[e.id];
4358            null != n ? a.push(n) : a.push(null);
4359          }), null == o.gradient) throw new Error("Cannot compute gradient: gradient function not found for " + o.kernelName + ".");
4360
4361          var i = o.gradient(a),
4362              s = function (e) {
4363            if (!(e in i)) throw new Error("Cannot backprop through input " + e + ". Available gradients found: " + Object.keys(i) + ".");
4364            var r = n(function () {
4365              return i[e]();
4366            });
4367            if ("float32" !== r.dtype) throw new Error("Error in gradient for op " + o.kernelName + ". The gradient of input " + e + " must have 'float32' dtype, but has '" + r.dtype + "'");
4368            var a = o.inputs[e];
4369            if (!S(r.shape, a.shape)) throw new Error("Error in gradient for op " + o.kernelName + ". The gradient of input '" + e + "' has shape '" + r.shape + "', which does not match the shape of the input '" + a.shape + "'");
4370            if (null == t[a.id]) t[a.id] = r;else {
4371              var s = t[a.id];
4372              t[a.id] = s.add(r), s.dispose();
4373            }
4374          };
4375
4376          for (var u in o.inputs) s(u);
4377        }, o = e.length - 1; o >= 0; o--) r(o);
4378      }(s, i, function (t) {
4379        return o.tidy(t);
4380      });
4381      var u = e.map(function (t) {
4382        return s[t.id];
4383      });
4384      return 0 === o.state.gradientDepth && (o.state.activeTape.forEach(function (t) {
4385        for (var e = 0, n = t.saved; e < n.length; e++) {
4386          n[e].dispose();
4387        }
4388      }), o.state.activeTape = null), {
4389        value: a,
4390        grads: u
4391      };
4392    });
4393  }, t.prototype.customGrad = function (t) {
4394    var e = this;
4395    return C(X(t), function () {
4396      return "The f passed in customGrad(f) must be a function.";
4397    }), function () {
4398      for (var n, r = [], o = 0; o < arguments.length; o++) r[o] = arguments[o];
4399
4400      C(r.every(function (t) {
4401        return t instanceof wt;
4402      }), function () {
4403        return "The args passed in customGrad(f)(x1, x2,...) must all be tensors";
4404      });
4405      var a = {};
4406      return r.forEach(function (t, e) {
4407        a[e] = t;
4408      }), e.runKernelFunc(function (e, o) {
4409        return C((n = t.apply(void 0, r.concat([o]))).value instanceof wt, function () {
4410          return "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor";
4411        }), C(X(n.gradFunc), function () {
4412          return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.";
4413        }), n.value;
4414      }, a, function (t, e) {
4415        var o = n.gradFunc(t, e),
4416            a = Array.isArray(o) ? o : [o];
4417        C(a.length === r.length, function () {
4418          return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).";
4419        }), C(a.every(function (t) {
4420          return t instanceof wt;
4421        }), function () {
4422          return "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.";
4423        });
4424        var i = {};
4425        return a.forEach(function (t, e) {
4426          i[e] = function () {
4427            return t;
4428          };
4429        }), i;
4430      });
4431    };
4432  }, t.prototype.readSync = function (t) {
4433    return this.state.tensorInfo.get(t).backend.readSync(t);
4434  }, t.prototype.read = function (t) {
4435    return this.state.tensorInfo.get(t).backend.read(t);
4436  }, t.prototype.time = function (t) {
4437    return n(this, void 0, void 0, function () {
4438      var e, n;
4439      return r(this, function (r) {
4440        switch (r.label) {
4441          case 0:
4442            return e = et(), [4, this.backend.time(t)];
4443
4444          case 1:
4445            return (n = r.sent()).wallMs = et() - e, [2, n];
4446        }
4447      });
4448    });
4449  }, t.prototype.track = function (t) {
4450    return null != this.state.activeScope && (t.scopeId = this.state.activeScope.id, this.state.activeScope.track.push(t)), t;
4451  }, Object.defineProperty(t.prototype, "registeredVariables", {
4452    get: function () {
4453      return this.state.registeredVariables;
4454    },
4455    enumerable: !0,
4456    configurable: !0
4457  }), t.prototype.reset = function () {
4458    for (var t in this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new Bt(), this.registry) this.disposeRegisteredKernels(t), this.registry[t].dispose(), delete this.registry[t];
4459
4460    this.backendName = null, this.backendInstance = null, this.pendingBackendInit = null;
4461  }, t.nextTensorId = 0, t.nextVariableId = 0, t;
4462}();
4463
4464exports.tensor_util = Mt;
4465
4466var Lt = function () {
4467  var t = function () {
4468    if (null == Ot) {
4469      var t = void 0;
4470      if ("undefined" != typeof window) t = window;else if ("undefined" != typeof global) t = global;else if ("undefined" != typeof process) t = process;else {
4471        if ("undefined" == typeof self) throw new Error("Could not find a global object");
4472        t = self;
4473      }
4474      Ot = t;
4475    }
4476
4477    return Ot;
4478  }();
4479
4480  if (null == t._tfengine) {
4481    var e = new o(t);
4482    t._tfengine = new Pt(e);
4483  }
4484
4485  return function (t) {
4486    exports.ENV = s = t;
4487  }(t._tfengine.ENV), yt = function () {
4488    return t._tfengine;
4489  }, t._tfengine;
4490}();
4491
4492function Wt() {
4493  return "undefined" != typeof window && null != window.document || "undefined" != typeof WorkerGlobalScope;
4494}
4495
4496var Ut = i();
4497Ut.registerFlag("DEBUG", function () {
4498  return !1;
4499}, function (t) {
4500  t && console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.");
4501}), Ut.registerFlag("IS_BROWSER", function () {
4502  return Wt();
4503}), Ut.registerFlag("IS_NODE", function () {
4504  return "undefined" != typeof process && void 0 !== process.versions && void 0 !== process.versions.node;
4505}), Ut.registerFlag("IS_CHROME", function () {
4506  return "undefined" != typeof navigator && null != navigator && null != navigator.userAgent && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
4507}), Ut.registerFlag("PROD", function () {
4508  return !1;
4509}), Ut.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", function () {
4510  return Ut.getBool("DEBUG");
4511}), Ut.registerFlag("DEPRECATION_WARNINGS_ENABLED", function () {
4512  return !0;
4513}), Ut.registerFlag("IS_TEST", function () {
4514  return !1;
4515});
4516var Vt,
4517    zt,
4518    Gt,
4519    Ht = {},
4520    qt = {
4521  alpha: !1,
4522  antialias: !1,
4523  premultipliedAlpha: !1,
4524  preserveDrawingBuffer: !1,
4525  depth: !1,
4526  stencil: !1,
4527  failIfMajorPerformanceCaveat: !0
4528};
4529
4530function Kt(t, e) {
4531  Ht[t] = e;
4532}
4533
4534function jt(t) {
4535  t in Ht || (Ht[t] = function (t) {
4536    if (1 !== t && 2 !== t) throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");
4537
4538    var e = function (t) {
4539      if ("undefined" != typeof OffscreenCanvas && 2 === t) return new OffscreenCanvas(300, 150);
4540      if ("undefined" != typeof document) return document.createElement("canvas");
4541      throw new Error("Cannot create a canvas in this context");
4542    }(t);
4543
4544    if (e.addEventListener("webglcontextlost", function (e) {
4545      e.preventDefault(), delete Ht[t];
4546    }, !1), 1 === t) return e.getContext("webgl", qt) || e.getContext("experimental-webgl", qt);
4547    return e.getContext("webgl2", qt);
4548  }(t));
4549  var e = Ht[t];
4550  return e.isContextLost() ? (delete Ht[t], jt(t)) : (e.disable(e.DEPTH_TEST), e.disable(e.STENCIL_TEST), e.disable(e.BLEND), e.disable(e.DITHER), e.disable(e.POLYGON_OFFSET_FILL), e.disable(e.SAMPLE_COVERAGE), e.enable(e.SCISSOR_TEST), e.enable(e.CULL_FACE), e.cullFace(e.BACK), Ht[t]);
4551}
4552
4553function Xt(t, e) {
4554  return [e, t];
4555}
4556
4557function Yt(t) {
4558  var e = k(t);
4559  return D(Math.ceil(e / 4));
4560}
4561
4562function $t(t, e) {
4563  return [Math.max(1, Math.ceil(e / 2)), Math.max(1, Math.ceil(t / 2))];
4564}
4565
4566function Qt(t, e) {
4567  var n,
4568      r,
4569      o,
4570      a,
4571      s,
4572      u,
4573      c,
4574      l,
4575      h,
4576      f = t;
4577  return 2 === i().getNumber("WEBGL_VERSION") ? (n = f.R32F, r = f.R16F, o = f.RGBA16F, a = f.RGBA32F, s = f.RED, u = 4, c = 1, l = f.HALF_FLOAT, h = f.FLOAT) : (n = t.RGBA, r = t.RGBA, o = t.RGBA, a = f.RGBA, s = t.RGBA, u = 4, c = 4, l = null != e ? e.HALF_FLOAT_OES : null, h = t.FLOAT), {
4578    internalFormatFloat: n,
4579    internalFormatHalfFloat: r,
4580    internalFormatPackedHalfFloat: o,
4581    internalFormatPackedFloat: a,
4582    textureFormatFloat: s,
4583    downloadTextureFormat: t.RGBA,
4584    downloadUnpackNumChannels: u,
4585    defaultNumChannels: c,
4586    textureTypeHalfFloat: l,
4587    textureTypeFloat: h
4588  };
4589}
4590
4591function Jt(t, e, n) {
4592  var r = n();
4593  return e && function (t) {
4594    var e = t.getError();
4595    if (e !== t.NO_ERROR) throw new Error("WebGL Error: " + ne(t, e));
4596  }(t), r;
4597}
4598
4599!function (t) {
4600  t[t.DENSE = 0] = "DENSE", t[t.SHARED_BATCH = 1] = "SHARED_BATCH";
4601}(Vt || (Vt = {})), function (t) {
4602  t[t.RENDER = 0] = "RENDER", t[t.UPLOAD = 1] = "UPLOAD", t[t.PIXELS = 2] = "PIXELS", t[t.DOWNLOAD = 3] = "DOWNLOAD";
4603}(zt || (zt = {})), function (t) {
4604  t[t.UNPACKED_FLOAT16 = 0] = "UNPACKED_FLOAT16", t[t.UNPACKED_FLOAT32 = 1] = "UNPACKED_FLOAT32", t[t.PACKED_4X1_UNSIGNED_BYTE = 2] = "PACKED_4X1_UNSIGNED_BYTE", t[t.PACKED_2X2_FLOAT32 = 3] = "PACKED_2X2_FLOAT32", t[t.PACKED_2X2_FLOAT16 = 4] = "PACKED_2X2_FLOAT16";
4605}(Gt || (Gt = {}));
4606var Zt = 5.96e-8,
4607    te = 65504;
4608
4609function ee(t) {
4610  return !!(i().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || 0 === t || Zt < Math.abs(t) && Math.abs(t) < te);
4611}
4612
4613function ne(t, e) {
4614  switch (e) {
4615    case t.NO_ERROR:
4616      return "NO_ERROR";
4617
4618    case t.INVALID_ENUM:
4619      return "INVALID_ENUM";
4620
4621    case t.INVALID_VALUE:
4622      return "INVALID_VALUE";
4623
4624    case t.INVALID_OPERATION:
4625      return "INVALID_OPERATION";
4626
4627    case t.INVALID_FRAMEBUFFER_OPERATION:
4628      return "INVALID_FRAMEBUFFER_OPERATION";
4629
4630    case t.OUT_OF_MEMORY:
4631      return "OUT_OF_MEMORY";
4632
4633    case t.CONTEXT_LOST_WEBGL:
4634      return "CONTEXT_LOST_WEBGL";
4635
4636    default:
4637      return "Unknown error code " + e;
4638  }
4639}
4640
4641function re(t, e, n) {
4642  return ke(t, e, function () {
4643    return t.getExtension(n);
4644  }, 'Extension "' + n + '" not supported on this browser.');
4645}
4646
4647function oe(t, e, n) {
4648  var r = ke(t, e, function () {
4649    return t.createShader(t.VERTEX_SHADER);
4650  }, "Unable to create vertex WebGLShader.");
4651  if (Jt(t, e, function () {
4652    return t.shaderSource(r, n);
4653  }), Jt(t, e, function () {
4654    return t.compileShader(r);
4655  }), !1 === t.getShaderParameter(r, t.COMPILE_STATUS)) throw console.log(t.getShaderInfoLog(r)), new Error("Failed to compile vertex shader.");
4656  return r;
4657}
4658
4659function ae(t, e, n) {
4660  var r = ke(t, e, function () {
4661    return t.createShader(t.FRAGMENT_SHADER);
4662  }, "Unable to create fragment WebGLShader.");
4663  if (Jt(t, e, function () {
4664    return t.shaderSource(r, n);
4665  }), Jt(t, e, function () {
4666    return t.compileShader(r);
4667  }), !1 === t.getShaderParameter(r, t.COMPILE_STATUS)) throw function (t, e) {
4668    var n = ue.exec(e);
4669    if (null == n) return console.log("Couldn't parse line number in error: " + e), void console.log(t);
4670
4671    for (var r = +n[1], o = t.split("\n"), a = o.length.toString().length + 2, i = o.map(function (t, e) {
4672      return N((e + 1).toString(), a) + t;
4673    }), s = 0, u = 0; u < i.length; u++) s = Math.max(i[u].length, s);
4674
4675    var c = i.slice(0, r - 1),
4676        l = i.slice(r - 1, r),
4677        h = i.slice(r);
4678    console.log(c.join("\n")), console.log(e.split("\n")[0]), console.log("%c " + N(l[0], s), "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(h.join("\n"));
4679  }(n, t.getShaderInfoLog(r)), new Error("Failed to compile fragment shader.");
4680  return r;
4681}
4682
4683var ie,
4684    se,
4685    ue = /ERROR: [0-9]+:([0-9]+):/g;
4686
4687function ce(t, e) {
4688  return ke(t, e, function () {
4689    return t.createProgram();
4690  }, "Unable to create WebGLProgram.");
4691}
4692
4693function le(t, e, n) {
4694  if (Jt(t, e, function () {
4695    return t.linkProgram(n);
4696  }), !1 === t.getProgramParameter(n, t.LINK_STATUS)) throw console.log(t.getProgramInfoLog(n)), new Error("Failed to link vertex and fragment shaders.");
4697}
4698
4699function he(t, e, n) {
4700  if (Jt(t, e, function () {
4701    return t.validateProgram(n);
4702  }), !1 === t.getProgramParameter(n, t.VALIDATE_STATUS)) throw console.log(t.getProgramInfoLog(n)), new Error("Shader program validation failed.");
4703}
4704
4705function fe(t, e, n) {
4706  var r = ke(t, e, function () {
4707    return t.createBuffer();
4708  }, "Unable to create WebGLBuffer");
4709  return Jt(t, e, function () {
4710    return t.bindBuffer(t.ARRAY_BUFFER, r);
4711  }), Jt(t, e, function () {
4712    return t.bufferData(t.ARRAY_BUFFER, n, t.STATIC_DRAW);
4713  }), r;
4714}
4715
4716function de(t, e, n) {
4717  var r = ke(t, e, function () {
4718    return t.createBuffer();
4719  }, "Unable to create WebGLBuffer");
4720  return Jt(t, e, function () {
4721    return t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, r);
4722  }), Jt(t, e, function () {
4723    return t.bufferData(t.ELEMENT_ARRAY_BUFFER, n, t.STATIC_DRAW);
4724  }), r;
4725}
4726
4727function pe(t, e) {
4728  return ke(t, e, function () {
4729    return t.createTexture();
4730  }, "Unable to create WebGLTexture.");
4731}
4732
4733function ve(t, e) {
4734  var n = i().getNumber("WEBGL_MAX_TEXTURE_SIZE");
4735
4736  if (t <= 0 || e <= 0) {
4737    var r = "[" + t + "x" + e + "]";
4738    throw new Error("Requested texture size " + r + " is invalid.");
4739  }
4740
4741  if (t > n || e > n) {
4742    r = "[" + t + "x" + e + "]";
4743    throw new Error("Requested texture size " + r + " greater than WebGL maximum on this browser / GPU " + ("[" + n + "x" + n + "]") + ".");
4744  }
4745}
4746
4747function me(t, e) {
4748  return ke(t, e, function () {
4749    return t.createFramebuffer();
4750  }, "Unable to create WebGLFramebuffer.");
4751}
4752
4753function ge(t, e, n, r, o, a, i, s) {
4754  var u = t.getAttribLocation(n, r);
4755  return -1 !== u && (Jt(t, e, function () {
4756    return t.bindBuffer(t.ARRAY_BUFFER, o);
4757  }), Jt(t, e, function () {
4758    return t.vertexAttribPointer(u, a, t.FLOAT, !1, i, s);
4759  }), Jt(t, e, function () {
4760    return t.enableVertexAttribArray(u);
4761  }), !0);
4762}
4763
4764function ye(t, e, n, r) {
4765  Se(t, r), Jt(t, e, function () {
4766    return t.activeTexture(t.TEXTURE0 + r);
4767  }), Jt(t, e, function () {
4768    return t.bindTexture(t.TEXTURE_2D, n);
4769  });
4770}
4771
4772function xe(t, e, n, r) {
4773  return ke(t, e, function () {
4774    return t.getUniformLocation(n, r);
4775  }, 'uniform "' + r + '" not present in program.');
4776}
4777
4778function be(t, e, n) {
4779  return t.getUniformLocation(e, n);
4780}
4781
4782function we(t, e, n, r, o, a) {
4783  Jt(t, e, function () {
4784    return ye(t, e, r, a);
4785  }), Jt(t, e, function () {
4786    return t.uniform1i(o, a);
4787  });
4788}
4789
4790function Ce(t, e, n, r) {
4791  Jt(t, e, function () {
4792    return t.bindFramebuffer(t.FRAMEBUFFER, r);
4793  }), Jt(t, e, function () {
4794    return t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, n, 0);
4795  });
4796}
4797
4798function Ee(t, e, n) {
4799  Jt(t, e, function () {
4800    return t.bindFramebuffer(t.FRAMEBUFFER, n);
4801  }), Jt(t, e, function () {
4802    return t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, null, 0);
4803  });
4804}
4805
4806function Re(t) {
4807  var e = t.checkFramebufferStatus(t.FRAMEBUFFER);
4808  if (e !== t.FRAMEBUFFER_COMPLETE) throw new Error("Error binding framebuffer: " + Ie(t, e));
4809}
4810
4811function Ie(t, e) {
4812  switch (e) {
4813    case t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
4814      return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT";
4815
4816    case t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
4817      return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";
4818
4819    case t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
4820      return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS";
4821
4822    case t.FRAMEBUFFER_UNSUPPORTED:
4823      return "FRAMEBUFFER_UNSUPPORTED";
4824
4825    default:
4826      return "unknown error " + e;
4827  }
4828}
4829
4830function ke(t, e, n, r) {
4831  var o = Jt(t, e, function () {
4832    return n();
4833  });
4834  if (null == o) throw new Error(r);
4835  return o;
4836}
4837
4838function Se(t, e) {
4839  var n = t.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1,
4840      r = e + t.TEXTURE0;
4841  if (r < t.TEXTURE0 || r > n) throw new Error("textureUnit must be in " + ("[gl.TEXTURE0, gl.TEXTURE" + n + "]") + ".");
4842}
4843
4844function Ae(t, e) {
4845  return void 0 === e && (e = 2), k(t.slice(0, t.length - e));
4846}
4847
4848function Te(t) {
4849  if (0 === t.length) throw Error("Cannot get rows and columns of an empty shape array.");
4850  return [t.length > 1 ? t[t.length - 2] : 1, t[t.length - 1]];
4851}
4852
4853function De(t) {
4854  var e = [1, 1, 1];
4855  return 0 === t.length || 1 === t.length && 1 === t[0] || (e = [Ae(t)].concat(Te(t))), e;
4856}
4857
4858function Ne(t, e) {
4859  var n;
4860  void 0 === e && (e = !1);
4861  var r = i().getNumber("WEBGL_MAX_TEXTURE_SIZE");
4862
4863  if (e && (r *= 2, 1 === (t = t.map(function (e, n) {
4864    return n >= t.length - 2 ? b(t[n]) : t[n];
4865  })).length && (t = [2, t[0]])), 2 !== t.length) {
4866    var o = M(t);
4867    t = o.newShape;
4868  }
4869
4870  var a = k(t);
4871  if (t.length <= 1 && a <= r) return [1, a];
4872  if (2 === t.length && t[0] <= r && t[1] <= r) return t;
4873  if (3 === t.length && t[0] * t[1] <= r && t[2] <= r) return [t[0] * t[1], t[2]];
4874  if (3 === t.length && t[0] <= r && t[1] * t[2] <= r) return [t[0], t[1] * t[2]];
4875  if (4 === t.length && t[0] * t[1] * t[2] <= r && t[3] <= r) return [t[0] * t[1] * t[2], t[3]];
4876  if (4 === t.length && t[0] <= r && t[1] * t[2] * t[3] <= r) return [t[0], t[1] * t[2] * t[3]
4876];
4877
4878  if (e) {
4879    var s = Ae(t),
4880        u = 2,
4881        c = 2;
4882    return t.length && (u = (n = Te(t))[0], c = n[1]), D(a = s * (u / 2) * (c / 2)).map(function (t) {
4883      return 2 * t;
4884    });
4885  }
4886
4887  return D(a);
4888}
4889
4890function Fe(t) {
4891  return t % 2 == 0;
4892}
4893
4894function _e(t, e) {
4895  if (S(t = t.slice(-2), e = e.slice(-2))) return !0;
4896  if (!t.length || !e.length) return !0;
4897  if (0 === t[0] || 0 === t[1] || 0 === e[0] || 0 === e[1]) return !0;
4898
4899  if (t.length !== e.length) {
4900    var n = t.slice(-1)[0],
4901        r = e.slice(-1)[0];
4902    if (n === r) return !0;
4903    if (Fe(n) && Fe(r) && (1 === t[0] || 1 === e[0])) return !0;
4904  }
4905
4906  return t[1] === e[1] && Fe(t[0]) && Fe(e[0]);
4907}
4908
4909function Oe(t) {
4910  if (null == ie) {
4911    var e = jt(t);
4912    ie = e.getParameter(e.MAX_TEXTURE_SIZE);
4913  }
4914
4915  return ie;
4916}
4917
4918function Me(t) {
4919  if (null == se) {
4920    var e = jt(t);
4921    se = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS);
4922  }
4923
4924  return Math.min(16, se);
4925}
4926
4927function Be(t) {
4928  if (0 === t) return 0;
4929  var e = jt(t);
4930  return Pe(e, "EXT_disjoint_timer_query_webgl2") && 2 === t ? 2 : Pe(e, "EXT_disjoint_timer_query") ? 1 : 0;
4931}
4932
4933function Pe(t, e) {
4934  return null != t.getExtension(e);
4935}
4936
4937function Le(t) {
4938  try {
4939    if (null != jt(t)) return !0;
4940  } catch (t) {
4941    return !1;
4942  }
4943
4944  return !1;
4945}
4946
4947function We(t) {
4948  if (0 === t) return !1;
4949  var e = jt(t);
4950
4951  if (1 === t) {
4952    if (!Pe(e, "OES_texture_float")) return !1;
4953  } else if (!Pe(e, "EXT_color_buffer_float")) return !1;
4954
4955  return Ve(e);
4956}
4957
4958function Ue(t) {
4959  if (0 === t) return !1;
4960  var e = jt(t);
4961
4962  if (1 !== t) {
4963    if (Pe(e, "EXT_color_buffer_float")) return Ve(e);
4964
4965    if (Pe(e, "EXT_color_buffer_half_float")) {
4966      var n = e.getExtension("EXT_color_buffer_half_float");
4967      return function (t, e) {
4968        var n = Qt(t, e),
4969            r = t.createTexture();
4970        t.bindTexture(t.TEXTURE_2D, r);
4971        t.texImage2D(t.TEXTURE_2D, 0, n.internalFormatHalfFloat, 1, 1, 0, n.textureFormatFloat, n.textureTypeHalfFloat, null);
4972        var o = t.createFramebuffer();
4973        t.bindFramebuffer(t.FRAMEBUFFER, o), t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, r, 0);
4974        var a = t.checkFramebufferStatus(t.FRAMEBUFFER) === t.FRAMEBUFFER_COMPLETE;
4975        return t.bindTexture(t.TEXTURE_2D, null), t.bindFramebuffer(t.FRAMEBUFFER, null), t.deleteTexture(r), t.deleteFramebuffer(o), a;
4976      }(e, n);
4977    }
4978
4979    return !1;
4980  }
4981
4982  return !!Pe(e, "OES_texture_float") && !!Pe(e, "WEBGL_color_buffer_float") && Ve(e);
4983}
4984
4985function Ve(t) {
4986  var e = Qt(t),
4987      n = t.createTexture();
4988  t.bindTexture(t.TEXTURE_2D, n);
4989  t.texImage2D(t.TEXTURE_2D, 0, e.internalFormatFloat, 1, 1, 0, e.textureFormatFloat, e.textureTypeFloat, null);
4990  var r = t.createFramebuffer();
4991  t.bindFramebuffer(t.FRAMEBUFFER, r), t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, n, 0);
4992  var o = t.checkFramebufferStatus(t.FRAMEBUFFER) === t.FRAMEBUFFER_COMPLETE;
4993  return t.bindTexture(t.TEXTURE_2D, null), t.bindFramebuffer(t.FRAMEBUFFER, null), t.deleteTexture(n), t.deleteFramebuffer(r), o;
4994}
4995
4996function ze(t) {
4997  return 2 === t && null != jt(t).fenceSync;
4998}
4999
5000var Ge = Object.freeze({
5001  callAndCheck: Jt,
5002  canBeRepresented: ee,
5003  getWebGLErrorMessage: ne,
5004  getExtensionOrThrow: re,
5005  createVertexShader: oe,
5006  createFragmentShader: ae,
5007  createProgram: ce,
5008  linkProgram: le,
5009  validateProgram: he,
5010  createStaticVertexBuffer: fe,
5011  createStaticIndexBuffer: de,
5012  getNumChannels: function () {
5013    return 2 === i().getNumber("WEBGL_VERSION") ? 1 : 4;
5014  },
5015  createTexture: pe,
5016  validateTextureSize: ve,
5017  createFramebuffer: me,
5018  bindVertexBufferToProgramAttribute: ge,
5019  bindTextureUnit: ye,
5020  unbindTextureUnit: function (t, e, n) {
5021    Se(t, n), Jt(t, e, function () {
5022      return t.activeTexture(t.TEXTURE0 + n);
5023    }), Jt(t, e, function () {
5024      return t.bindTexture(t.TEXTURE_2D, null);
5025    });
5026  },
5027  getProgramUniformLocationOrThrow: xe,
5028  getProgramUniformLocation: be,
5029  bindTextureToProgramUniformSampler: we,
5030  bindCanvasToFramebuffer: function (t, e) {
5031    Jt(t, e, function () {
5032      return t.bindFramebuffer(t.FRAMEBUFFER, null);
5033    }), Jt(t, e, function () {
5034      return t.viewport(0, 0, t.canvas.width, t.canvas.height);
5035    }), Jt(t, e, function () {
5036      return t.scissor(0, 0, t.canvas.width, t.canvas.height);
5037    });
5038  },
5039  bindColorTextureToFramebuffer: Ce,
5040  unbindColorTextureFromFramebuffer: Ee,
5041  validateFramebuffer: Re,
5042  getFramebufferErrorMessage: Ie,
5043  getBatchDim: Ae,
5044  getRowsCols: Te,
5045  getShapeAs3D: De,
5046  getTextureShapeFromLogicalShape: Ne,
5047  isReshapeFree: _e,
5048  getWebGLMaxTextureSize: Oe,
5049  resetMaxTextureSize: function () {
5050    ie = null;
5051  },
5052  resetMaxTexturesInShader: function () {
5053    se = null;
5054  },
5055  getMaxTexturesInShader: Me,
5056  getWebGLDisjointQueryTimerVersion: Be,
5057  hasExtension: Pe,
5058  isWebGLVersionEnabled: Le,
5059  isCapableOfRenderingToFloatTexture: We,
5060  isDownloadFloatTextureEnabled: Ue,
5061  isWebGLFenceEnabled: ze
5062}),
5063    He = i();
5064
5065function qe() {
5066  i().set("PROD", !0);
5067}
5068
5069function Ke() {
5070  i().set("DEBUG", !0);
5071}
5072
5073function je() {
5074  i().set("DEPRECATION_WARNINGS_ENABLED", !1), console.warn("TensorFlow.js deprecation warnings have been disabled.");
5075}
5076
5077function Xe(t) {
5078  i().getBool("DEPRECATION_WARNINGS_ENABLED") && console.warn(t + " You can disable deprecation warnings with tf.disableDeprecationWarnings().");
5079}
5080
5081function Ye() {
5082  Lt.disposeVariables();
5083}
5084
5085function $e() {
5086  return Lt;
5087}
5088
5089function Qe() {
5090  return Lt.memory();
5091}
5092
5093function Je(t) {
5094  return Lt.profile(t);
5095}
5096
5097function Ze(t, e) {
5098  return Lt.tidy(t, e);
5099}
5100
5101function tn(t) {
5102  _t(t).forEach(function (t) {
5103    return t.dispose();
5104  });
5105}
5106
5107function en(t) {
5108  return Lt.keep(t);
5109}
5110
5111function nn(t) {
5112  return Lt.time(t);
5113}
5114
5115function rn(t) {
5116  return Lt.setBackend(t);
5117}
5118
5119function on() {
5120  return Lt.ready();
5121}
5122
5123function an() {
5124  return Lt.backendName;
5125}
5126
5127function sn(t) {
5128  Lt.removeBackend(t);
5129}
5130
5131function un(t) {
5132  return Lt.findBackend(t);
5133}
5134
5135function cn(t) {
5136  return Lt.findBackendFactory(t);
5137}
5138
5139function ln(t, e, n) {
5140  return void 0 === n && (n = 1), Lt.registerBackend(t, e, n);
5141}
5142
5143function hn() {
5144  return Lt.backend;
5145}
5146
5147function fn(t, e) {
5148  i().setPlatform(t, e);
5149}
5150
5151function dn() {
5152  for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
5153
5154  i().getBool("IS_TEST") || console.warn.apply(console, t);
5155}
5156
5157function pn(t, e) {
5158  var n = t;
5159  if (V(t)) return "string" === e ? [] : [t.length];
5160  if (!Array.isArray(t)) return [];
5161
5162  for (var r = []; Array.isArray(n) || V(n) && "string" !== e;) r.push(n.length), n = n[0];
5163
5164  return Array.isArray(t) && i().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && function t(e, n, r) {
5165    if (r = r || [], !Array.isArray(e) && !V(e)) return void C(0 === n.length, function () {
5166      return "Element arr[" + r.join("][") + "] is a primitive, but should be an array/TypedArray of " + n[0] + " elements";
5167    });
5168    C(n.length > 0, function () {
5169      return "Element arr[" + r.join("][") + "] should be a primitive, but is an array of " + e.length + " elements";
5170    }), C(e.length === n[0], function () {
5171      return "Element arr[" + r.join("][") + "] should have " + n[0] + " elements, but has " + e.length + " elements";
5172    });
5173
5174    for (var o = n.slice(1), a = 0; a < e.length; ++a) t(e[a], o, r.concat(a));
5175  }(t, r, []), r;
5176}
5177
5178function vn(t, e, n, r) {
5179  if (null != t && ("numeric" !== t && t !== e || "numeric" === t && "string" === e)) throw new Error("Argument '" + n + "' passed to '" + r + "' must be " + t + " tensor, but got " + e + " tensor");
5180}
5181
5182function mn(t, e, n, r) {
5183  if (void 0 === r && (r = "numeric"), t instanceof wt) return vn(r, t.dtype, e, n), t;
5184  var o = j(t);
5185
5186  if ("string" !== o && ["bool", "int32", "float32"].indexOf(r) >= 0 && (o = r), vn(r, o, e, n), null == t || !V(t) && !Array.isArray(t) && "number" != typeof t && "boolean" != typeof t && "string" != typeof t) {
5187    var a = null == t ? "null" : t.constructor.name;
5188    throw new Error("Argument '" + e + "' passed to '" + n + "' must be a Tensor or TensorLike, but got '" + a + "'");
5189  }
5190
5191  var s = pn(t, o);
5192  V(t) || Array.isArray(t) || (t = [t]);
5193  var u = "string" !== o ? Q(t, o, i().getBool("DEBUG")) : I(t, [], !0);
5194  return Lt.makeTensor(u, s, o);
5195}
5196
5197function gn(t, e, n, r) {
5198  if (void 0 === r && (r = "numeric"), !Array.isArray(t)) throw new Error("Argument " + e + " passed to " + n + " must be a `Tensor[]` or `TensorLike[]`");
5199  return t.map(function (t, r) {
5200    return mn(t, e + "[" + r + "]", n);
5201  }, r);
5202}
5203
5204function yn(t, e) {
5205  for (var n = 0; n < t.length; ++n) if (t[t.length - n - 1] !== e - 1 - n) return !1;
5206
5207  return !0;
5208}
5209
5210function xn(t, e, n) {
5211  for (var r = t.length + e.length, o = [], a = 0, i = 0, s = 0; s < r;
5211 s++) -1 === n.indexOf(s) ? o.push(t[a++]) : o.push(e[i++]);
5212
5213  return o;
5214}
5215
5216function bn(t, e) {
5217  for (var n = [], r = t.length, o = 0; o < r; o++) -1 === e.indexOf(o) && n.push(t[o]);
5218
5219  return [n, e.map(function (e) {
5220    return t[e];
5221  })];
5222}
5223
5224function wn(t, e) {
5225  return xn(t, e.map(function (t) {
5226    return 1;
5227  }), e);
5228}
5229
5230function Cn(t, e, n) {
5231  C(yn(e, n), function () {
5232    return t + " supports only inner-most axes for now. Got axes " + e + " and rank-" + n + " input.";
5233  });
5234}
5235
5236function En(t, e) {
5237  if (yn(t, e)) return null;
5238
5239  for (var n = [], r = 0; r < e; ++r) -1 === t.indexOf(r) && n.push(r);
5240
5241  return t.forEach(function (t) {
5242    return n.push(t);
5243  }), n;
5244}
5245
5246function Rn(t) {
5247  return t.map(function (t, e) {
5248    return [e, t];
5249  }).sort(function (t, e) {
5250    return t[1] - e[1];
5251  }).map(function (t) {
5252    return t[0];
5253  });
5254}
5255
5256function In(t, e) {
5257  for (var n = [], r = e - t; r < e; ++r) n.push(r);
5258
5259  return n;
5260}
5261
5262function kn(t, e) {
5263  var n = t[0].length;
5264  t.forEach(function (t, e) {
5265    C(t.length === n, function () {
5266      return "Error in concat" + n + "D: rank of tensors[" + e + "] must be the same as the rank of the rest (" + n + ")";
5267    });
5268  }), C(e >= 0 && e < n, function () {
5269    return "Error in concat" + n + "D: axis must be between 0 and " + (n - 1) + ".";
5270  });
5271  var r = t[0];
5272  t.forEach(function (t, o) {
5273    for (var a = 0; a < n; a++) C(a === e || t[a] === r[a], function () {
5274      return "Error in concat" + n + "D: Shape of tensors[" + o + "] (" + t + ") does not match the shape of the rest (" + r + ") along the non-concatenated axis " + o + ".";
5275    });
5276  });
5277}
5278
5279function Sn(t, e) {
5280  for (var n = t[0].slice(), r = 1; r < t.length; r++) n[e] += t[r][e];
5281
5282  return n;
5283}
5284
5285function An(t) {
5286  var e = Object.keys(t);
5287  if (1 !== e.length) throw new Error("Please provide an object with a single key (operation name) mapping to a function. Got an object with " + e.length + " keys.");
5288  var n = e[0],
5289      r = t[n];
5290  n.endsWith("_") && (n = n.substring(0, n.length - 1));
5291
5292  var o = function () {
5293    for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e];
5294
5295    Lt.startScope(n);
5296
5297    try {
5298      var o = r.apply(void 0, t);
5299      return o instanceof Promise && console.error("Cannot return a Promise inside of tidy."), Lt.endScope(o), o;
5300    } catch (t) {
5301      throw Lt.endScope(null), t;
5302    }
5303  };
5304
5305  return Object.defineProperty(o, "name", {
5306    value: n,
5307    configurable: !0
5308  }), o;
5309}
5310
5311He.registerFlag("HAS_WEBGL", function () {
5312  return He.getNumber("WEBGL_VERSION") > 0;
5313}), He.registerFlag("WEBGL_VERSION", function () {
5314  return Le(2) ? 2 : Le(1) ? 1 : 0;
5315}), He.registerFlag("WEBGL_BUFFER_SUPPORTED", function () {
5316  return 2 === He.get("WEBGL_VERSION");
5317}), He.registerFlag("WEBGL_CPU_FORWARD", function () {
5318  return !0;
5319}), He.registerFlag("WEBGL_FORCE_F16_TEXTURES", function () {
5320  return !1;
5321}), He.registerFlag("WEBGL_PACK", function () {
5322  return He.getBool("HAS_WEBGL");
5323}), He.registerFlag("WEBGL_PACK_NORMALIZATION", function () {
5324  return He.getBool("WEBGL_PACK");
5325}), He.registerFlag("WEBGL_PACK_CLIP", function () {
5326  return He.getBool("WEBGL_PACK");
5327}), He.registerFlag("WEBGL_PACK_DEPTHWISECONV", function () {
5328  return !1;
5329}), He.registerFlag("WEBGL_PACK_BINARY_OPERATIONS", function () {
5330  return He.getBool("WEBGL_PACK");
5331}), He.registerFlag("WEBGL_PACK_UNARY_OPERATIONS", function () {
5332  return He.getBool("WEBGL_PACK");
5333}), He.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS", function () {
5334  return He.getBool("WEBGL_PACK");
5335}), He.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS", function () {
5336  return He.getBool("WEBGL_PACK");
5337}), He.registerFlag("WEBGL_PACK_REDUCE", function () {
5338  return He.getBool("WEBGL_PACK");
5339}), He.registerFlag("WEBGL_LAZILY_UNPACK", function () {
5340  return He.getBool("WEBGL_PACK");
5341}), He.registerFlag("WEBGL_CONV_IM2COL", function () {
5342  return He.getBool("WEBGL_PACK");
5343}), He.registerFlag("WEBGL_MAX_TEXTURE_SIZE", function () {
5344  return Oe(He.getNumber("WEBGL_VERSION"));
5345}), He.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER", function () {
5346  return Me(He.getNumber("WEBGL_VERSION"));
5347}), He.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION", function () {
5348  var t = He.getNumber("WEBGL_VERSION");
5349  return 0 === t ? 0 : Be(t);
5350}), He.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE", function () {
5351  return He.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 && (t = navigator.userAgent || navigator.vendor || window.opera, !(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
5351sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0, 4))));
5352  var t;
5353}), He.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE", function () {
5354  return We(He.getNumber("WEBGL_VERSION"));
5355}), He.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED", function () {
5356  return !He.getBool("WEBGL_FORCE_F16_TEXTURES") && He.getBool("WEBGL_RENDER_FLOAT32_CAPABLE");
5357}), He.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED", function () {
5358  return Ue(He.getNumber("WEBGL_VERSION"));
5359}), He.registerFlag("WEBGL_FENCE_API_ENABLED", function () {
5360  return ze(He.getNumber("WEBGL_VERSION"));
5361}), He.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM", function () {
5362  return He.getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? 4 : 0;
5363}), bt = Xe;
5364var Tn = An({
5365  complex_: function (t, e) {
5366    var n = mn(t, "real", "complex"),
5367        r = mn(e, "imag", "complex");
5368    return E(n.shape, r.shape, "real and imag shapes, " + n.shape + " and " + r.shape + ", must match in call to tf.complex()."), Lt.runKernelFunc(function (t) {
5369      return t.complex(n, r);
5370    }, {
5371      $real: n,
5372      $imag: r
5373    });
5374  }
5375}),
5376    Dn = An({
5377  real_: function (t) {
5378    var e = mn(t, "input", "real");
5379    return Lt.runKernelFunc(function (t) {
5380      return t.real(e);
5381    }, {
5382      $input: e
5383    });
5384  }
5385}),
5386    Nn = An({
5387  imag_: function (t) {
5388    var e = mn(t, "input", "imag");
5389    return Lt.runKernelFunc(function (t) {
5390      return t.imag(e);
5391    }, {
5392      $input: e
5393    });
5394  }
5395});
5396exports.imag = Nn;
5397exports.real = Dn;
5398exports.complex = Tn;
5399
5400function Fn(t, e, n) {
5401  return _n(t, e, pn(t, n), n);
5402}
5403
5404function _n(t, e, n, r) {
5405  if (null == r && (r = j(t)), "complex64" === r) throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");
5406  if (!V(t) && !Array.isArray(t) && "number" != typeof t && "boolean" != typeof t && "string" != typeof t) throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");
5407
5408  if (null != e) {
5409    nt(e);
5410    var o = k(e),
5411        a = k(n);
5412    C(o === a, function () {
5413      return "Based on the provided shape, [" + e + "], the tensor should have " + o + " values but has " + a;
5414    });
5415
5416    for (var s = 0; s < n.length; ++s) {
5417      var u = n[s],
5418          c = s !== n.length - 1 || u !== k(e.slice(s));
5419      C(n[s] === e[s] || !c, function () {
5420        return "Error creating a new Tensor. Inferred shape (" + n + ") does not match the provided shape (" + e + "). ";
5421      });
5422    }
5423  }
5424
5425  return V(t) || Array.isArray(t) || (t = [t]), e = e || n, t = "string" !== r ? Q(t, r, i().getBool("DEBUG")) : I(t, [], !0), Lt.makeTensor(t, e, r);
5426}
5427
5428function On(t, e) {
5429  if ((V(t) && "string" !== e || Array.isArray(t)) && "complex64" !== e) throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");
5430  if ("string" === e && V(t) && !(t instanceof Uint8Array)) throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");
5431  return _n(t, [], [], e);
5432}
5433
5434function Mn(t, e) {
5435  R(t);
5436  var n = pn(t, e);
5437  if (1 !== n.length) throw new Error("tensor1d() requires values to be a flat/TypedArray");
5438  return _n(t, null, n, e);
5439}
5440
5441function Bn(t, e, n) {
5442  if (R(t), null != e && 2 !== e.length) throw new Error("tensor2d() requires shape to have two numbers");
5443  var r = pn(t, n);
5444  if (2 !== r.length && 1 !== r.length) throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");
5445  if (1 === r.length && null == e) throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");
5446  return _n(t, e, r, n);
5447}
5448
5449function Pn(t, e, n) {
5450  if (R(t), null != e && 3 !== e.length) throw new Error("tensor3d() requires shape to have three numbers");
5451  var r = pn(t, n);
5452  if (3 !== r.length && 1 !== r.length) throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");
5453  if (1 === r.length && null == e) throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");
5454  return _n(t, e, r, n);
5455}
5456
5457function Ln(t, e, n) {
5458  if (R(t), null != e && 4 !== e.length) throw new Error("tensor4d() requires shape to have four numbers");
5459  var r = pn(t, n);
5460  if (4 !== r.length && 1 !== r.length) throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");
5461  if (1 === r.length && null == e) throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");
5462  return _n(t, e, r, n);
5463}
5464
5465function Wn(t, e, n) {
5466  if (R(t), null != e && 5 !== e.length) throw new Error("tensor5d() requires shape to have five numbers");
5467  var r = pn(t, n);
5468  if (5 !== r.length && 1 !== r.length) throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");
5469  if (1 === r.length && null == e) throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");
5470  return _n(t, e, r, n);
5471}
5472
5473function Un(t, e, n) {
5474  if (R(t), null != e && 6 !== e.length) throw new Error("tensor6d() requires shape to have six numbers");
5475  var r = pn(t, n);
5476  if (6 !== r.length && 1 !== r.length) throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");
5477  if (1 === r.length && null == e) throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");
5478  return _n(t, e = e || r, r, n);
5479}
5480
5481function Vn(t, e, n, r) {
5482  return void 0 === e && (e = !0), Lt.makeVariable(t, e, n, r);
5483}
5484
5485function zn(t, e) {
5486  if (void 0 === e && (e = "float32"), "complex64" === e) {
5487    var n = zn(t, "float32"),
5488        r = Gn(t, "float32");
5489    return Tn(n, r);
5490  }
5491
5492  var o = Z(k(t), e);
5493  return Lt.makeTensor(o, t, e);
5494}
5495
5496function Gn(t, e) {
5497  if (void 0 === e && (e = "float32"), "complex64" === e) {
5498    var n = Gn(t, "float32"),
5499        r = Gn(t, "float32");
5500    return Tn(n, r);
5501  }
5502
5503  var o = tt(k(t), e);
5504  return Lt.makeTensor(o, t, e);
5505}
5506
5507function Hn(t, e, n) {
5508  return Lt.runKernelFunc(function (r) {
5509    return r.fill(t, e, n);
5510  }, {});
5511}
5512
5513function qn(t, e, n) {
5514  if (n <= 0) throw new Error("The number of values should be positive.");
5515  return Lt.runKernelFunc(function (r) {
5516    return r.linspace(t, e, n);
5517  }, {});
5518}
5519
5520function Kn(t, e, n, r) {
5521  if (void 0 === n && (n = 1), void 0 === r && (r = "float32"), 0 === n) throw new Error("Cannot have a step of zero");
5522  if (t === e || t < e && n < 0 || e < t && n > 1) return Gn([0], r);
5523  var o = tt(Math.abs(Math.ceil((e - t) / n)), r);
5524  e < t && 1 === n && (n = -1), o[0] = t;
5525
5526  for (var a = 1; a < o.length; a++) o[a] = o[a - 1] + n;
5527
5528  return Mn(o, r);
5529}
5530
5531var jn = An({
5532  onesLike_: function (t) {
5533    var e = mn(t, "x", "onesLike");
5534
5535    if ("complex64" === e.dtype) {
5536      var n = jn(Dn(e)),
5537          r = Xn(Nn(e));
5538      return Tn(n, r);
5539    }
5540
5541    return Lt.runKernelFunc(function (t) {
5542      return t.onesLike(e);
5543    }, {
5544      x: e
5545    }, function (t, e) {
5546      return {
5547        x: function () {
5548          return Xn(t);
5549        }
5550      };
5551    }, "OnesLike");
5552  }
5553}),
5554    Xn = An({
5555  zerosLike_: function (t) {
5556    var e = mn(t, "x", "zerosLike");
5557    return Lt.runKernelFunc(function (t) {
5558      return t.zerosLike(e);
5559    }, {
5560      x: e
5561    }, function (t, e) {
5562      return {
5563        x: function () {
5564          return Xn(t);
5565        }
5566      };
5567    }, "ZerosLike");
5568  }
5569});
5570exports.zerosLike = Xn;
5571exports.onesLike = jn;
5572var Yn = An({
5573  concat_: function (t, e) {
5574    void 0 === e && (e = 0), C(t.length >= 1, function () {
5575      return "Pass at least one tensor to concat";
5576    });
5577    var n = gn(t, "tensors", "concat");
5578    "complex64" === n[0].dtype && n.forEach(function (t) {
5579      if ("complex64" !== t.dtype) throw new Error("Cannot concatenate complex64 tensors with a tensor\n          with dtype " + t.dtype + ". ");
5580    }), e = O(e, n[0].shape)[0];
5581    var r = Sn(n.map(function (t) {
5582      return t.shape;
5583    }), e);
5584    if (0 === k(r)) return Fn([], r);
5585    if (1 === (n = n.filter(function (t) {
5586      return t.size > 0;
5587    })).length) return n[0];
5588    var o = n.map(function (t) {
5589      return t.shape;
5590    });
5591    kn(o, e);
5592    var a = n,
5593        i = {
5594      axis: e
5595    };
5596    return Lt.runKernelFunc(function (t) {
5597      return t.concat(n, e);
5598    }, a, function (t) {
5599      var n = o.map(function (t) {
5600        return t[e];
5601      });
5602      return tr(t, n, e).map(function (t) {
5603        return function () {
5604          return t;
5605        };
5606      });
5607    }, "Concat", i);
5608  }
5609}),
5610    $n = An({
5611  concat1d_: function (t) {
5612    return Yn(t, 0);
5613  }
5614}),
5615    Qn = An({
5616  concat2d_: function (t, e) {
5617    return Yn(t, e);
5618  }
5619}),
5620    Jn = An({
5621  concat3d_: function (t, e) {
5622    return Yn(t, e);
5623  }
5624}),
5625    Zn = An({
5626  concat4d_: function (t, e) {
5627    return Yn(t, e);
5628  }
5629}),
5630    tr = An({
5631  split_: function (t, e, n) {
5632    void 0 === n && (n = 0);
5633    var r,
5634        o = mn(t, "x", "split");
5635    return n = O(n, o.shape)[0], "number" == typeof e ? (C(o.shape[n] % e == 0, function () {
5636      return "Number of splits must evenly divide the axis.";
5637    }), r = new Array(e).fill(o.shape[n] / e)) : (C(o.shape[n] === e.reduce(function (t, e) {
5638      return t + e;
5639    }), function () {
5640      return "The sum of sizes must match the size of the axis dimension.";
5641    }), r = e), Lt.runKernelFunc(function (t) {
5642      return t.split(o, r, n);
5643    }, {
5644      $x: o
5645    }, function (t) {
5646      return {
5647        $x: function () {
5648          return Yn(t, n);
5649        }
5650      };
5651    });
5652  }
5653});
5654exports.split = tr;
5655exports.concat4d = Zn;
5656exports.concat3d = Jn;
5657exports.concat2d = Qn;
5658exports.concat1d = $n;
5659exports.concat = Yn;
5660
5661function er(t, e, n) {
5662  return void 0 === e && (e = "float32"), e = e || "float32", nt(t), new gt(t, e, n);
5663}
5664
5665function nr(t, e) {
5666  void 0 === e && (e = !1), console.log(t.toString(e));
5667}
5668
5669var rr = An({
5670  batchToSpaceND_: function (t, e, n) {
5671    var r = mn(t, "x", "batchToSpaceND"),
5672        o = e.reduce(function (t, e) {
5673      return t * e;
5674    });
5675    return C(r.rank >= 1 + e.length, function () {
5676      return "input rank is " + r.rank + " but should be > than blockShape.length " + e.length;
5677    }), C(n.length === e.length, function () {
5678      return "crops.length is " + n.length + " but should be equal to blockShape.length  " + e.length;
5679    }), C(r.shape[0] % o == 0, function () {
5680      return "input tensor batch is " + r.shape[0] + " but is not divisible by the product of the elements of blockShape " + e.join(" * ") + " === " + o;
5681    }), Lt.runKernelFunc(function (t) {
5682      return t.batchToSpaceND(r, e, n);
5683    }, {
5684      $x: r
5685    }, function (t) {
5686      return {
5687        $x: function () {
5688          return t.spaceToBatchND(e, n);
5689        }
5690      };
5691    });
5692  }
5693}),
5694    or = An({
5695  cast_: function (t, e) {
5696    var n = mn(t, "x", "cast");
5697    if (!W(e)) throw new Error("Failed to cast to unknown dtype " + e);
5698    if ("string" === e && "string" !== n.dtype || "string" !== e && "string" === n.dtype) throw new Error("Only strings can be casted to strings");
5699    var r = {
5700      dtype: e
5701    };
5702    return Lt.runKernelFunc(function (t) {
5703      return t.cast(n, e);
5704    }, {
5705      x: n
5706    }, function (t) {
5707      return {
5708        x: function () {
5709          return t.clone();
5710        }
5711      };
5712    }, "Cast", r);
5713  }
5714}),
5715    ar = An({
5716  cumsum_: function (t, e, n, r) {
5717    void 0 === e && (e = 0), void 0 === n && (n = !1), void 0 === r && (r = !1);
5718    var o = mn(t, "x", "cumsum"),
5719        a = En([e |= 0], o.rank),
5720        i = o;
5721    null != a && (i = o.transpose(a));
5722    var s = In(1, o.rank)[0],
5723        u = Lt.runKernelFunc(function (t) {
5724      return t.cumsum(i, s, n, r);
5725    }, {
5726      permutedX: i
5727    }, function (t) {
5728      return {
5729        permutedX: function () {
5730          return t.cumsum(e, n, !r);
5731        }
5732      };
5733    });
5734    return null != a && (u = u.transpose(a)), u;
5735  }
5736}),
5737    ir = An({
5738  depthToSpace_: function (t, e, n) {
5739    void 0 === n && (n = "NHWC");
5740    var r = mn(t, "x", "depthToSpace"),
5741        o = "NHWC" === n ? r.shape[1] : r.shape[2],
5742        a = "NHWC" === n ? r.shape[2] : r.shape[3],
5743        i = "NHWC" === n ? r.shape[3] : r.shape[1];
5744    return C(o * e >= 0, function () {
5745      return "Negative dimension size caused by overflow when multiplying\n      " + o + " and " + e + "  for depthToSpace with input shape\n      " + r.shape;
5746    }), C(a * e >= 0, function () {
5747      return "Negative dimension size caused by overflow when multiplying\n      " + a + " and " + e + " for depthToSpace with input shape\n          " + r.shape;
5748    }), C(i % (e * e) == 0, function () {
5749      return "Dimension size must be evenly divisible by " + e * e + " but is " + i + " for depthToSpace with input shape " + r.shape;
5750    }), Lt.runKernelFunc(function (t) {
5751      return t.depthToSpace(r, e, n);
5752    }, {
5753      $x: r
5754    });
5755  }
5756}),
5757    sr = An({
5758  expandDims_: function (t, e) {
5759    void 0 === e && (e = 0);
5760    var n = mn(t, "x", "expandDims", null);
5761    C(e <= n.rank, function () {
5762      return "Axis must be <= rank of the tensor";
5763    });
5764    var r = n.shape.slice();
5765    return e < 0 && (C(-(n.rank + 1) <= e, function () {
5766      return "Axis must be in the interval [" + -(n.rank + 1) + ", " + n.rank + "]";
5767    }), e = n.rank + e + 1), r.splice(e, 0, 1), dr(n, r);
5768  }
5769}),
5770    ur = An({
5771  pad_: function (t, e, n) {
5772    void 0 === n && (n = 0);
5773    var r = mn(t, "x", "pad");
5774    if (0 === r.rank) throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");
5775    var o = {
5776      paddings: e,
5777      constantValue: n
5778    };
5779    return Lt.runKernelFunc(function (t) {
5780      return t.pad(r, e, n);
5781    }, {
5782      x: r
5783    }, function (t) {
5784      var n = e.map(function (t) {
5785        return t[0];
5786      });
5787      return {
5788        x: function () {
5789          return t.slice(n, r.shape);
5790        }
5791      };
5792    }, "PadV2", o);
5793  }
5794}),
5795    cr = An({
5796  pad1d_: function (t, e, n) {
5797    return void 0 === n && (n = 0), C(2 === e.length, function () {
5798      return "Invalid number of paddings. Must be length of 2.";
5799    }), ur(t, [e], n);
5800  }
5801}),
5802    lr = An({
5803  pad2d_: function (t, e, n) {
5804    return void 0 === n && (n = 0), C(2 === e.length && 2 === e[0].length && 2 === e[1].length, function () {
5805      return "Invalid number of paddings. Must be length of 2 each.";
5806    }), ur(t, e, n);
5807  }
5808}),
5809    hr = An({
5810  pad3d_: function (t, e, n) {
5811    return void 0 === n && (n = 0), C(3 === e.length && 2 === e[0].length && 2 === e[1].length && 2 === e[2].length, function () {
5812      return "Invalid number of paddings. Must be length of 2 each.";
5813    }), ur(t, e, n);
5814  }
5815}),
5816    fr = An({
5817  pad4d_: function (t, e, n) {
5818    return void 0 === n && (n = 0), C(4 === e.length && 2 === e[0].length && 2 === e[1].length && 2 === e[2].length && 2 === e[3].length, function () {
5819      return "Invalid number of paddings. Must be length of 2 each.";
5820    }), ur(t, e, n);
5821  }
5822}),
5823    dr = An({
5824  reshape_: function (t, e) {
5825    var n = mn(t, "x", "reshape", null);
5826    e = _(e, n.size), C(n.size === k(e), function () {
5827      return "new shape and old shape must have the same number of elements.";
5828    });
5829    var r = {
5830      shape: e
5831    };
5832    return Lt.runKernelFunc(function (t) {
5833      return t.reshape(n, e);
5834    }, {
5835      x: n
5836    }, function (t) {
5837      return {
5838        x: function () {
5839          return t.reshape(n.shape);
5840        }
5841      };
5842    }, "Reshape", r);
5843  }
5844}),
5845    pr = An({
5846  spaceToBatchND_: function (t, e, n) {
5847    var r = mn(t, "x", "spaceToBatchND");
5848    return C(r.rank >= 1 + e.length, function () {
5849      return "input rank " + r.rank + " should be > than [blockShape] " + e.length;
5850    }), C(n.length === e.length, function () {
5851      return "paddings.shape[0] " + n.length + " must be equal to [blockShape] " + e.length;
5852    }), C(r.shape.reduce(function (t, r, o) {
5853      return o > 0 && o <= e.length ? t && (r + n[o - 1][0] + n[o - 1][1]) % e[o - 1] == 0 : t;
5854    }, !0), function () {
5855      return "input spatial dimensions " + r.shape.slice(1) + " with paddings " + n.toString() + " must be divisible by blockShapes " + e.toString();
5856    }), Lt.runKernelFunc(function (t) {
5857      return t.spaceToBatchND(r, e, n);
5858    }, {
5859      $x: r
5860    }, function (t) {
5861      return {
5862        $x: function () {
5863          return t.batchToSpaceND(e, n);
5864        }
5865      };
5866    });
5867  }
5868}),
5869    vr = An({
5870  squeeze_: function (t, e) {
5871    var n = mn(t, "x", "squeeze");
5872    return dr(n, M(n.shape, e).newShape);
5873  }
5874}),
5875    mr = An({
5876  stack_: function (t, e) {
5877    void 0 === e && (e = 0);
5878    var n = gn(t, "tensors", "stack");
5879    if (C(n.length >= 1, function () {
5880      return "Pass at least one tensor to tf.stack";
5881    }), 1 === n.length) return n[0].expandDims(e);
5882    var r = n[0].rank,
5883        o = n[0].shape,
5884        a = n[0].dtype;
5885    C(e <= r, function () {
5886      return "Axis must be <= rank of the tensor";
5887    }), n.forEach(function (t) {
5888      E(o, t.shape, "All tensors passed to stack must have matching shapes");
5889    }), n.forEach(function (t) {
5890      C(a === t.dtype, function () {
5891        return "All tensors passed to stack must have matching dtypes";
5892      });
5893    });
5894    var i = n.map(function (t) {
5895      return t.expandDims(e);
5896    });
5897    return Yn(i, e);
5898  }
5899}),
5900    gr = An({
5901  unstack_: function (t, e) {
5902    void 0 === e && (e = 0), e = e || 0;
5903    var n = mn(t, "x", "unstack");
5904    C(e >= -n.shape.length && e < n.shape.length, function () {
5905      return "Axis = " + e + " is not in [-" + n.shape.length + ", " + n.shape.length + ")";
5906    }), e < 0 && (e += n.shape.length);
5907    var r = {
5908      axis: e
5909    };
5910    return Lt.runKernelFunc(function (t) {
5911      return t.unstack(n, e);
5912    }, {
5913      x: n
5914    }, function (t) {
5915      return {
5916        x: function () {
5917          return mr(t, e);
5918        }
5919      };
5920    }, "Unpack", r);
5921  }
5922}),
5923    yr = function (t, e) {
5924  return n(this, void 0, void 0, function () {
5925    var n, o, a, i, s, u, c, l, h, f;
5926    return r(this, function (r) {
5927      switch (r.label) {
5928        case 0:
5929          return n = mn(t, "x", "setdiff1d"), o = mn(e, "y", "setdiff1d"), C(n.dtype === o.dtype, function () {
5930            return "x and y should have the same dtype, but got x (" + n.dtype + ") and y (" + o.dtype + ").";
5931          }), C(1 === n.rank, function () {
5932            return "x should be 1D tensor, but got x (" + n.shape + ").";
5933          }), C(1 === o.rank, function () {
5934            return "y should be 1D tensor, but got y (" + o.shape + ").";
5935          }), [4, n.data()];
5936
5937        case 1:
5938          return a = r.sent(), [4, o.data()];
5939
5940        case 2:
5941          for (i = r.sent(), s = new Set(i), u = 0, h = 0; h < a.length; h++) s.has(a[h]) || u++;
5942
5943          for (c = new gt([u], n.dtype), l = new gt([u], "int32"), h = 0, f = 0; h < a.length; h++) s.has(a[h]) || (c.values[f] = a[h], l.values[f] = h, f++);
5944
5945          return [2, [c.toTensor(), l.toTensor()]];
5946      }
5947    });
5948  });
5949};
5950
5951exports.setdiff1dAsync = yr;
5952exports.unstack = gr;
5953exports.stack = mr;
5954exports.squeeze = vr;
5955exports.spaceToBatchND = pr;
5956exports.reshape = dr;
5957exports.pad4d = fr;
5958exports.pad3d = hr;
5959exports.pad2d = lr;
5960exports.pad1d = cr;
5961exports.pad = ur;
5962exports.expandDims = sr;
5963exports.depthToSpace = ir;
5964exports.cumsum = ar;
5965exports.cast = or;
5966exports.batchToSpaceND = rr;
5967
5968function xr(t, e, n, r) {
5969  void 0 === r && (r = !0);
5970  var o = [];
5971  if (r) (o = o.concat(e.slice(0))).push(t[0] / n), o = o.concat(t.slice(1));else {
5972    o = o.concat(t[0]);
5973
5974    for (var a = e.length, i = 0; i < a; ++i) o = o.concat([t[i + 1] / e[i], e[i]]);
5975
5976    o = o.concat(t.slice(a + 1));
5977  }
5978  return o;
5979}
5980
5981function br(t, e, n) {
5982  void 0 === n && (n = !0);
5983  var r = [];
5984
5985  if (n) {
5986    r.push(e);
5987
5988    for (var o = e + 1; o < t; ++o) o <= 2 * e ? (r.push(o), r.push(o - (e + 1))) : r.push(o);
5989  } else {
5990    var a = [],
5991        i = [];
5992
5993    for (o = 1; o < t; ++o) o >= 2 * e + 1 || o % 2 == 1 ? i.push(o) : a.push(o);
5994
5995    r.push.apply(r, a), r.push(0), r.push.apply(r, i);
5996  }
5997
5998  return r;
5999}
6000
6001function wr(t, e, n, r) {
6002  void 0 === r && (r = !0);
6003  var o = [];
6004  r ? o.push(t[0] / n) : o.push(t[0] * n);
6005
6006  for (var a = 1; a < t.length; ++a) a <= e.length ? r ? o.push(e[a - 1] * t[a]) : o.push(t[a] / e[a - 1]) : o.push(t[a]);
6007
6008  return o;
6009}
6010
6011function Cr(t, e) {
6012  for (var n = [0], r = 0; r < e; ++r) n.push(t[r][0]);
6013
6014  return n;
6015}
6016
6017function Er(t, e, n) {
6018  for (var r = t.slice(0, 1), o = 0; o < n; ++o) r.push(t[o + 1] - e[o][0] - e[o][1]);
6019
6020  return r;
6021}
6022
6023var Rr = "Div",
6024    Ir = "SquaredDifference",
6025    kr = "BroadcastTo",
6026    Sr = "OneHot",
6027    Ar = "Identity",
6028    Tr = "Tile";
6029
6030function Dr(t, e) {
6031  for (var n = t.length, r = [], o = 0; o < n; o++) {
6032    var a = n - 1 - o,
6033        i = t[a] || 1;
6034    (e[e.length - 1 - o] || 1) > 1 && 1 === i && r.unshift(a);
6035  }
6036
6037  return r;
6038}
6039
6040function Nr(t, e) {
6041  for (var n = [], r = 0; r < e.length; r++) {
6042    var o = t[t.length - r - 1],
6043        a = e.length - r - 1,
6044        i = e[a];
6045    (null == o || 1 === o && i > 1) && n.unshift(a);
6046  }
6047
6048  return n;
6049}
6050
6051function Fr(t, e) {
6052  for (var n = [], r = Math.max(t.length, e.length), o = 0; o < r; o++) {
6053    var a = t[t.length - o - 1];
6054    null == a && (a = 1);
6055    var i = e[e.length - o - 1];
6056    if (null == i && (i = 1), 1 === a) n.unshift(i);else if (1 === i) n.unshift(a);else {
6057      if (a !== i) throw Error("Operands could not be broadcast together with shapes " + t + " and " + e + ".");
6058      n.unshift(a);
6059    }
6060  }
6061
6062  return n;
6063}
6064
6065var _r = An({
6066  abs_: function (t) {
6067    var e = mn(t, "x", "abs");
6068    return "complex64" === e.dtype ? Lt.runKernelFunc(function (t) {
6069      return t.complexAbs(e);
6070    }, {
6071      $x: e
6072    }) : Lt.runKernelFunc(function (t, n) {
6073      var r = t.abs(e);
6074      return n([e]), r;
6075    }, {
6076      x: e
6077    }, function (t, e) {
6078      var n = e[0];
6079      return {
6080        x: function () {
6081          return t.mul(n.toFloat().step(-1));
6082        }
6083      };
6084    }, "Abs");
6085  }
6086}),
6087    Or = An({
6088  acos_: function (t) {
6089    var e = mn(t, "x", "acos");
6090    return Lt.runKernelFunc(function (t, n) {
6091      var r = t.acos(e);
6092      return n([e]), r;
6093    }, {
6094      $x: e
6095    }, function (t, e) {
6096      var n = e[0];
6097      return {
6098        $x: function () {
6099          return t.divStrict(On(1).sub(n.toFloat().square()).sqrt()).neg();
6100        }
6101      };
6102    });
6103  }
6104}),
6105    Mr = An({
6106  acosh_: function (t) {
6107    var e = mn(t, "x", "acosh");
6108    return Lt.runKernelFunc(function (t, n) {
6109      var r = t.acosh(e);
6110      return n([e]), r;
6111    }, {
6112      $x: e
6113    }, function (t, e) {
6114      var n = e[0];
6115      return {
6116        $x: function () {
6117          return t.divStrict(n.toFloat().square().sub(1).sqrt());
6118        }
6119      };
6120    });
6121  }
6122}),
6123    Br = An({
6124  asin_: function (t) {
6125    var e = mn(t, "x", "asin");
6126    return Lt.runKernelFunc(function (t, n) {
6127      var r = t.asin(e);
6128      return n([e]), r;
6129    }, {
6130      $x: e
6131    }, function (t, e) {
6132      var n = e[0];
6133      return {
6134        $x: function () {
6135          return t.divStrict(On(1).sub(n.toFloat().square()).sqrt());
6136        }
6137      };
6138    });
6139  }
6140}),
6141    Pr = An({
6142  asinh_: function (t) {
6143    var e = mn(t, "x", "asinh");
6144    return Lt.runKernelFunc(function (t, n) {
6145      var r = t.asinh(e);
6146      return n([e]), r;
6147    }, {
6148      $x: e
6149    }, function (t, e) {
6150      var n = e[0];
6151      return {
6152        $x: function () {
6153          return t.divStrict(On(1).add(n.toFloat().square()).sqrt());
6154        }
6155      };
6156    });
6157  }
6158}),
6159    Lr = An({
6160  atan_: function (t) {
6161    var e = mn(t, "x", "atan");
6162    return Lt.runKernelFunc(function (t, n) {
6163      var r = t.atan(e);
6164      return n([e]), r;
6165    }, {
6166      $x: e
6167    }, function (t, e) {
6168      var n = e[0];
6169      return {
6170        $x: function () {
6171          return t.div(n.toFloat().square().add(1));
6172        }
6173      };
6174    });
6175  }
6176}),
6177    Wr = An({
6178  atanh_: function (t) {
6179    var e = mn(t, "x", "atanh");
6180    return Lt.runKernelFunc(function (t, n) {
6181      var r = t.atanh(e);
6182      return n([e]), r;
6183    }, {
6184      $x: e
6185    }, function (t, e) {
6186      var n = e[0];
6187      return {
6188        $x: function () {
6189          return t.div(On(1).sub(n.toFloat().square()));
6190        }
6191      };
6192    });
6193  }
6194}),
6195    Ur = An({
6196  ceil_: function (t) {
6197    var e = mn(t, "x", "ceil");
6198    return Lt.runKernelFunc(function (t) {
6199      return t.ceil(e);
6200    }, {
6201      $x: e
6202    }, function (t) {
6203      return {
6204        $x: function () {
6205          return Xn(t);
6206        }
6207      };
6208    });
6209  }
6210}),
6211    Vr = An({
6212  clipByValue_: function (t, e, n) {
6213    var r = mn(t, "x", "clipByValue");
6214    C(e <= n, function () {
6215      return "Error in clip: min (" + e + ") must be less than or equal to max (" + n + ").";
6216    });
6217    var o = [r],
6218        a = {
6219      min: e,
6220      max: n
6221    };
6222    return Lt.runKernelFunc(function (t, o) {
6223      var a = t.clip(r, e, n);
6224      return o([r]), a;
6225    }, {
6226      x: r
6227    }, function (t, r) {
6228      var o = r[0];
6229      return {
6230        x: function () {
6231          return t.where(o.greaterEqual(e).logicalAnd(o.lessEqual(n)), Xn(t));
6232        }
6233      };
6234    }, "ClipByValue", a, o);
6235  }
6236}),
6237    zr = An({
6238  cos_: function (t) {
6239    var e = mn(t, "x", "cos"),
6240        n = [e];
6241    return Lt.runKernelFunc(function (t, n) {
6242      var r = t.cos(e);
6243      return n([e]), r;
6244    }, {
6245      x: e
6246    }, function (t, e) {
6247      var n = e[0];
6248      return {
6249        x: function () {
6250          return n.toFloat().sin().neg().mul(t);
6251        }
6252      };
6253    }, "Cos", {}, n);
6254  }
6255}),
6256    Gr = An({
6257  cosh_: function (t) {
6258    var e = mn(t, "x", "cosh");
6259    return Lt.runKernelFunc(function (t, n) {
6260      var r = t.cosh(e);
6261      return n([e]), r;
6262    }, {
6263      $x: e
6264    }, function (t, e) {
6265      var n = e[0];
6266      return {
6267        $x: function () {
6268          return n.toFloat().sinh().mulStrict(t);
6269        }
6270      };
6271    });
6272  }
6273}),
6274    Hr = An({
6275  erf_: function (t) {
6276    var e = mn(t, "x", "erf");
6277    return C("int32" === e.dtype || "float32" === e.dtype, function () {
6278      return "Input dtype must be `int32` or `float32`.";
6279    }), "int32" === e.dtype && (e = e.toFloat()), Lt.runKernelFunc(function (t, n) {
6280      var r = t.erf(e);
6281      return n([e]), r;
6282    }, {
6283      $x: e
6284    }, function (t, e) {
6285      var n = e[0];
6286      return {
6287        $x: function () {
6288          return t.mul(n.square().neg().exp().mul(2 / Math.sqrt(Math.PI)));
6289        }
6290      };
6291    });
6292  }
6293}),
6294    qr = An({
6295  exp_: function (t) {
6296    var e = mn(t, "x", "exp");
6297    return Lt.runKernelFunc(function (t, n) {
6298      var r = t.exp(e);
6299      return n([r]), r;
6300    }, {
6301      x: e
6302    }, function (t, e) {
6303      return {
6304        x: function () {
6305          return t.mulStrict(e[0]);
6306        }
6307      };
6308    }, "Exp", {}, [], [!0]);
6309  }
6310}),
6311    Kr = An({
6312  expm1_: function (t) {
6313    var e = mn(t, "x", "expm1");
6314    return Lt.runKernelFunc(function (t, n) {
6315      var r = t.expm1(e);
6316      return n([e]), r;
6317    }, {
6318      $x: e
6319    }, function (t, e) {
6320      var n = e[0];
6321      return {
6322        $x: function () {
6323          return t.mul(n.exp());
6324        }
6325      };
6326    });
6327  }
6328}),
6329    jr = An({
6330  floor_: function (t) {
6331    var e = mn(t, "x", "floor");
6332    return Lt.runKernelFunc(function (t) {
6333      return t.floor(e);
6334    }, {
6335      $x: e
6336    }, function (t) {
6337      return {
6338        $x: function () {
6339          return Xn(t);
6340        }
6341      };
6342    });
6343  }
6344}),
6345    Xr = An({
6346  log_: function (t) {
6347    var e = mn(t, "x", "log"),
6348        n = [e];
6349    return Lt.runKernelFunc(function (t, n) {
6350      var r = t.log(e);
6351      return n([e]), r;
6352    }, {
6353      x: e
6354    }, function (t, e) {
6355      var n = e[0];
6356      return {
6357        x: function () {
6358          return t.div(n.toFloat());
6359        }
6360      };
6361    }, "Log", {}, n);
6362  }
6363}),
6364    Yr = An({
6365  log1p_: function (t) {
6366    var e = mn(t, "x", "log1p");
6367    return Lt.runKernelFunc(function (t, n) {
6368      var r = t.log1p(e);
6369      return n([e]), r;
6370    }, {
6371      $x: e
6372    }, function (t, e) {
6373      var n = e[0];
6374      return {
6375        $x: function () {
6376          return t.div(n.add(1));
6377        }
6378      };
6379    });
6380  }
6381}),
6382    $r = An({
6383  logSigmoid_: function (t) {
6384    var e = mn(t, "x", "logSigmoid");
6385    return Lt.runKernelFunc(function (t, n) {
6386      var r = t.softplus(e.neg()).neg();
6387      return n([e]), r;
6388    }, {
6389      $x: e
6390    }, function (t, e) {
6391      var n = e[0];
6392      return {
6393        $x: function () {
6394          return t.mul(n.neg().sigmoid());
6395        }
6396      };
6397    });
6398  }
6399}),
6400    Qr = An({
6401  neg_: function (t) {
6402    var e = mn(t, "x", "neg"),
6403        n = [e];
6404    return Lt.runKernelFunc(function (t) {
6405      return t.neg(e);
6406    }, {
6407      x: e
6408    }, function (t) {
6409      return {
6410        x: function () {
6411          return t.neg();
6412        }
6413      };
6414    }, "Neg", {}, n);
6415  }
6416}),
6417    Jr = An({
6418  reciprocal_: function (t) {
6419    var e = mn(t, "x", "reciprocal");
6420    return Lt.runKernelFunc(function (t, n) {
6421      var r = t.reciprocal(e);
6422      return n([e]), r;
6423    }, {
6424      $x: e
6425    }, function (t, e) {
6426      var n = e[0];
6427      return {
6428        $x: function () {
6429          return t.div(n.square().neg());
6430        }
6431      };
6432    });
6433  }
6434}),
6435    Zr = An({
6436  round_: function (t) {
6437    var e = mn(t, "x", "round");
6438    return Lt.runKernelFunc(function (t) {
6439      return t.round(e);
6440    }, {
6441      $x: e
6442    }, function (t) {
6443      return {
6444        $x: function () {
6445          return Xn(t);
6446        }
6447      };
6448    });
6449  }
6450}),
6451    to = An({
6452  rsqrt_: function (t) {
6453    var e = mn(t, "x", "rsqrt"),
6454        n = [e];
6455    return Lt.runKernelFunc(function (t, n) {
6456      var r = t.rsqrt(e);
6457      return n([e]), r;
6458    }, {
6459      x: e
6460    }, function (t, e) {
6461      var n = e[0];
6462      return {
6463        x: function () {
6464          return t.div(n.pow(1.5).mul(2)).neg();
6465        }
6466      };
6467    }, "Rsqrt", {}, n);
6468  }
6469}),
6470    eo = An({
6471  sigmoid_: function (t) {
6472    var e = mn(t, "x", "sigmoid");
6473    return Lt.runKernelFunc(function (t, n) {
6474      var r = t.sigmoid(e);
6475      return n([r]), r;
6476    }, {
6477      x: e
6478    }, function (t, e) {
6479      var n = e[0];
6480      return {
6481        x: function () {
6482          return t.mul(n.mul(On(1).sub(n)));
6483        }
6484      };
6485    }, "Sigmoid");
6486  }
6487}),
6488    no = An({
6489  sign_: function (t) {
6490    var e = mn(t, "x", "sign");
6491    return Lt.runKernelFunc(function (t) {
6492      return t.sign(e);
6493    }, {
6494      $x: e
6495    }, function (t) {
6496      return {
6497        $x: function () {
6498          return Xn(t);
6499        }
6500      };
6501    });
6502  }
6503}),
6504    ro = An({
6505  isNaN_: function (t) {
6506    var e = mn(t, "x", "isNaN");
6507    return Lt.runKernelFunc(function (t) {
6508      return t.isNaN(e);
6509    }, {
6510      $x: e
6511    }, function (t) {
6512      return {
6513        $x: function () {
6514          return Xn(t);
6515        }
6516      };
6517    });
6518  }
6519}),
6520    oo = An({
6521  isInf_: function (t) {
6522    var e = mn(t, "x", "isInf");
6523    return Lt.runKernelFunc(function (t) {
6524      return t.isInf(e);
6525    }, {
6526      $x: e
6527    }, function (t) {
6528      return {
6529        $x: function () {
6530          return Xn(t);
6531        }
6532      };
6533    });
6534  }
6535}),
6536    ao = An({
6537  isFinite_: function (t) {
6538    var e = mn(t, "x", "isFinite");
6539    return Lt.runKernelFunc(function (t) {
6540      return t.isFinite(e);
6541    }, {
6542      $x: e
6543    }, function (t) {
6544      return {
6545        $x: function () {
6546          return Xn(t);
6547        }
6548      };
6549    });
6550  }
6551}),
6552    io = An({
6553  sin_: function (t) {
6554    var e = mn(t, "x", "sin"),
6555        n = [e];
6556    return Lt.runKernelFunc(function (t, n) {
6557      var r = t.sin(e);
6558      return n([e]), r;
6559    }, {
6560      x: e
6561    }, function (t, e) {
6562      var n = e[0];
6563      return {
6564        x: function () {
6565          return n.toFloat().cos().mul(t);
6566        }
6567      };
6568    }, "Sin", {}, n);
6569  }
6570}),
6571    so = An({
6572  sinh_: function (t) {
6573    var e = mn(t, "x", "sinh");
6574    return Lt.runKernelFunc(function (t, n) {
6575      var r = t.sinh(e);
6576      return n([e]), r;
6577    }, {
6578      $x: e
6579    }, function (t, e) {
6580      var n = e[0];
6581      return {
6582        $x: function () {
6583          return n.toFloat().cosh().mulStrict(t);
6584        }
6585      };
6586    });
6587  }
6588}),
6589    uo = An({
6590  softplus_: function (t) {
6591    var e = mn(t, "x", "softplus");
6592    return Lt.runKernelFunc(function (t, n) {
6593      var r = t.softplus(e);
6594      return n([e]), r;
6595    }, {
6596      $x: e
6597    }, function (t, e) {
6598      var n = e[0];
6599      return {
6600        $x: function () {
6601          return t.mul(n.sigmoid());
6602        }
6603      };
6604    });
6605  }
6606}),
6607    co = An({
6608  sqrt_: function (t) {
6609    var e = mn(t, "x", "sqrt");
6610    return Lt.runKernelFunc(function (t, n) {
6611      var r = t.sqrt(e);
6612      return n([e]), r;
6613    }, {
6614      $x: e
6615    }, function (t, e) {
6616      var n = e[0];
6617      return {
6618        $x: function () {
6619          return t.div(n.toFloat().sqrt().mul(2));
6620        }
6621      };
6622    });
6623  }
6624}),
6625    lo = An({
6626  step_: function (t, e) {
6627    void 0 === e && (e = 0);
6628    var n = mn(t, "x", "step");
6629    return Lt.runKernelFunc(function (t) {
6630      return t.step(n, e);
6631    }, {
6632      $x: n
6633    }, function (t) {
6634      return {
6635        $x: function () {
6636          return Xn(t);
6637        }
6638      };
6639    });
6640  }
6641}),
6642    ho = An({
6643  tan_: function (t) {
6644    var e = mn(t, "x", "tan");
6645    return Lt.runKernelFunc(function (t, n) {
6646      var r = t.tan(e);
6647      return n([e]), r;
6648    }, {
6649      $x: e
6650    }, function (t, e) {
6651      var n = e[0];
6652      return {
6653        $x: function () {
6654          return t.div(n.cos().square());
6655        }
6656      };
6657    });
6658  }
6659}),
6660    fo = An({
6661  tanh_: function (t) {
6662    var e = mn(t, "x", "tanh");
6663    return Lt.runKernelFunc(function (t, n) {
6664      var r = t.tanh(e);
6665      return n([r]), r;
6666    }, {
6667      x: e
6668    }, function (t, e) {
6669      var n = e[0];
6670      return {
6671        x: function () {
6672          return On(1).sub(n.square()).mulStrict(t);
6673        }
6674      };
6675    }, "Tanh", {}, null, [!0]);
6676  }
6677});
6678
6679exports.tanh = fo;
6680exports.tan = ho;
6681exports.step = lo;
6682exports.sqrt = co;
6683exports.softplus = uo;
6684exports.sinh = so;
6685exports.sin = io;
6686exports.isFinite = ao;
6687exports.isInf = oo;
6688exports.isNaN = ro;
6689exports.sign = no;
6690exports.sigmoid = eo;
6691exports.rsqrt = to;
6692exports.round = Zr;
6693exports.reciprocal = Jr;
6694exports.neg = Qr;
6695exports.logSigmoid = $r;
6696exports.log1p = Yr;
6697exports.log = Xr;
6698exports.floor = jr;
6699exports.expm1 = Kr;
6700exports.exp = qr;
6701exports.erf = Hr;
6702exports.cosh = Gr;
6703exports.cos = zr;
6704exports.clipByValue = Vr;
6705exports.ceil = Ur;
6706exports.atanh = Wr;
6707exports.atan = Lr;
6708exports.asinh = Pr;
6709exports.asin = Br;
6710exports.acosh = Mr;
6711exports.acos = Or;
6712exports.abs = _r;
6713var po = An({
6714  add_: function (t, e) {
6715    var n,
6716        r = mn(t, "a", "add"),
6717        o = mn(e, "b", "add");
6718    n = Nt(r, o), r = n[0], o = n[1];
6719    var a = Fr(r.shape, o.shape);
6720    return Lt.runKernelFunc(function (t) {
6721      return t.add(r, o);
6722    }, {
6723      a: r,
6724      b: o
6725    }, function (t) {
6726      return {
6727        a: function () {
6728          var e = t,
6729              n = Nr(r.shape, a);
6730          return n.length > 0 && (e = e.sum(n)), e.reshape(r.shape);
6731        },
6732        b: function () {
6733          var e = t,
6734              n = Nr(o.shape, a);
6735          return n.length > 0 && (e = e.sum(n)), e.reshape(o.shape);
6736        }
6737      };
6738    }, "Add");
6739  }
6740}),
6741    vo = An({
6742  addN_: function (t) {
6743    C(Array.isArray(t), function () {
6744      return "The argument passed to tf.addN() must be a list of tensors";
6745    }), C(t.length >= 1, function () {
6746      return "Must pass at least one tensor to tf.addN(), but got " + t.length;
6747    });
6748    var e = t.map(function (t, e) {
6749      return mn(t, "tensors" + e, "addN");
6750    }),
6751        n = e[0];
6752    e.forEach(function (t) {
6753      if (t.dtype !== n.dtype) throw new Error("All tensors passed to tf.addN() must have the same dtype");
6754    }), e.forEach(function (t) {
6755      if (!S(t.shape, n.shape)) throw new Error("All tensors passed to tf.addN() must have the same shape");
6756    });
6757    var r = e;
6758    return Lt.runKernelFunc(function (t) {
6759      return t.addN(e);
6760    }, r, function (t) {
6761      var n = {};
6762      return e.forEach(function (e, r) {
6763        n[r] = function () {
6764          return t.clone();
6765        };
6766      }), n;
6767    }, "AddN");
6768  }
6769}),
6770    mo = An({
6771  addStrict_: function (t, e) {
6772    var n = mn(t, "a", "addStrict"),
6773        r = mn(e, "b", "addStrict");
6774    return E(n.shape, r.shape, "Error in addStrict: "), n.add(r);
6775  }
6776}),
6777    go = An({
6778  atan2_: function (t, e) {
6779    var n,
6780        r = mn(t, "a", "atan2"),
6781        o = mn(e, "b", "atan2");
6782    n = Nt(r, o), r = n[0], o = n[1];
6783    var a = Fr(r.shape, o.shape);
6784    return Lt.runKernelFunc(function (t, e) {
6785      var n = t.atan2(r, o);
6786      return e([r, o]), n;
6787    }, {
6788      $a: r,
6789      $b: o
6790    }, function (t, e) {
6791      var n = e[0],
6792          r = e[1];
6793      return {
6794        $a: function () {
6795          var e = po(n.square(), r.square()),
6796              o = t.mul(r.div(e)),
6797              i = Nr(n.shape, a);
6798          return i.length > 0 && (o = o.sum(i)), o.reshape(n.shape);
6799        },
6800        $b: function () {
6801          var e = po(n.square(), r.square()),
6802              o = Qr(t.mul(n.div(e))),
6803              i = Nr(r.shape, a);
6804          return i.length > 0 && (o = o.sum(i)), o.reshape(r.shape);
6805        }
6806      };
6807    });
6808  }
6809}),
6810    yo = An({
6811  divStrict_: function (t, e) {
6812    var n = mn(t, "a", "div"),
6813        r = mn(e, "b", "div");
6814    return E(n.shape, r.shape, "Error in divideStrict: "), n.div(r);
6815  }
6816}),
6817    xo = An({
6818  floorDiv_: function (t, e) {
6819    var n,
6820        r = mn(t, "a", "floorDiv"),
6821        o = mn(e, "b", "floorDiv");
6822    n = Nt(r, o), r = n[0], o = n[1];
6823    var a = Fr(r.shape, o.shape);
6824    return Lt.runKernelFunc(function (t, e) {
6825      var n = t.floorDiv(r, o);
6826      return e([r, o]), n;
6827    }, {
6828      a: r,
6829      b: o
6830    }, function (t, e) {
6831      var n = e[0],
6832          r = e[1];
6833      return {
6834        a: function () {
6835          var e = t.div(r.toFloat()),
6836              o = Nr(n.shape, a);
6837          return o.length > 0 ? e.sum(o).reshape(n.shape) : e;
6838        },
6839        b: function () {
6840          var e = t.mul(n.toFloat()),
6841              o = Nr(r.shape, a);
6842          o.length > 0 && (e = e.sum(o).reshape(r.shape));
6843          var i = r.square();
6844          return e.div(i.toFloat()).neg();
6845        }
6846      };
6847    }, "FloorDiv");
6848  }
6849}),
6850    bo = An({
6851  maximum_: function (t, e) {
6852    var n,
6853        r = mn(t, "a", "maximum"),
6854        o = mn(e, "b", "maximum");
6855    return n = Nt(r, o), r = n[0], o = n[1], "bool" === r.dtype && (r = r.toInt(), o = o.toInt()), Fr(r.shape, o.shape), Lt.runKernelFunc(function (t, e) {
6856      var n = t.maximum(r, o);
6857      return e([r, o]), n;
6858    }, {
6859      a: r,
6860      b: o
6861    }, function (t, e) {
6862      var n = e[0],
6863          r = e[1];
6864      return {
6865        a: function () {
6866          return t.mul(n.greaterEqual(r).toFloat());
6867        },
6868        b: function () {
6869          return t.mul(n.less(r).toFloat());
6870        }
6871      };
6872    }, "Maximum");
6873  }
6874}),
6875    wo = An({
6876  maximumStrict_: function (t, e) {
6877    var n = mn(t, "a", "maximumStrict"),
6878        r = mn(e, "b", "maximumStrict");
6879    return E(n.shape, r.shape, "Error in maximumStrict: "), n.maximum(r);
6880  }
6881}),
6882    Co = An({
6883  minimum_: function (t, e) {
6884    var n,
6885        r = mn(t, "a", "minimum"),
6886        o = mn(e, "b", "minimum");
6887    return n = Nt(r, o), r = n[0], o = n[1], "bool" === r.dtype && (r = r.toInt(), o = o.toInt()), Fr(r.shape, o.shape), Lt.runKernelFunc(function (t, e) {
6888      var n = t.minimum(r, o);
6889      return e([r, o]), n;
6890    }, {
6891      a: r,
6892      b: o
6893    }, function (t, e) {
6894      var n = e[0],
6895          r = e[1];
6896      return {
6897        a: function () {
6898          return t.mul(n.lessEqual(r).toFloat());
6899        },
6900        b: function () {
6901          return t.mul(n.greater(r).toFloat());
6902        }
6903      };
6904    }, "Minimum");
6905  }
6906}),
6907    Eo = An({
6908  minimumStrict_: function (t, e) {
6909    var n = mn(t, "a", "minimumStrict"),
6910        r = mn(e, "b", "minimumStrict");
6911    return E(n.shape, r.shape, "Error in minimumStrict: "), n.minimum(r);
6912  }
6913}),
6914    Ro = An({
6915  mod_: function (t, e) {
6916    var n,
6917        r = mn(t, "a", "mod"),
6918        o = mn(e, "b", "mod");
6919    n = Nt(r, o), r = n[0], o = n[1];
6920    var a = Fr(r.shape, o.shape);
6921    return Lt.runKernelFunc(function (t, e) {
6922      var n = t.mod(r, o);
6923      return e([r, o]), n;
6924    }, {
6925      $a: r,
6926      $b: o
6927    }, function (t, e) {
6928      var n = e[0],
6929          r = e[1];
6930      return {
6931        $a: function () {
6932          var e = Nr(n.shape, a);
6933          return e.length > 0 ? t.sum(e).reshape(n.shape) : t;
6934        },
6935        $b: function () {
6936          var e = t.mul(n.div(r).floor().neg()),
6937              o = Nr(r.shape, a);
6938          return o.length > 0 ? e.sum(o).reshape(r.shape) : e;
6939        }
6940      };
6941    });
6942  }
6943}),
6944    Io = An({
6945  modStrict_: function (t, e) {
6946    var n = mn(t, "a", "modStrict"),
6947        r = mn(e, "b", "modStrict");
6948    return E(n.shape, r.shape, "Error in modStrict: "), n.mod(r);
6949  }
6950}),
6951    ko = An({
6952  mul_: function (t, e) {
6953    var n,
6954        r = mn(t, "a", "mul"),
6955        o = mn(e, "b", "mul");
6956    n = Nt(r, o), r = n[0], o = n[1];
6957    var a = Fr(r.shape, o.shape);
6958    return Lt.runKernelFunc(function (t, e) {
6959      var n = t.multiply(r, o);
6960      return e([r, o]), n;
6961    }, {
6962      a: r,
6963      b: o
6964    }, function (t, e) {
6965      var n = e[0],
6966          r = e[1];
6967      return {
6968        a: function () {
6969          var e = t.mul(r.toFloat()),
6970              o = Nr(n.shape, a);
6971          return o.length > 0 ? e.sum(o).reshape(n.shape) : e;
6972        },
6973        b: function () {
6974          var e = t.mul(n.toFloat()),
6975              o = Nr(r.shape, a);
6976          return o.length > 0 ? e.sum(o).reshape(r.shape) : e;
6977        }
6978      };
6979    }, "Mul");
6980  }
6981}),
6982    So = An({
6983  mulStrict_: function (t, e) {
6984    var n = mn(t, "a", "mul"),
6985        r = mn(e, "b", "mul");
6986    return E(n.shape, r.shape, "Error in multiplyStrict: "), n.mul(r);
6987  }
6988}),
6989    Ao = An({
6990  pow_: function (t, e) {
6991    var n,
6992        r = mn(t, "base", "pow"),
6993        o = mn(e, "exp", "pow");
6994    n = Nt(r, o), r = n[0], o = n[1];
6995    var a = Fr(r.shape, o.shape),
6996        i = [r, o];
6997    return Lt.runKernelFunc(function (t, e) {
6998      var n = t.pow(r, o);
6999      return e([r, o, n]), n;
7000    }, {
7001      a: r,
7002      b: o
7003    }, function (t, e) {
7004      var n = e[0],
7005          r = e[1],
7006          o = e[2];
7007      return {
7008        a: function () {
7009          var e = r.toFloat(),
7010              o = t.mul(e.mul(n.pow(e.sub(On(1))))),
7011              i = Nr(n.shape, a);
7012          return i.length > 0 && (o = o.sum(i)), o.reshape(n.shape);
7013        },
7014        b: function () {
7015          var e = n.greater(0),
7016              i = n.log().where(e, Xn(n)),
7017              s = t.mul(o.mul(i)),
7018              u = Nr(r.shape, a);
7019          return u.length > 0 && (s = s.sum(u)), s.reshape(r.shape);
7020        }
7021      };
7022    }, "Pow", {}, i, [!0]);
7023  }
7024}),
7025    To = An({
7026  powStrict_: function (t, e) {
7027    return E(t.shape, e.shape, "Error in powStrict: "), t.pow(e);
7028  }
7029}),
7030    Do = An({
7031  squaredDifferenceStrict_: function (t, e) {
7032    var n = mn(t, "a", "squaredDifferenceStrict"),
7033        r = mn(e, "b", "squaredDifferenceStrict");
7034    return E(n.shape, r.shape, "Error in squaredDifferenceStrict: "), n.squaredDifference(r);
7035  }
7036}),
7037    No = An({
7038  sub_: function (t, e) {
7039    var n,
7040        r = mn(t, "a", "sub"),
7041        o = mn(e, "b", "sub");
7042    n = Nt(r, o), r = n[0], o = n[1];
7043    var a = Fr(r.shape, o.shape);
7044    return Lt.runKernelFunc(function (t) {
7045      return t.subtract(r, o);
7046    }, {
7047      a: r,
7048      b: o
7049    }, function (t) {
7050      return {
7051        a: function () {
7052          var e = t,
7053              n = Nr(r.shape, a);
7054          return n.length > 0 && (e = e.sum(n)), e.reshape(r.shape);
7055        },
7056        b: function () {
7057          var e = t,
7058              n = Nr(o.shape, a);
7059          return n.length > 0 && (e = e.sum(n)), e.neg().reshape(o.shape);
7060        }
7061      };
7062    }, "Sub");
7063  }
7064}),
7065    Fo = An({
7066  subStrict_: function (t, e) {
7067    var n = mn(t, "a", "subStrict"),
7068        r = mn(e, "b", "subStrict");
7069    return E(n.shape, r.shape, "Error in subStrict: "), n.sub(r);
7070  }
7071});
7072exports.subStrict = Fo;
7073exports.sub = No;
7074exports.squaredDifferenceStrict = Do;
7075exports.powStrict = To;
7076exports.pow = Ao;
7077exports.mulStrict = So;
7078exports.mul = ko;
7079exports.modStrict = Io;
7080exports.mod = Ro;
7081exports.minimumStrict = Eo;
7082exports.minimum = Co;
7083exports.maximumStrict = wo;
7084exports.maximum = bo;
7085exports.floorDiv = xo;
7086exports.divStrict = yo;
7087exports.atan2 = go;
7088exports.addStrict = mo;
7089exports.addN = vo;
7090exports.add = po;
7091
7092var _o = An({
7093  div_: function (t, e) {
7094    var n,
7095        r = mn(t, "a", "div"),
7096        o = mn(e, "b", "div");
7097    if (n = Nt(r, o), r = n[0], o = n[1], "int32" === r.dtype && "int32" === o.dtype) return xo(r, o);
7098    var a = {
7099      a: r,
7100      b: o
7101    };
7102    return Lt.runKernelFunc(function (t, e) {
7103      var n = t.realDivide(r, o);
7104      return e([r, o]), n;
7105    }, a, null, Rr, {});
7106  }
7107});
7108
7109exports.div = _o;
7110
7111function Oo(t, e) {
7112  if (t.rank < 1) throw new Error("tf.gatherND() expects the input to be rank 1 or higher, but the rank was " + t.rank + ".");
7113  if (e.rank < 1) throw new Error("tf.gatherND() expects the indices to be rank 1 or higher, but the rank was " + e.rank + ".");
7114  if ("int32" !== e.dtype) throw new Error("tf.gatherND() expects the indices to be int32 type, but the dtype was " + e.dtype + ".");
7115  if (e.shape[e.rank - 1] > t.rank) throw new Error("index innermost dimension length must be <= tensor rank; saw: " + e.shape[e.rank - 1] + " vs. " + t.rank);
7116  if (0 === t.size) throw new Error("Requested more than 0 entries, but input is empty. Input shape: " + t.shape + ".");
7117
7118  for (var n = e.shape, r = n[n.length - 1], o = 1, a = 0; a < n.length - 1; ++a) o *= n[a];
7119
7120  var i = t.shape,
7121      s = n.slice();
7122  s.pop();
7123  var u = 1;
7124
7125  for (a = r; a < t.rank; ++a) u *= i[a], s.push(i[a]);
7126
7127  var c = $(t.shape).map(function (t) {
7128    return t / u;
7129  }).concat([1]).slice(0, r);
7130  return [s, o, u, c];
7131}
7132
7133var Mo = Object.freeze({
7134  prepareAndValidate: Oo
7135}),
7136    Bo = 30;
7137exports.gather_util = Mo;
7138
7139function Po(t) {
7140  return t <= Bo ? t : Y(t, Math.floor(Math.sqrt(t)));
7141}
7142
7143function Lo(t, e, n) {
7144  var r = e.rank > 1 ? e.shape[e.rank - 1] : 1,
7145      o = e.rank > 1 ? e.rank - 1 : 1,
7146      a = "Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: " + n.shape + ", indices.shape: " + e.shape + ", shape: " + t + ", sliceDim: " + r + ", and batchDim: " + o + ".";
7147  if (n.rank < o) throw new Error(a + " update.rank < " + o + ". ");
7148  if (t.length < r + (n.rank - o)) throw new Error(a + " Output shape length < " + (r + (n.rank - o)));
7149  if (n.rank !== o + t.length - r) throw new Error(a + " update.rank != " + (o + t.length - r));
7150
7151  for (var i = 0; i < o; ++i) if (n.shape[i] !== e.shape[i]) throw new Error(a + " updates.shape[" + i + "] (" + n.shape[i] + ") != indices.shape[" + i + "] (" + e.shape[i] + ").");
7152
7153  for (i = 0; i < n.rank - o; ++i) if (n.shape[i + o] !== t[i + r]) throw new Error(a + " updates.shape[" + (i + o) + "] (" + n.shape[i + o] + ") != shape[" + (i + o) + "] (" + t[i + o] + ")");
7154}
7155
7156function Wo(t, e, n) {
7157  if (e.rank < 1) throw new Error("tf.scatterND() expects the indices to be rank 1 or higher, but the rank was " + e.rank + ".");
7158  if (t.rank < 1) throw new Error("tf.scatterND() expects the updates to be rank 1 or higher, but the rank was " + t.rank + ".");
7159  if ("int32" !== e.dtype) throw new Error("The dtype of 'indices' should be int32, but got dtype: " + e.dtype);
7160  if (n.length < 1) throw new Error("Output rank must be greater or equal to 1, but got shape: " + n);
7161
7162  if (0 === n.length) {
7163    if (0 === e.size) throw new Error("Indices specified for empty output. indices shape: " + e.shape);
7164    if (0 === t.size) throw new Error("Updates specified for empty output. updates shape: " + t.shape);
7165  }
7166
7167  Lo(n, e, t);
7168}
7169
7170function Uo(t, e, n) {
7171  for (var r = e.shape.length, o = r > 1 ? e.shape[r - 1] : 1, a = n.length, i = 1, s = o; s < a; ++s) i *= n[s];
7172
7173  var u = o < 1 ? 1 : o;
7174  return {
7175    sliceRank: o,
7176    numUpdates: k(e.shape) / u,
7177    sliceSize: i,
7178    strides: $(n.slice(0, o)).concat([1]),
7179    outputSize: k(n)
7180  };
7181}
7182
7183var Vo = Object.freeze({
7184  validateUpdateShape: Lo,
7185  validateInput: Wo,
7186  calculateShapes: Uo
7187});
7188exports.scatter_util = Vo;
7189
7190function zo(t, e, n) {
7191  C(t.rank === e.length, function () {
7192    return "Error in slice" + t.rank + "D: Length of begin " + e + " must match the rank of the array (" + t.rank + ").";
7193  }), C(t.rank === n.length, function () {
7194    return "Error in slice" + t.rank + "D: Length of size " + n + " must match the rank of the array (" + t.rank + ").";
7195  });
7196
7197  for (var r = function (r) {
7198    C(e[r] + n[r] <= t.shape[r], function () {
7199      return "Error in slice" + t.rank + "D: begin[" + r + "] + size[" + r + "] (" + (e[r] + n[r]) + ") would overflow input.shape[" + r + "] (" + t.shape[r] + ")";
7200    });
7201  }, o = 0; o < t.rank; ++o) r(o);
7202}
7203
7204function Go(t) {
7205  for (var e = [], n = 0; t > 0;) 1 & t && e.push(n), t /= 2, n++;
7206
7207  return e;
7208}
7209
7210function Ho(t, e, n) {
7211  for (var r = [], o = 0; o < t.length; o++) r[o] = Math.ceil((e[o] - t[o]) / n[o]);
7212
7213  return r;
7214}
7215
7216function qo(t, e, n, r, o) {
7217  var a = e[o],
7218      i = n[o] || 1;
7219  (t & 1 << o || null == a) && (a = i > 0 ? Number.MIN_SAFE_INTEGER : Number.MAX_SAFE_INTEGER);
7220  var s = r[o];
7221  return a < 0 && (a += s), a = x(0, a, s - 1);
7222}
7223
7224function Ko(t, e, n, r, o) {
7225  var a = e[o],
7226      i = n[o] || 1;
7227  (t & 1 << o || null == a) && (a = i > 0 ? Number.MAX_SAFE_INTEGER : Number.MIN_SAFE_INTEGER);
7228  var s = r[o];
7229  return a < 0 && (a += s), a = i > 0 ? x(0, a, s) : x(-1, a, s - 1);
7230}
7231
7232function jo(t, e, n) {
7233  for (var r = n.length, o = 0; o < n.length; o++) if (n[o] > 1) {
7234    r = o;
7235    break;
7236  }
7237
7238  for (o = r + 1; o < n.length; o++) if (e[o] > 0 || n[o] !== t[o]) return !1;
7239
7240  return !0;
7241}
7242
7243function Xo(t, e) {
7244  for (var n = t.length > 0 ? t[t.length - 1] : 1, r = 0; r < t.length - 1; r++) n += t[r] * e[r];
7245
7246  return n;
7247}
7248
7249var Yo = Object.freeze({
7250  assertParamsValid: zo,
7251  maskToAxes: Go,
7252  computeOutShape: Ho,
7253  startForAxis: qo,
7254  stopForAxis: Ko,
7255  isSliceContinous: jo,
7256  computeFlatOffset: Xo
7257});
7258exports.slice_util = Yo;
7259
7260function $o(t) {
7261  return C(X(t), function () {
7262    return "The f passed in grad(f) must be a function";
7263  }), function (e, n) {
7264    var r = mn(e, "x", "tf.grad", null),
7265        o = null != n ? mn(n, "dy", "tf.grad") : null;
7266    return Lt.tidy(function () {
7267      var e = Lt.gradients(function () {
7268        return t(r);
7269      }, [r], o),
7270          n = e.value,
7271          a = e.grads;
7272      return null != o && E(n.shape, o.shape, "The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"), na(a), a[0];
7273    });
7274  };
7275}
7276
7277function Qo(t) {
7278  return C(X(t), function () {
7279    return "The f passed in grads(f) must be a function";
7280  }), function (e, n) {
7281    C(Array.isArray(e), function () {
7282      return "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s";
7283    });
7284    var r = gn(e, "args", "tf.grads", null),
7285        o = null != n ? mn(n, "dy", "tf.grads") : null;
7286    return Lt.tidy(function () {
7287      var e = Lt.gradients(function () {
7288        return t.apply(void 0, r);
7289      }, r, o),
7290          n = e.value,
7291          a = e.grads;
7292      return null != o && E(n.shape, o.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), na(a), a;
7293    });
7294  };
7295}
7296
7297function Jo(t) {
7298  return C(X(t), function () {
7299    return "The f passed in valueAndGrad(f) must be a function";
7300  }), function (e, n) {
7301    C(e instanceof wt, function () {
7302      return "The x passed in valueAndGrad(f)(x) must be a tensor";
7303    }), C(null == n || n instanceof wt, function () {
7304      return "The dy passed in valueAndGrad(f)(x, dy) must be a tensor";
7305    });
7306    var r = Lt.gradients(function () {
7307      return t(e);
7308    }, [e], n),
7309        o = r.grads,
7310        a = r.value;
7311    return na(o), {
7312      grad: o[0],
7313      value: a
7314    };
7315  };
7316}
7317
7318function Zo(t) {
7319  return C(X(t), function () {
7320    return "The f passed in valueAndGrads(f) must be a function";
7321  }), function (e, n) {
7322    C(Array.isArray(e) && e.every(function (t) {
7323      return t instanceof wt;
7324    }), function () {
7325      return "The args passed in valueAndGrads(f)(args) must be array of tensors";
7326    }), C(null == n || n instanceof wt, function () {
7327      return "The dy passed in valueAndGrads(f)(args, dy) must be a tensor";
7328    });
7329    var r = Lt.gradients(function () {
7330      return t.apply(void 0, e);
7331    }, e, n);
7332    return null != n && E(r.value.shape, n.shape, "The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), na(r.grads), r;
7333  };
7334}
7335
7336function ta(t, e) {
7337  C(X(t), function () {
7338    return "The f passed in variableGrads(f) must be a function";
7339  }), C(null == e || Array.isArray(e) && e.every(function (t) {
7340    return t instanceof St;
7341  }), function () {
7342    return "The varList passed in variableGrads(f, varList) must be an array of variables";
7343  });
7344  var n = null != e;
7345  if (!n) for (var r in e = [], Lt.registeredVariables) e.push(Lt.registeredVariables[r]);
7346  var o = n ? e.filter(function (t) {
7347    return !t.trainable;
7348  }) : null,
7349      a = e.length;
7350  C((e = e.filter(function (t) {
7351    return t.trainable;
7352  })).length > 0, function () {
7353    return "variableGrads() expects at least one of the input variables to be trainable, but none of the " + a + " variables is trainable.";
7354  });
7355  var i = Lt.gradients(t, e, null, !0),
7356      s = i.value,
7357      u = i.grads;
7358  C(u.some(function (t) {
7359    return null != t;
7360  }), function () {
7361    return "Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize().";
7362  }), C(0 === s.rank, function () {
7363    return "The f passed in variableGrads(f) must return a scalar, but it returned a rank-" + s.rank + " tensor";
7364  });
7365  var c = {};
7366  return e.forEach(function (t, e) {
7367    null != u[e] && (c[t.name] = u[e]);
7368  }), null != o && o.forEach(function (t) {
7369    return c[t.name] = null;
7370  }), {
7371    value: s,
7372    grads: c
7373  };
7374}
7375
7376function ea(t) {
7377  return Lt.customGrad(t);
7378}
7379
7380function na(t) {
7381  if (t.filter(function (t) {
7382    return null == t;
7383  }).length > 0) throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n    the f you passed encloses all operations that lead from x to y.");
7384}
7385
7386var ra = An({
7387  softmax_: function (t, e) {
7388    void 0 === e && (e = -1);
7389    var n = mn(t, "logits", "softmax", "float32");
7390    if (-1 === e && (e = n.rank - 1), e !== n.rank - 1) throw Error("Softmax along a non-last dimension is not yet supported. Logits was rank " + n.rank + " and dim was " + e);
7391    return Lt.runKernelFunc(function (t, r) {
7392      var o = t.softmax(n, e);
7393      return r([o]), o;
7394    }, {
7395      logits: n
7396    }, function (t, n) {
7397      var r = n[0],
7398          o = t.mul(r);
7399      return {
7400        logits: function () {
7401          return o.sub(o.sum([e], !0).mul(r));
7402        }
7403      };
7404    }, "Softmax", {
7405      dim: e
7406    }, [], [!0]);
7407  }
7408}),
7409    oa = An({
7410  logSoftmax_: function (t, e) {
7411    void 0 === e && (e = -1);
7412    var n = mn(t, "logits", "logSoftmax");
7413    if (-1 === e && (e = n.rank - 1), e !== n.rank - 1) throw Error("Log Softmax along a non-last dimension is not yet supported. Logits was rank " + n.rank + " and axis was " + e);
7414    return ea(function (t, n) {
7415      var r = t.max(e, !0),
7416          o = t.sub(r),
7417          a = o.toFloat().sub(o.exp().sum(e, !0).log());
7418      n([a]);
7419      return {
7420        value: a,
7421        gradFunc: function (t, n) {
7422          var r = n[0].exp();
7423          return t.sub(t.sum(e, !0).mul(r));
7424        }
7425      };
7426    })(n);
7427  }
7428}),
7429    aa = function () {
7430  function t(t, e) {
7431    this.backend = t, this.dataMover = e, this.data = new WeakMap(), this.dataIdsCount = 0;
7432  }
7433
7434  return t.prototype.get = function (t) {
7435    return this.data.has(t) || this.dataMover.moveData(this.backend, t), this.data.get(t);
7436  }, t.prototype.set = function (t, e) {
7437    this.dataIdsCount++, this.data.set(t, e);
7438  }, t.prototype.has = function (t) {
7439    return this.data.has(t);
7440  }, t.prototype.delete = function (t) {
7441    return this.dataIdsCount--, this.data.delete(t);
7442  }, t.prototype.numDataIds = function () {
7443    return this.dataIdsCount;
7444  }, t;
7445}(),
7446    ia = function () {
7447  function t() {}
7448
7449  return t.prototype.time = function (t) {
7450    return sa("time");
7451  }, t.prototype.read = function (t) {
7452    return sa("read");
7453  }, t.prototype.readSync = function (t) {
7454    return sa("readSync");
7455  }, t.prototype.numDataIds = function () {
7456    return sa("numDataIds");
7457  }, t.prototype.disposeData = function (t) {
7458    return sa("disposeData");
7459  }, t.prototype.write = function (t, e, n) {
7460    return sa("write");
7461  }, t.prototype.move = function (t, e, n, r) {
7462    return sa("move");
7463  }, t.prototype.memory = function () {
7464    return sa("memory");
7465  }, t.prototype.floatPrecision = function () {
7466    return sa("floatPrecision");
7467  }, t.prototype.epsilon = function () {
7468    return 32 === this.floatPrecision() ? 1e-7 : 1e-4;
7469  }, t.prototype.batchMatMul = function (t, e, n, r) {
7470    return sa("batchMatMul");
7471  }, t.prototype.fusedBatchMatMul = function (t) {
7472    t.a, t.b, t.transposeA, t.transposeB, t.bias, t.activation, t.preluActivationWeights;
7473    return sa("fusedBatchMatMul");
7474  }, t.prototype.slice = function (t, e, n) {
7475    return sa("slice");
7476  }, t.prototype.stridedSlice = function (t, e, n, r) {
7477    return sa("stridedSlice");
7478  }, t.prototype.unstack = function (t, e) {
7479    return sa("unstack");
7480  }, t.prototype.reverse = function (t, e) {
7481    return sa("reverse");
7482  }, t.prototype.concat = function (t, e) {
7483    return sa("concat");
7484  }, t.prototype.neg = function (t) {
7485    return sa("neg");
7486  }, t.prototype.add = function (t, e) {
7487    return sa("add");
7488  }, t.prototype.addN = function (t) {
7489    return sa("addN");
7490  }, t.prototype.subtract = function (t, e) {
7491    return sa("subtract");
7492  }, t.prototype.multiply = function (t, e) {
7493    return sa("multiply");
7494  }, t.prototype.realDivide = function (t, e) {
7495    return sa("realDivide");
7496  }, t.prototype.floorDiv = function (t, e) {
7497    return sa("floorDiv");
7498  }, t.prototype.sum = function (t, e) {
7499    return sa("sum");
7500  }, t.prototype.prod = function (t, e) {
7501    return sa("prod");
7502  }, t.prototype.unsortedSegmentSum = function (t, e, n) {
7503    return sa("unsortedSegmentSum");
7504  }, t.prototype.argMin = function (t, e) {
7505    return sa("argMin");
7506  }, t.prototype.argMax = function (t, e) {
7507    return sa("argMax");
7508  }, t.prototype.equal = function (t, e) {
7509    return sa("equal");
7510  }, t.prototype.notEqual = function (t, e) {
7511    return sa("notEqual");
7512  }, t.prototype.less = function (t, e) {
7513    return sa("less");
7514  }, t.prototype.lessEqual = function (t, e) {
7515    return sa("lessEqual");
7516  }, t.prototype.greater = function (t, e) {
7517    return sa("greater");
7518  }, t.prototype.greaterEqual = function (t, e) {
7519    return sa("greaterEqual");
7520  }, t.prototype.logicalNot = function (t) {
7521    return sa("logicalNot");
7522  }, t.prototype.logicalAnd = function (t, e) {
7523    return sa("logicalAnd");
7524  }, t.prototype.logicalOr = function (t, e) {
7525    return sa("logicalOr");
7526  }, t.prototype.where = function (t) {
7527    return sa("where");
7528  }, t.prototype.select = function (t, e, n) {
7529    return sa("select");
7530  }, t.prototype.topk = function (t, e, n) {
7531    return sa("topk");
7532  }, t.prototype.min = function (t, e) {
7533    return sa("min");
7534  }, t.prototype.minimum = function (t, e) {
7535    return sa("minimum");
7536  }, t.prototype.mod = function (t, e) {
7537    return sa("mod");
7538  }, t.prototype.max = function (t, e) {
7539    return sa("max");
7540  }, t.prototype.maximum = function (t, e) {
7541    return sa("maximum");
7542  }, t.prototype.all = function (t, e) {
7543    return sa("all");
7544  }, t.prototype.any = function (t, e) {
7545    return sa("any");
7546  }, t.prototype.squaredDifference = function (t, e) {
7547    return sa("squaredDifference");
7548  }, t.prototype.ceil = function (t) {
7549    return sa("ceil");
7550  }, t.prototype.floor = function (t) {
7551    return sa("floor");
7552  }, t.prototype.round = function (t) {
7553    return sa("round");
7554  }, t.prototype.sign = function (t) {
7555    return sa("sign");
7556  }, t.prototype.isNaN = function (t) {
7557    return sa("isNaN");
7558  }, t.prototype.isInf = function (t) {
7559    return sa("isInf");
7560  }, t.prototype.isFinite = function (t) {
7561    return sa("isFinite");
7562  }, t.prototype.pow = function (t, e) {
7563    return sa("pow");
7564  }, t.prototype.exp = function (t) {
7565    return sa("exp");
7566  }, t.prototype.expm1 = function (t) {
7567    return sa("expm1");
7568  }, t.prototype.softmax = function (t, e) {
7569    return sa("softmax");
7570  }, t.prototype.log = function (t) {
7571    return sa("log");
7572  }, t.prototype.log1p = function (t) {
7573    return sa("log1p");
7574  }, t.prototype.sqrt = function (t) {
7575    return sa("sqrt");
7576  }, t.prototype.rsqrt = function (t) {
7577    return sa("rsqrt");
7578  }, t.prototype.square = function (t) {
7579    return sa("square");
7580  }, t.prototype.reciprocal = function (t) {
7581    return sa("reciprocal");
7582  }, t.prototype.relu = function (t) {
7583    return sa("relu");
7584  }, t.prototype.relu6 = function (t) {
7585    return sa("relu6");
7586  }, t.prototype.prelu = function (t, e) {
7587    return sa("prelu");
7588  }, t.prototype.elu = function (t) {
7589    return sa("elu");
7590  }, t.prototype.eluDer = function (t, e) {
7591    return sa("eluDer");
7592  }, t.prototype.selu = function (t) {
7593    return sa("selu");
7594  }, t.prototype.int = function (t) {
7595    return sa("int");
7596  }, t.prototype.clip = function (t, e, n) {
7597    return sa("clip");
7598  }, t.prototype.abs = function (t) {
7599    return sa("abs");
7600  }, t.prototype.complexAbs = function (t) {
7601    return sa("complexAbs");
7602  }, t.prototype.sigmoid = function (t) {
7603    return sa("sigmoid");
7604  }, t.prototype.softplus = function (t) {
7605    return sa("softplus");
7606  }, t.prototype.sin = function (t) {
7607    return sa("sin");
7608  }, t.prototype.cos = function (t) {
7609    return sa("cos");
7610  }, t.prototype.tan = function (t) {
7611    return sa("tan");
7612  }, t.prototype.asin = function (t) {
7613    return sa("asin");
7614  }, t.prototype.acos = function (t) {
7615    return sa("acos");
7616  }, t.prototype.atan = function (t) {
7617    return sa("atan");
7618  }, t.prototype.atan2 = function (t, e) {
7619    return sa("atan2");
7620  }, t.prototype.sinh = function (t) {
7621    return sa("sinh");
7622  }, t.prototype.cosh = function (t) {
7623    return sa("cosh");
7624  }, t.prototype.tanh = function (t) {
7625    return sa("tanh");
7626  }, t.prototype.asinh = function (t) {
7627    return sa("asinh");
7628  }, t.prototype.acosh = function (t) {
7629    return sa("acosh");
7630  }, t.prototype.atanh = function (t) {
7631    return sa("atanh");
7632  }, t.prototype.erf = function (t) {
7633    return sa("erf");
7634  }, t.prototype.step = function (t, e) {
7635    return sa("step");
7636  }, t.prototype.fusedConv2d = function (t) {
7637    t.input, t.filter, t.convInfo, t.bias, t.activation, t.preluActivationWeights;
7638    return sa("fusedConv2d");
7639  }
7639, t.prototype.conv2d = function (t, e, n) {
7640    return sa("conv2d");
7641  }, t.prototype.conv2dDerInput = function (t, e, n) {
7642    return sa("conv2dDerInput");
7643  }, t.prototype.conv2dDerFilter = function (t, e, n) {
7644    return sa("conv2dDerFilter");
7645  }, t.prototype.fusedDepthwiseConv2D = function (t) {
7646    t.input, t.filter, t.convInfo, t.bias, t.activation, t.preluActivationWeights;
7647    return sa("fusedDepthwiseConv2D");
7648  }, t.prototype.depthwiseConv2D = function (t, e, n) {
7649    return sa("depthwiseConv2D");
7650  }, t.prototype.depthwiseConv2DDerInput = function (t, e, n) {
7651    return sa("depthwiseConv2DDerInput");
7652  }, t.prototype.depthwiseConv2DDerFilter = function (t, e, n) {
7653    return sa("depthwiseConv2DDerFilter");
7654  }, t.prototype.conv3d = function (t, e, n) {
7655    return sa("conv3d");
7656  }, t.prototype.conv3dDerInput = function (t, e, n) {
7657    return sa("conv3dDerInput");
7658  }, t.prototype.conv3dDerFilter = function (t, e, n) {
7659    return sa("conv3dDerFilter");
7660  }, t.prototype.maxPool = function (t, e) {
7661    return sa("maxPool");
7662  }, t.prototype.maxPoolBackprop = function (t, e, n, r) {
7663    return sa("maxPoolBackprop");
7664  }, t.prototype.avgPool = function (t, e) {
7665    return sa("avgPool");
7666  }, t.prototype.avgPoolBackprop = function (t, e, n) {
7667    return sa("avgPoolBackprop");
7668  }, t.prototype.avgPool3d = function (t, e) {
7669    return sa("avgPool3d");
7670  }, t.prototype.avgPool3dBackprop = function (t, e, n) {
7671    return sa("avgPool3dBackprop");
7672  }, t.prototype.maxPool3d = function (t, e) {
7673    return sa("maxPool3d");
7674  }, t.prototype.maxPool3dBackprop = function (t, e, n, r) {
7675    return sa("maxPool3dBackprop");
7676  }, t.prototype.reshape = function (t, e) {
7677    return sa("reshape");
7678  }, t.prototype.cast = function (t, e) {
7679    return sa("cast");
7680  }, t.prototype.tile = function (t, e) {
7681    return sa("tile");
7682  }, t.prototype.pad = function (t, e, n) {
7683    return sa("pad");
7684  }, t.prototype.transpose = function (t, e) {
7685    return sa("transpose");
7686  }, t.prototype.gather = function (t, e, n) {
7687    return sa("gather");
7688  }, t.prototype.gatherND = function (t, e) {
7689    return sa("gatherND");
7690  }, t.prototype.scatterND = function (t, e, n) {
7691    return sa("scatterND");
7692  }, t.prototype.batchToSpaceND = function (t, e, n) {
7693    return sa("batchToSpaceND");
7694  }, t.prototype.spaceToBatchND = function (t, e, n) {
7695    return sa("spaceToBatchND");
7696  }, t.prototype.resizeBilinear = function (t, e, n, r) {
7697    return sa("resizeBilinear");
7698  }, t.prototype.resizeBilinearBackprop = function (t, e, n) {
7699    return sa("resizeBilinearBackprop");
7700  }, t.prototype.resizeNearestNeighbor = function (t, e, n, r) {
7701    return sa("resizeNearestNeighbor");
7702  }, t.prototype.resizeNearestNeighborBackprop = function (t, e, n) {
7703    return sa("resizeNearestNeighborBackprop");
7704  }, t.prototype.batchNormalization = function (t, e, n, r, o, a) {
7705    return sa("batchNormalization");
7706  }, t.prototype.localResponseNormalization4D = function (t, e, n, r, o) {
7707    return sa("localResponseNormalization4D");
7708  }, t.prototype.LRNGrad = function (t, e, n, r, o, a, i) {
7709    return sa("LRNGrad");
7710  }, t.prototype.multinomial = function (t, e, n, r) {
7711    return sa("multinomial");
7712  }, t.prototype.oneHot = function (t, e, n, r) {
7713    return sa("oneHot");
7714  }, t.prototype.cumsum = function (t, e, n, r) {
7715    return sa("cumsum");
7716  }, t.prototype.nonMaxSuppression = function (t, e, n, r, o) {
7717    return sa("nonMaxSuppression");
7718  }, t.prototype.fft = function (t) {
7719    return sa("fft");
7720  }, t.prototype.ifft = function (t) {
7721    return sa("ifft");
7722  }, t.prototype.complex = function (t, e) {
7723    return sa("complex");
7724  }, t.prototype.real = function (t) {
7725    return sa("real");
7726  }, t.prototype.imag = function (t) {
7727    return sa("imag");
7728  }, t.prototype.cropAndResize = function (t, e, n, r, o, a) {
7729    return sa("cropAndResize");
7730  }, t.prototype.depthToSpace = function (t, e, n) {
7731    return sa("depthToSpace");
7732  }, t.prototype.split = function (t, e, n) {
7733    return sa("split");
7734  }, t.prototype.sparseToDense = function (t, e, n, r) {
7735    return sa("sparseToDense");
7736  }, t.prototype.diag = function (t) {
7737    return sa("diag");
7738  }, t.prototype.fill = function (t, e, n) {
7739    return sa("fill");
7740  }, t.prototype.onesLike = function (t) {
7741    return sa("onesLike");
7742  }, t.prototype.zerosLike = function (t) {
7743    return sa("zerosLike");
7744  }, t.prototype.linspace = function (t, e, n) {
7745    return sa("linspace");
7746  }, t.prototype.dispose = function () {
7747    return sa("dispose");
7748  }, t;
7749}();
7750
7751exports.KernelBackend = ia;
7752exports.DataStorage = aa;
7753exports.logSoftmax = oa;
7754exports.softmax = ra;
7755
7756function sa(t) {
7757  throw new Error("'" + t + "' not yet implemented or not found in the registry. Did you forget to import the kernel?");
7758}
7759
7760function ua(t, e, n, r, o, a, i) {
7761  void 0 === i && (i = "channelsLast");
7762  var s,
7763      u = da(e),
7764      c = u[0],
7765      l = u[1];
7766  if ("channelsLast" === i) s = [c, l, t[3], t[3]];else {
7767    if ("channelsFirst" !== i) throw new Error("Unknown dataFormat " + i);
7768    s = [c, l, t[1], t[1]];
7769  }
7770  return la(t, s, n, r, o, a, !1, i);
7771}
7772
7773function ca(t, e, n, r, o, a, i) {
7774  void 0 === i && (i = "NDHWC");
7775  var s,
7776      u,
7777      c = pa(e),
7778      l = c[0],
7779      h = c[1],
7780      f = c[2];
7781  if ("NDHWC" === i) u = "channelsLast", s = [l, h, f, t[4], t[4]];else {
7782    if ("NCDHW" !== i) throw new Error("Unknown dataFormat " + i);
7783    u = "channelsFirst", s = [l, h, f, t[1], t[1]];
7784  }
7785  return ha(t, s, n, r, o, !1, u, a);
7786}
7787
7788function la(t, e, n, r, o, a, i, s) {
7789  void 0 === i && (i = !1), void 0 === s && (s = "channelsLast");
7790  var u = [-1, -1, -1, -1],
7791      c = u[0],
7792      l = u[1],
7793      h = u[2],
7794      f = u[3];
7795  if ("channelsLast" === s) c = t[0], l = t[1], h = t[2], f = t[3];else {
7796    if ("channelsFirst" !== s) throw new Error("Unknown dataFormat " + s);
7797    c = t[0], f = t[1], l = t[2], h = t[3];
7798  }
7799
7800  var d,
7801      p = e[0],
7802      v = e[1],
7803      m = e[3],
7804      g = da(n),
7805      y = g[0],
7806      x = g[1],
7807      b = da(r),
7808      w = b[0],
7809      E = b[1],
7810      R = va(p, w),
7811      I = va(v, E),
7812      k = function (t, e, n, r, o, a, i, s) {
7813    var u, c, l;
7814
7815    if ("number" == typeof t) {
7816      u = {
7817        top: t,
7818        bottom: t,
7819        left: t,
7820        right: t,
7821        type: 0 === t ? "VALID" : "NUMBER"
7822      };
7823
7824      var h = function (t, e, n, r, o) {
7825        null == r && (r = fa(t, e, n));
7826        var a = t[0],
7827            i = t[1],
7828            s = ma((a - e + 2 * r) / n + 1, o);
7829        C(A(s), function () {
7830          return "The output # of rows (" + s + ") must be an integer. Change the stride and/or zero pad parameters";
7831        });
7832        var u = ma((i - e + 2 * r) / n + 1, o);
7833        return C(A(u), function () {
7834          return "The output # of columns (" + u + ") must be an integer. Change the stride and/or zero pad parameters";
7835        }), [s, u];
7836      }([e, n], a, r, t, s);
7837
7838      c = h[0], l = h[1];
7839    } else if ("same" === t) {
7840      c = Math.ceil(e / r), l = Math.ceil(n / o);
7841      var f = Math.max(0, (c - 1) * r + a - e),
7842          d = Math.max(0, (l - 1) * o + i - n),
7843          p = Math.floor(f / 2),
7844          v = f - p,
7845          m = Math.floor(d / 2);
7846      u = {
7847        top: p,
7848        bottom: v,
7849        left: m,
7850        right: d - m,
7851        type: "SAME"
7852      };
7853    } else {
7854      if ("valid" !== t) throw Error("Unknown padding parameter: " + t);
7855      u = {
7856        top: 0,
7857        bottom: 0,
7858        left: 0,
7859        right: 0,
7860        type: "VALID"
7861      }, c = Math.ceil((e - a + 1) / r), l = Math.ceil((n - i + 1) / o);
7862    }
7863
7864    return {
7865      padInfo: u,
7866      outHeight: c,
7867      outWidth: l
7868    };
7869  }(o, l, h, y, x, R, I, a),
7870      S = k.padInfo,
7871      T = k.outHeight,
7872      D = k.outWidth,
7873      N = i ? m * f : m;
7874
7875  return "channelsFirst" === s ? d = [c, N, T, D] : "channelsLast" === s && (d = [c, T, D, N]), {
7876    batchSize: c,
7877    dataFormat: s,
7878    inHeight: l,
7879    inWidth: h,
7880    inChannels: f,
7881    outHeight: T,
7882    outWidth: D,
7883    outChannels: N,
7884    padInfo: S,
7885    strideHeight: y,
7886    strideWidth: x,
7887    filterHeight: p,
7888    filterWidth: v,
7889    effectiveFilterHeight: R,
7890    effectiveFilterWidth: I,
7891    dilationHeight: w,
7892    dilationWidth: E,
7893    inShape: t,
7894    outShape: d,
7895    filterShape: e
7896  };
7897}
7898
7899function ha(t, e, n, r, o, a, i, s) {
7900  void 0 === a && (a = !1), void 0 === i && (i = "channelsLast");
7901  var u = [-1, -1, -1, -1, -1],
7902      c = u[0],
7903      l = u[1],
7904      h = u[2],
7905      f = u[3],
7906      d = u[4];
7907  if ("channelsLast" === i) c = t[0], l = t[1], h = t[2], f = t[3], d = t[4];else {
7908    if ("channelsFirst" !== i) throw new Error("Unknown dataFormat " + i);
7909    c = t[0], d = t[1], l = t[2], h = t[3], f = t[4];
7910  }
7911
7912  var p,
7913      v = e[0],
7914      m = e[1],
7915      g = e[2],
7916      y = e[4],
7917      x = pa(n),
7918      b = x[0],
7919      w = x[1],
7920      E = x[2],
7921      R = pa(r),
7922      I = R[0],
7923      k = R[1],
7924      S = R[2],
7925      T = va(v, I),
7926      D = va(m, k),
7927      N = va(g, S),
7928      F = function (t, e, n, r, o, a, i, s, u, c, l) {
7929    var h, f, d, p;
7930
7931    if ("number" == typeof t) {
7932      h = {
7933        top: t,
7934        bottom: t,
7935        left: t,
7936        right: t,
7937        front: t,
7938        back: t,
7939        type: 0 === t ? "VALID" : "NUMBER"
7940      };
7941
7942      var v = function (t, e, n, r, o, a) {
7943        null == o && (o = fa(t, e, r));
7944        var i = t[0],
7945            s = t[1],
7946            u = t[2],
7947            c = ma((i - e + 2 * o) / r + 1, a);
7948        C(A(c), function () {
7949          return "The output # of depths (" + c + ") must be an integer. Change the stride and/or zero pad parameters";
7950        });
7951        var l = ma((s - e + 2 * o) / r + 1, a);
7952        C(A(l), function () {
7953          return "The output # of rows (" + l + ") must be an integer. Change the stride and/or zero pad parameters";
7954        });
7955        var h = ma((u - e + 2 * o) / r + 1, a);
7956        return C(A(h), function () {
7957          return "The output # of columns (" + h + ") must be an integer. Change the stride and/or zero pad parameters";
7958        }), [c, l, h, n];
7959      }([e, n, r, 1], s, 1, o, t, l);
7960
7961      f = v[0], d = v[1], p = v[2];
7962    } else if ("same" === t) {
7963      f = Math.ceil(e / o), d = Math.ceil(n / a), p = Math.ceil(r / i);
7964      var m = (f - 1) * o + s - e,
7965          g = (d - 1) * a + u - n,
7966          y = (p - 1) * i + c - r,
7967          x = Math.floor(m / 2),
7968          b = m - x,
7969          w = Math.floor(g / 2),
7970          E = g - w,
7971          R = Math.floor(y / 2);
7972      h = {
7973        top: w,
7974        bottom: E,
7975        left: R,
7976        right: y - R,
7977        front: x,
7978        back: b,
7979        type: "SAME"
7980      };
7981    } else {
7982      if ("valid" !== t) throw Error("Unknown padding parameter: " + t);
7983      h = {
7984        top: 0,
7985        bottom: 0,
7986        left: 0,
7987        right: 0,
7988        front: 0,
7989        back: 0,
7990        type: "VALID"
7991      }, f = Math.ceil((e - s + 1) / o), d = Math.ceil((n - u + 1) / a), p = Math.ceil((r - c + 1) / i);
7992    }
7993
7994    return {
7995      padInfo: h,
7996      outDepth: f,
7997      outHeight: d,
7998      outWidth: p
7999    };
8000  }(o, l, h, f, b, w, E, T, D, N, s),
8001      _ = F.padInfo,
8002      O = F.outDepth,
8003      M = F.outHeight,
8004      B = F.outWidth,
8005      P = a ? y * d : y;
8006
8007  return "channelsFirst" === i ? p = [c, P, O, M, B] : "channelsLast" === i && (p = [c, O, M, B, P]), {
8008    batchSize: c,
8009    dataFormat: i,
8010    inDepth: l,
8011    inHeight: h,
8012    inWidth: f,
8013    inChannels: d,
8014    outDepth: O,
8015    outHeight: M,
8016    outWidth: B,
8017    outChannels: P,
8018    padInfo: _,
8019    strideDepth: b,
8020    strideHeight: w,
8021    strideWidth: E,
8022    filterDepth: v,
8023    filterHeight: m,
8024    filterWidth: g,
8025    effectiveFilterDepth: T,
8026    effectiveFilterHeight: D,
8027    effectiveFilterWidth: N,
8028    dilationDepth: I,
8029    dilationHeight: k,
8030    dilationWidth: S,
8031    inShape: t,
8032    outShape: p,
8033    filterShape: e
8034  };
8035}
8036
8037function fa(t, e, n, r) {
8038  void 0 === r && (r = 1);
8039  var o = va(e, r);
8040  return Math.floor((t[0] * (n - 1) - n + o) / 2);
8041}
8042
8043function da(t) {
8044  return "number" == typeof t ? [t, t, t] : 2 === t.length ? [t[0], t[1], 1] : t;
8045}
8046
8047function pa(t) {
8048  return "number" == typeof t ? [t, t, t] : t;
8049}
8050
8051function va(t, e) {
8052  return e <= 1 ? t : t + (t - 1) * (e - 1);
8053}
8054
8055function ma(t, e) {
8056  if (!e) return t;
8057
8058  switch (e) {
8059    case "round":
8060      return Math.round(t);
8061
8062    case "ceil":
8063      return Math.ceil(t);
8064
8065    case "floor":
8066      return Math.floor(t);
8067
8068    default:
8069      throw new Error("Unknown roundingMode " + e);
8070  }
8071}
8072
8073function ga(t) {
8074  var e = da(t),
8075      n = e[0],
8076      r = e[1],
8077      o = e[2];
8078  return 1 === n && 1 === r && 1 === o;
8079}
8080
8081function ya(t, e) {
8082  return ga(t) || ga(e);
8083}
8084
8085function xa(t) {
8086  if ("NHWC" === t) return "channelsLast";
8087  if ("NCHW" === t) return "channelsFirst";
8088  throw new Error("Unknown dataFormat " + t);
8089}
8090
8091function ba(t, e, n) {
8092  if ("complex64" === e) {
8093    if ("complex64" === t.dtype) return t.clone();
8094    var r = Gn(t.shape),
8095        o = t.toFloat(),
8096        a = n.complex(o, r);
8097    return r.dispose(), o.dispose(), a;
8098  }
8099
8100  if (!U(t.dtype, e)) return Lt.makeTensorFromDataId(t.dataId, t.shape, e);
8101
8102  if ("complex64" === t.dtype) {
8103    var i = n.real(t);
8104    a = i.cast(e);
8105    return i.dispose(), a;
8106  }
8107
8108  if ("int32" === e) return n.int(t);
8109
8110  if ("bool" === e) {
8111    var s = On(0, t.dtype);
8112    a = n.notEqual(t, s);
8113    return s.dispose(), a;
8114  }
8115
8116  throw new Error("Error in Cast: failed to cast " + t.dtype + " to " + e);
8117}
8118
8119function wa(t, e) {
8120  return Lt.makeTensorFromDataId(t.dataId, e, t.dtype);
8121}
8122
8123function Ca(t, e, n) {
8124  var r = (e - t) / (n - 1),
8125      o = tt(n, "float32");
8126  o[0] = t;
8127
8128  for (var a = 1; a < o.length; a++) o[a] = o[a - 1] + r;
8129
8130  return Mn(o, "float32");
8131}
8132
8133var Ea = Object.freeze({
8134  castTensor: ba,
8135  reshapeTensor: wa,
8136  linspaceImpl: Ca,
8137  upcastType: Tt,
8138  axesAreInnerMostDims: yn,
8139  combineLocations: xn,
8140  computeOutAndReduceShapes: bn,
8141  expandShapeToKeepDim: wn,
8142  assertAxesAreInnerMostDims: Cn,
8143  getAxesPermutation: En,
8144  getUndoAxesPermutation: Rn,
8145  getInnerMostAxes: In,
8146  getBroadcastDims: Dr,
8147  getReductionAxes: Nr,
8148  assertAndGetBroadcastShape: Fr,
8149  assertParamsConsistent: kn,
8150  computeOutShape: Sn,
8151  computePool2DInfo: ua,
8152  computePool3DInfo: ca,
8153  computeConv2DInfo: la,
8154  computeConv3DInfo: ha,
8155  computeDefaultPad: fa,
8156  tupleValuesAreOne: ga,
8157  eitherStridesOrDilationsAreOne: ya,
8158  convertConv2DDataFormat: xa,
8159  PARALLELIZE_THRESHOLD: Bo,
8160  computeOptimalWindowSize: Po
8161});
8162exports.backend_util = Ea;
8163
8164function Ra(t, e) {
8165  if (t.length !== e.length) throw new Error("Cannot merge real and imag arrays of different lengths. real:" + t.length + ", imag: " + e.length + ".");
8166
8167  for (var n = new Float32Array(2 * t.length), r = 0; r < n.length; r += 2) n[r] = t[r / 2], n[r + 1] = e[r / 2];
8168
8169  return n;
8170}
8171
8172function Ia(t, e) {
8173  return {
8174    real: t[2 * e],
8175    imag: t[2 * e + 1]
8176  };
8177}
8178
8179function ka(t, e, n, r) {
8180  t[2 * r] = e, t[2 * r + 1] = n;
8181}
8182
8183function Sa(t, e, n) {
8184  var r = (n ? 2 : -2) * Math.PI * (t / e);
8185  return {
8186    real: Math.cos(r),
8187    imag: Math.sin(r)
8188  };
8189}
8190
8191function Aa(t, e, n) {
8192  var r = function (t, e, n) {
8193    return function (t, e, n) {
8194      var r = 0,
8195          o = t.length,
8196          a = 0,
8197          i = !1;
8198
8199      for (; r < o;) {
8200        var s = n(e, t[a = r + (o - r >>> 1)]);
8201        s > 0 ? r = a + 1 : (o = a, i = !s);
8202      }
8203
8204      return i ? r : -r - 1;
8205    }(t, e, n || Ta);
8206  }(t, e, n),
8207      o = r < 0 ? -(r + 1) : r;
8208
8209  t.splice(o, 0, e);
8210}
8211
8212function Ta(t, e) {
8213  return t > e ? 1 : t < e ? -1 : 0;
8214}
8215
8216function Da(t, e, n, r, o) {
8217  return Fa(t, e, n, r, o, 0).selectedIndices;
8218}
8219
8220function Na(t, e, n, r, o, a) {
8221  var i = Fa(t, e, n, r, o, a, !0);
8222  return i.numValidOutputs.dispose(), {
8223    selectedIndices: i.selectedIndices,
8224    selectedScores: i.selectedScores
8225  };
8226}
8227
8228function Fa(t, e, n, r, o, a, i, s) {
8229  void 0 === i && (i = !1), void 0 === s && (s = !1);
8230
8231  for (var u = Array.from(e).map(function (t, e) {
8232    return {
8233      score: t,
8234      boxIndex: e,
8235      suppressBeginIndex: 0
8236    };
8237  }).filter(function (t) {
8238    return t.score > o;
8239  }).sort(Ma), c = a > 0 ? -.5 / a : 0, l = [], h = []; l.length < n && u.length > 0;) {
8240    var f = u.pop(),
8241        d = f.score,
8242        p = f.boxIndex,
8243        v = f.suppressBeginIndex;
8244    if (d < o) break;
8245
8246    for (var m = !1, g = l.length - 1; g >= v; --g) {
8247      var y = _a(t, p, l[g]);
8248
8249      if (y >= r) {
8250        m = !0;
8251        break;
8252      }
8253
8254      if (f.score = f.score * Oa(r, c, y), f.score <= o) break;
8255    }
8256
8257    f.suppressBeginIndex = l.length, m || (f.score === d ? (l.push(p), h.push(f.score)) : f.score > o && Aa(u, f, Ma));
8258  }
8259
8260  var x = l.length;
8261  return s && (l.fill(0, x), h.fill(0, x)), {
8262    selectedIndices: Mn(l, "int32"),
8263    selectedScores: Mn(h, "float32"),
8264    numValidOutputs: On(x, "int32")
8265  };
8266}
8267
8268function _a(t, e, n) {
8269  var r = t.subarray(4 * e, 4 * e + 4),
8270      o = t.subarray(4 * n, 4 * n + 4),
8271      a = Math.min(r[0], r[2]),
8272      i = Math.min(r[1], r[3]),
8273      s = Math.max(r[0], r[2]),
8274      u = Math.max(r[1], r[3]),
8275      c = Math.min(o[0], o[2]),
8276      l = Math.min(o[1], o[3]),
8277      h = Math.max(o[0], o[2]),
8278      f = Math.max(o[1], o[3]),
8279      d = (s - a) * (u - i),
8280      p = (h - c) * (f - l);
8281  if (d <= 0 || p <= 0) return 0;
8282  var v = Math.max(a, c),
8283      m = Math.max(i, l),
8284      g = Math.min(s, h),
8285      y = Math.min(u, f),
8286      x = Math.max(g - v, 0) * Math.max(y - m, 0);
8287  return x / (d + p - x);
8288}
8289
8290function Oa(t, e, n) {
8291  var r = Math.exp(e * n * n);
8292  return n <= t ? r : 0;
8293}
8294
8295function Ma(t, e) {
8296  return t.score - e.score || t.score === e.score && e.boxIndex - t.boxIndex;
8297}
8298
8299function Ba(t, e, n) {
8300  var r = new Array(t.rank).fill(0),
8301      o = t.shape.slice();
8302  return e.map(function (e) {
8303    o[n] = e;
8304    var a = t.slice(r, o);
8305    return r[n] += e, a;
8306  });
8307}
8308
8309function Pa(t, e) {
8310  for (var n = new Array(t.rank), r = 0; r < n.length; r++) n[r] = t.shape[r] * e[r];
8311
8312  var o = er(n, t.dtype);
8313
8314  for (r = 0; r < o.values.length; ++r) {
8315    for (var a = o.indexToLoc(r), i = new Array(t.rank), s = 0; s < i.length; s++) i[s] = a[s] % t.shape[s];
8316
8317    var u = t.locToIndex(i);
8318    o.values[r] = t.values[u];
8319  }
8320
8321  return o.toTensor();
8322}
8323
8324function La(t, e, n, r, o) {
8325  for (var a = e[e.length - 1], i = [t.length / a, a], s = i[0], u = i[1], c = B(n, s * r), l = B("int32", s * r), h = 0; h < s; h++) {
8326    for (var f = h * u, d = t.subarray(f, f + u), p = [], v = 0; v < d.length; v++) p.push({
8327      value: d[v],
8328      index: v
8329    });
8330
8331    p.sort(function (t, e) {
8332      return e.value - t.value;
8333    });
8334    var m = h * r,
8335        g = c.subarray(m, m + r),
8336        y = l.subarray(m, m + r);
8337
8338    for (v = 0; v < r; v++) g[v] = p[v].value, y[v] = p[v].index;
8339  }
8340
8341  var x = e.slice();
8342  return x[x.length - 1] = r, [Fn(c, x, n), Fn(l, x, "int32")];
8343}
8344
8345function Wa(t, e) {
8346  for (var n = [], r = 0; r < e.length; r++) e[r] && n.push(r);
8347
8348  var o = er(t, "int32"),
8349      a = er([n.length, t.length], "int32");
8350
8351  for (r = 0; r < n.length; r++) {
8352    var i = o.indexToLoc(n[r]),
8353        s = r * t.length;
8354    a.values.set(i, s);
8355  }
8356
8357  return a.toTensor();
8358}
8359
8360var Ua = function (t, e) {
8361  this.outputShape = [], this.outputShape = t, this.variableNames = e.map(function (t, e) {
8362    return "T" + e;
8363  });
8364  var n = [];
8365  this.variableNames.forEach(function (t) {
8366    n.push("float v" + t + " = get" + t + "AtOutCoords();");
8367  });
8368  var r = this.variableNames.map(function (t) {
8369    return "v" + t;
8370  }).join(" + ");
8371  this.userCode = "\n      void main() {\n        " + n.join("\n        ") + "\n\n        float result = " + r + ";\n        setOutput(result);\n      }\n    ";
8372},
8373    Va = function (t, e) {
8374  this.outputShape = [], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t, this.variableNames = e.map(function (t, e) {
8375    return "T" + e;
8376  });
8377  var n = [];
8378  this.variableNames.forEach(function (t) {
8379    n.push("vec4 v" + t + " = get" + t + "AtOutCoords();");
8380  });
8381  var r = this.variableNames.map(function (t) {
8382    return "v" + t;
8383  }).join(" + ");
8384  this.userCode = "\n      void main() {\n        " + n.join("\n        ") + "\n\n        vec4 result = " + r + ";\n        setOutput(result);\n      }\n    ";
8385},
8386    za = function (t, e, n) {
8387  this.variableNames = ["A"];
8388  var r = t.windowSize,
8389      o = t.batchSize,
8390      a = t.inSize,
8391      i = Math.ceil(a / r);
8392  n || this.variableNames.push("bestIndicesA"), this.outputShape = [o, i];
8393  var s = "max" === e ? ">" : "<",
8394      u = n ? "inOffset + i;" : "round(getBestIndicesA(batch, inOffset + i));";
8395  this.userCode = "\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * " + r + ";\n\n        int bestIndex = inOffset;\n        float bestValue = getA(batch, bestIndex);\n\n        for (int i = 0; i < " + r + "; i++) {\n          int inIdx = " + u + ";\n          float candidate = getA(batch, inIdx);\n          if (candidate " + s + " bestValue) {\n            bestValue = candidate;\n            bestIndex = inIdx;\n          }\n        }\n        setOutput(float(bestIndex));\n      }\n    ";
8396};
8397
8398function Ga(t, e) {
8399  return ["x", "y", "z", "w", "u", "v"].slice(0, e).map(function (e) {
8400    return t + "." + e;
8401  });
8402}
8403
8404function Ha(t, e) {
8405  return 1 === e ? [t] : Ga(t, e);
8406}
8407
8408function qa() {
8409  var t, e, n, r, o, a, s, u, c, l;
8410  return 2 === i().getNumber("WEBGL_VERSION") ? (t = "#version 300 es", e = "in", n = "out", r = "in", o = "texture", a = "outputColor", s = "out vec4 outputColor;", u = "\n      bool isnan_custom(float val) {\n        return (val > 0.0 || val < 0.0) ? false : val != 0.0;\n      }\n\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan_custom(val.x),\n          isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n      }\n\n      #define isnan(value) isnan_custom(value)\n    ", c = "", l = "\n      #define round(value) newRound(value)\n      int newRound(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 newRound(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    ") : (t = "", e = "attribute", n = "varying", r = "varying", o = "texture2D", a = "gl_FragColor", s = "", u = "\n      #define isnan(value) isnan_custom(value)\n      bool isnan_custom(float val) {\n        return (val > 0. || val < 1. || val == 0.) ? false : true;\n      }\n      bvec4 isnan_custom(vec4 val) {\n        return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n      }\n    ", c = "\n      uniform float INFINITY;\n\n      bool isinf(float val) {\n        return abs(val) == INFINITY;\n      }\n      bvec4 isinf(vec4 val) {\n        return equal(abs(val), vec4(INFINITY));\n      }\n    ", l = "\n      int round(float value) {\n        return int(floor(value + 0.5));\n      }\n\n      ivec4 round(vec4 value) {\n        return ivec4(floor(value + vec4(0.5)));\n      }\n    "), {
8411    version: t,
8412    attribute: e,
8413    varyingVs: n,
8414    varyingFs: r,
8415    texture2D: o,
8416    output: a,
8417    defineOutput: s,
8418    defineSpecialNaN: u,
8419    defineSpecialInf: c,
8420    defineRound: l
8421  };
8422}
8423
8424function Ka(t, e, n) {
8425  void 0 === n && (n = "index");
8426  var r = $(e);
8427  return r.map(function (e, o) {
8428    return "int " + t[o] + " = " + n + " / " + e + "; " + (o === r.length - 1 ? "int " + t[o + 1] + " = " + n + " - " + t[o] + " * " + e : "index -= " + t[o] + " * " + e) + ";";
8429  }).join("");
8430}
8431
8432function ja(t) {
8433  var e = $(t).map(function (t) {
8434    return t.toString();
8435  });
8436  return "\n  int getFlatIndex(ivec3 coords) {\n    return coords.x * " + e[0] + " + coords.y * " + e[1] + " + coords.z;\n  }\n";
8437}
8438
8439var Xa = "\n  const float FLOAT_MAX = 1.70141184e38;\n  const float FLOAT_MIN = 1.17549435e-38;\n\n  lowp vec4 encode_float(highp float v) {\n    if (isnan(v)) {\n      return vec4(255, 255, 255, 255);\n    }\n\n    highp float av = abs(v);\n\n    if(av < FLOAT_MIN) {\n      return vec4(0.0, 0.0, 0.0, 0.0);\n    } else if(v > FLOAT_MAX) {\n      return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n    } else if(v < -FLOAT_MAX) {\n      return vec4(0.0, 0.0,  128.0, 255.0) / 255.0;\n    }\n\n    highp vec4 c = vec4(0,0,0,0);\n\n    highp float e = floor(log2(av));\n    highp float m = exp2(fract(log2(av))) - 1.0;\n\n    c[2] = floor(128.0 * m);\n    m -= c[2] / 128.0;\n    c[1] = floor(32768.0 * m);\n    m -= c[1] / 32768.0;\n    c[0] = floor(8388608.0 * m);\n\n    highp float ebias = e + 127.0;\n    c[3] = floor(ebias / 2.0);\n    ebias -= c[3] * 2.0;\n    c[2] += floor(ebias) * 128.0;\n\n    c[3] += 128.0 * step(0.0, -v);\n\n    return c / 255.0;\n  }\n";
8440
8441function Ya(t, e, n, r) {
8442  var o = [];
8443  t.forEach(function (t) {
8444    var e = k(t.shapeInfo.logicalShape);
8445    t.shapeInfo.isUniform ? o.push("uniform float " + t.name + (e > 1 ? "[" + e + "]" : "") + ";") : (o.push("uniform sampler2D " + t.name + ";"), o.push("uniform int offset" + t.name + ";"));
8446  });
8447
8448  var a,
8449      i,
8450      s = o.join("\n"),
8451      u = t.map(function (t) {
8452    return function (t, e, n) {
8453      void 0 === n && (n = !1);
8454      var r = "";
8455      r += n ? Qa(t) : $a(t);
8456      var o = t.shapeInfo.logicalShape,
8457          a = e.logicalShape;
8458      o.length <= a.length && (r += n ? function (t, e) {
8459        var n,
8460            r = t.name,
8461            o = r.charAt(0).toUpperCase() + r.slice(1),
8462            a = "get" + o + "AtOutCoords",
8463            i = t.shapeInfo.logicalShape.length,
8464            s = e.logicalShape.length,
8465            u = Dr(t.shapeInfo.logicalShape, e.logicalShape),
8466            c = oi(s),
8467            l = s - i,
8468            h = ["x", "y", "z", "w", "u", "v"];
8469        n = 0 === i ? "" : s < 2 && u.length >= 1 ? "coords = 0;" : u.map(function (t) {
8470          return "coords." + h[t + l] + " = 0;";
8471        }).join("\n");
8472        var f = "";
8473        f = s < 2 && i > 0 ? "coords" : t.shapeInfo.logicalShape.map(function (t, e) {
8474          return "coords." + h[e + l];
8475        }).join(", ");
8476        var d = "return outputValue;",
8477            p = 1 === k(t.shapeInfo.logicalShape),
8478            v = 1 === k(e.logicalShape);
8479
8480        if (1 !== i || p || v) {
8481          if (p && !v) d = 1 === s ? "\n        return vec4(outputValue.x, outputValue.x, 0., 0.);\n      " : "\n        return vec4(outputValue.x);\n      ";else if (u.length) {
8482            var m = i - 2,
8483                g = i - 1;
8484            u.indexOf(m) > -1 && u.indexOf(g) > -1 ? d = "return vec4(outputValue.x);" : u.indexOf(m) > -1 ? d = "return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);" : u.indexOf(g) > -1 && (d = "return vec4(outputValue.xx, outputValue.zz);");
8485          }
8486        } else d = "\n      return vec4(outputValue.xy, outputValue.xy);\n    ";
8487
8488        return "\n    vec4 " + a + "() {\n      " + c + " coords = getOutputCoords();\n      " + n + "\n      vec4 outputValue = get" + o + "(" + f + ");\n      " + d + "\n    }\n  ";
8489      }(t, e) : function (t, e) {
8490        var n = t.name,
8491            r = n.charAt(0).toUpperCase() + n.slice(1),
8492            o = "get" + r + "AtOutCoords",
8493            a = e.texShape,
8494            i = t.shapeInfo.texShape,
8495            s = t.shapeInfo.logicalShape.length,
8496            u = e.logicalShape.length;
8497        if (!t.shapeInfo.isUniform && s === u && null == t.shapeInfo.flatOffset && S(i, a)) return "\n      float " + o + "() {\n        return sampleTexture(" + n + ", resultUV);\n      }\n    ";
8498        var c,
8499            l = oi(u),
8500            h = Dr(t.shapeInfo.logicalShape, e.logicalShape),
8501            f = u - s,
8502            d = ["x", "y", "z", "w", "u", "v"];
8503        c = 0 === s ? "" : u < 2 && h.length >= 1 ? "coords = 0;" : h.map(function (t) {
8504          return "coords." + d[t + f] + " = 0;";
8505        }).join("\n");
8506        var p = "";
8507        p = u < 2 && s > 0 ? "coords" : t.shapeInfo.logicalShape.map(function (t, e) {
8508          return "coords." + d[e + f];
8509        }).join(", ");
8510        return "\n    float " + o + "() {\n      " + l + " coords = getOutputCoords();\n      " + c + "\n      return get" + r + "(" + p + ");\n    }\n  ";
8511      }(t, e));
8512      return r;
8513    }(t, e, r);
8514  }).join("\n"),
8515      c = e.texShape,
8516      l = qa(),
8517      h = function (t) {
8518    return "\n    float sampleTexture(sampler2D textureSampler, vec2 uv) {\n      return " + t.texture2D + "(textureSampler, uv).r;\n    }\n  ";
8519  }(l),
8520      f = function (t) {
8521    return t.version + "\n    precision highp float;\n    precision highp int;\n    precision highp sampler2D;\n    " + t.varyingFs + " vec2 resultUV;\n    " + t.defineOutput + "\n    const vec2 halfCR = vec2(0.5, 0.5);\n\n    struct ivec5\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n    };\n\n    struct ivec6\n    {\n      int x;\n      int y;\n      int z;\n      int w;\n      int u;\n      int v;\n    };\n\n    uniform float NAN;\n    " + t.defineSpecialNaN + "\n    " + t.defineSpecialInf + "\n    " + t.defineRound + "\n\n    int imod(int x, int y) {\n      return x - y * (x / y
8521);\n    }\n\n    int idiv(int a, int b, float sign) {\n      int res = a / b;\n      int mod = imod(a, b);\n      if (sign < 0. && mod != 0) {\n        res -= 1;\n      }\n      return res;\n    }\n\n    //Based on the work of Dave Hoskins\n    //https://www.shadertoy.com/view/4djSRW\n    #define HASHSCALE1 443.8975\n    float random(float seed){\n      vec2 p = resultUV * seed;\n      vec3 p3  = fract(vec3(p.xyx) * HASHSCALE1);\n      p3 += dot(p3, p3.yzx + 19.19);\n      return fract((p3.x + p3.y) * p3.z);\n    }\n\n    " + Ja + "\n    " + Za + "\n    " + ti + "\n  ";
8522  }(l);
8523
8524  return e.isPacked ? (a = function (t, e) {
8525    switch (t.length) {
8526      case 0:
8527        return "\n    int getOutputCoords() {\n      return 0;\n    }\n  ";
8528
8529      case 1:
8530        return function (t, e) {
8531          var n = [Math.ceil(e[0] / 2), Math.ceil(e[1] / 2)];
8532          if (1 === n[0]) return "\n      int getOutputCoords() {\n        return 2 * int(resultUV.x * " + n[1] + ".0);\n      }\n    ";
8533          if (1 === n[1]) return "\n      int getOutputCoords() {\n        return 2 * int(resultUV.y * " + n[0] + ".0);\n      }\n    ";
8534          return "\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(" + n[0] + ", " + n[1] + "));\n      return 2 * (resTexRC.x * " + n[1] + " + resTexRC.y);\n    }\n  ";
8535        }(0, e);
8536
8537      case 2:
8538        return function (t, e) {
8539          var n = [Math.ceil(e[0] / 2), Math.ceil(e[1] / 2)];
8540          if (S(t, e)) return "\n      ivec2 getOutputCoords() {\n        return 2 * ivec2(resultUV.yx * vec2(" + n[0] + ", " + n[1] + "));\n      }\n    ";
8541          var r = Math.ceil(t[1] / 2);
8542          return "\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(" + n[0] + ", " + n[1] + "));\n\n      int index = resTexRC.x * " + n[1] + " + resTexRC.y;\n      int r = 2 * (index / " + r + ");\n      int c = imod(index, " + r + ") * 2;\n\n      return ivec2(r, c);\n    }\n  ";
8543        }(t, e);
8544
8545      case 3:
8546        return n = t, r = e, o = [Math.ceil(r[0] / 2), Math.ceil(r[1] / 2)], a = Math.ceil(n[2] / 2), i = a * Math.ceil(n[1] / 2), "\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(" + o[0] + ", " + o[1] + "));\n      int index = resTexRC.x * " + o[1] + " + resTexRC.y;\n\n      int b = index / " + i + ";\n      index -= b * " + i + ";\n\n      int r = 2 * (index / " + a + ");\n      int c = imod(index, " + a + ") * 2;\n\n      return ivec3(b, r, c);\n    }\n  ";
8547
8548      default:
8549        return function (t, e) {
8550          for (var n = [Math.ceil(e[0] / 2), Math.ceil(e[1] / 2)], r = Math.ceil(t[t.length - 1] / 2), o = r * Math.ceil(t[t.length - 2] / 2), a = o, i = "", s = "b, r, c", u = 2; u < t.length - 1; u++) a *= t[t.length - u - 1], i = "\n      int b" + u + " = index / " + a + ";\n      index -= b" + u + " * " + a + ";\n    " + i, s = "b" + u + ", " + s;
8551
8552          return "\n    ivec" + t.length + " getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(" + n[0] + ", " + n[1] + "));\n      int index = resTexRC.x * " + n[1] + " + resTexRC.y;\n\n      " + i + "\n\n      int b = index / " + o + ";\n      index -= b * " + o + ";\n\n      int r = 2 * (index / " + r + ");\n      int c = imod(index, " + r + ") * 2;\n\n      return ivec" + t.length + "(" + s + ");\n    }\n  ";
8553        }(t, e);
8554    }
8555
8556    var n, r, o, a, i;
8557  }(e.logicalShape, c), i = function (t) {
8558    return "\n    void setOutput(vec4 val) {\n      " + t.output + " = val;\n    }\n  ";
8559  }(l)) : (a = function (t, e) {
8560    switch (t.length) {
8561      case 0:
8562        return "\n    int getOutputCoords() {\n      return 0;\n    }\n  ";
8563
8564      case 1:
8565        return function (t, e) {
8566          if (1 === e[0]) return "\n      int getOutputCoords() {\n        return int(resultUV.x * " + e[1] + ".0);\n      }\n    ";
8567          if (1 === e[1]) return "\n      int getOutputCoords() {\n        return int(resultUV.y * " + e[0] + ".0);\n      }\n    ";
8568          return "\n    int getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(" + e[0] + ", " + e[1] + "));\n      return resTexRC.x * " + e[1] + " + resTexRC.y;\n    }\n  ";
8569        }(0, e);
8570
8571      case 2:
8572        return function (t, e) {
8573          if (S(t, e)) return "\n      ivec2 getOutputCoords() {\n        return ivec2(resultUV.yx * vec2(" + e[0] + ", " + e[1] + "));\n      }\n    ";
8574          if (1 === t[1]) return "\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2(" + e[0] + ", " + e[1] + "));\n        int index = resTexRC.x * " + e[1] + " + resTexRC.y;\n        return ivec2(index, 0);\n      }\n    ";
8575          if (1 === t[0]) return "\n      ivec2 getOutputCoords() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n                               vec2(" + e[0] + ", " + e[1] + "));\n        int index = resTexRC.x * " + e[1] + " + resTexRC.y;\n        return ivec2(0, index);\n      }\n    ";
8576          return "\n    ivec2 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(" + e[0] + ", " + e[1] + "));\n      int index = resTexRC.x * " + e[1] + " + resTexRC.y;\n      int r = index / " + t[1] + ";\n      int c = index - r * " + t[1] + ";\n      return ivec2(r, c);\n    }\n  ";
8577        }(t, e);
8578
8579      case 3:
8580        return n = e, r = Ka(["r", "c", "d"], t), "\n    ivec3 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n                             vec2(" + n[0] + ", " + n[1] + "));\n      int index = resTexRC.x * " + n[1] + " + resTexRC.y;\n      " + r + "\n      return ivec3(r, c, d);\n    }\n  ";
8581
8582      case 4:
8583        return function (t, e) {
8584          var n = Ka(["r", "c", "d", "d2"], t);
8585          return "\n    ivec4 getOutputCoords() {\n      ivec2 resTexRC = ive
8585c2(resultUV.yx *\n        vec2(" + e[0] + ", " + e[1] + "));\n      int index = resTexRC.x * " + e[1] + " + resTexRC.y;\n      " + n + "\n      return ivec4(r, c, d, d2);\n    }\n  ";
8586        }(t, e);
8587
8588      case 5:
8589        return function (t, e) {
8590          var n = Ka(["r", "c", "d", "d2", "d3"], t);
8591          return "\n    ivec5 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx * vec2(" + e[0] + ",\n                             " + e[1] + "));\n\n      int index = resTexRC.x * " + e[1] + " + resTexRC.y;\n\n      " + n + "\n\n      ivec5 outShape = ivec5(r, c, d, d2, d3);\n      return outShape;\n    }\n  ";
8592        }(t, e);
8593
8594      case 6:
8595        return function (t, e) {
8596          var n = Ka(["r", "c", "d", "d2", "d3", "d4"], t);
8597          return "\n    ivec6 getOutputCoords() {\n      ivec2 resTexRC = ivec2(resultUV.yx *\n        vec2(" + e[0] + ", " + e[1] + "));\n      int index = resTexRC.x * " + e[1] + " + resTexRC.y;\n\n      " + n + "\n\n      ivec6 result = ivec6(r, c, d, d2, d3, d4);\n      return result;\n    }\n  ";
8598        }(t, e);
8599
8600      default:
8601        throw new Error(t.length + "-D output sampling is not yet supported");
8602    }
8603
8604    var n, r;
8605  }(e.logicalShape, c), i = function (t) {
8606    return "\n    void setOutput(float val) {\n      " + t.output + " = vec4(val, 0, 0, 0);\n    }\n  ";
8607  }(l)), r && (f += ei), [f, h, i, s, a, u, n].join("\n");
8608}
8609
8610function $a(t) {
8611  var e = t.shapeInfo.logicalShape;
8612
8613  switch (e.length) {
8614    case 0:
8615      return function (t) {
8616        var e = t.name,
8617            n = "get" + e.charAt(0).toUpperCase() + e.slice(1);
8618        if (t.shapeInfo.isUniform) return "float " + n + "() {return " + e + ";}";
8619        var r = t.shapeInfo.texShape,
8620            o = r[0],
8621            a = r[1];
8622        if (1 === o && 1 === a) return "\n      float " + n + "() {\n        return sampleTexture(" + e + ", halfCR);\n      }\n    ";
8623        var i = t.shapeInfo.texShape,
8624            s = i[0],
8625            u = i[1],
8626            c = ni(e);
8627        return "\n    float " + n + "() {\n      vec2 uv = uvFromFlat(" + s + ", " + u + ", " + c + ");\n      return sampleTexture(" + e + ", uv);\n    }\n  ";
8628      }(t);
8629
8630    case 1:
8631      return function (t) {
8632        var e = t.name,
8633            n = "get" + e.charAt(0).toUpperCase() + e.slice(1);
8634        if (t.shapeInfo.isUniform) return "\n      float " + n + "(int index) {\n        " + ri(t) + "\n      }\n    ";
8635        var r = t.shapeInfo.texShape,
8636            o = r[0],
8637            a = r[1];
8638        if (1 === a && 1 === o) return "\n      float " + n + "(int index) {\n        return sampleTexture(" + e + ", halfCR);\n      }\n    ";
8639        var i = ni(e);
8640        if (1 === a) return "\n      float " + n + "(int index) {\n        vec2 uv = vec2(0.5, (float(index + " + i + ") + 0.5) / " + o + ".0);\n        return sampleTexture(" + e + ", uv);\n      }\n    ";
8641        if (1 === o) return "\n      float " + n + "(int index) {\n        vec2 uv = vec2((float(index + " + i + ") + 0.5) / " + a + ".0, 0.5);\n        return sampleTexture(" + e + ", uv);\n      }\n    ";
8642        return "\n    float " + n + "(int index) {\n      vec2 uv = uvFromFlat(" + o + ", " + a + ", index + " + i + ");\n      return sampleTexture(" + e + ", uv);\n    }\n  ";
8643      }(t);
8644
8645    case 2:
8646      return function (t) {
8647        var e = t.shapeInfo.logicalShape,
8648            n = t.name,
8649            r = "get" + n.charAt(0).toUpperCase() + n.slice(1),
8650            o = t.shapeInfo.texShape;
8651
8652        if (null != o && S(e, o)) {
8653          var a = o[0],
8654              i = o[1];
8655          return "\n    float " + r + "(int row, int col) {\n      vec2 uv = (vec2(col, row) + halfCR) / vec2(" + i + ".0, " + a + ".0);\n      return sampleTexture(" + n + ", uv);\n    }\n  ";
8656        }
8657
8658        var s = M(e),
8659            u = s.newShape,
8660            c = s.keptDims,
8661            l = u;
8662
8663        if (l.length < e.length) {
8664          var h = ai(t, l);
8665          return "\n      " + $a(h) + "\n      float " + r + "(int row, int col) {\n        return " + r + "(" + ii(["row", "col"], c) + ");\n      }\n    ";
8666        }
8667
8668        if (t.shapeInfo.isUniform) return "\n      float " + r + "(int row, int col) {\n        int index = round(dot(vec2(row, col), vec2(" + e[1] + ", 1)));\n        " + ri(t) + "\n      }\n    ";
8669        var f = o[0],
8670            d = o[1],
8671            p = ni(n);
8672        if (1 === d) return "\n    float " + r + "(int row, int col) {\n      float index = dot(vec3(row, col, " + p + "), vec3(" + e[1] + ", 1, 1));\n      vec2 uv = vec2(0.5, (index + 0.5) / " + f + ".0);\n      return sampleTexture(" + n + ", uv);\n    }\n  ";
8673        if (1 === f) return "\n    float " + r + "(int row, int col) {\n      float index = dot(vec3(row, col, " + p + "), vec3(" + e[1] + ", 1, 1));\n      vec2 uv = vec2((index + 0.5) / " + d + ".0, 0.5);\n      return sampleTexture(" + n + ", uv);\n    }\n  ";
8674        return "\n  float " + r + "(int row, int col) {\n    // Explicitly use integer operations as dot() only w
8674orks on floats.\n    int index = row * " + e[1] + " + col + " + p + ";\n    vec2 uv = uvFromFlat(" + f + ", " + d + ", index);\n    return sampleTexture(" + n + ", uv);\n  }\n";
8675      }(t);
8676
8677    case 3:
8678      return function (t) {
8679        var e = t.shapeInfo.logicalShape,
8680            n = t.name,
8681            r = "get" + n.charAt(0).toUpperCase() + n.slice(1),
8682            o = e[1] * e[2],
8683            a = e[2],
8684            i = M(e),
8685            s = i.newShape,
8686            u = i.keptDims,
8687            c = s;
8688
8689        if (c.length < e.length) {
8690          var l = ai(t, c);
8691          return "\n        " + $a(l) + "\n        float " + r + "(int row, int col, int depth) {\n          return " + r + "(" + ii(["row", "col", "depth"], u) + ");\n        }\n      ";
8692        }
8693
8694        if (t.shapeInfo.isUniform) return "\n      float " + r + "(int row, int col, int depth) {\n        int index = round(dot(vec3(row, col, depth),\n                          vec3(" + o + ", " + a + ", 1)));\n        " + ri(t) + "\n      }\n    ";
8695        var h = t.shapeInfo.texShape,
8696            f = h[0],
8697            d = h[1],
8698            p = t.shapeInfo.flatOffset;
8699        if (d === o && null == p) return "\n        float " + r + "(int row, int col, int depth) {\n          float texR = float(row);\n          float texC = dot(vec2(col, depth), vec2(" + a + ", 1));\n          vec2 uv = (vec2(texC, texR) + halfCR) /\n                     vec2(" + d + ".0, " + f + ".0);\n          return sampleTexture(" + n + ", uv);\n        }\n      ";
8700        if (d === a && null == p) return "\n    float " + r + "(int row, int col, int depth) {\n      float texR = dot(vec2(row, col), vec2(" + e[1] + ", 1));\n      float texC = float(depth);\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(" + d + ".0, " + f + ".0);\n      return sampleTexture(" + n + ", uv);\n    }\n  ";
8701        var v = ni(n);
8702        return "\n      float " + r + "(int row, int col, int depth) {\n        // Explicitly use integer operations as dot() only works on floats.\n        int index = row * " + o + " + col * " + a + " + depth + " + v + ";\n        vec2 uv = uvFromFlat(" + f + ", " + d + ", index);\n        return sampleTexture(" + n + ", uv);\n      }\n  ";
8703      }(t);
8704
8705    case 4:
8706      return function (t) {
8707        var e = t.shapeInfo.logicalShape,
8708            n = t.name,
8709            r = "get" + n.charAt(0).toUpperCase() + n.slice(1),
8710            o = e[3],
8711            a = e[2] * o,
8712            i = e[1] * a,
8713            s = M(e),
8714            u = s.newShape,
8715            c = s.keptDims;
8716
8717        if (u.length < e.length) {
8718          var l = ai(t, u);
8719          return "\n      " + $a(l) + "\n      float " + r + "(int row, int col, int depth, int depth2) {\n        return " + r + "(" + ii(["row", "col", "depth", "depth2"], c) + ");\n      }\n    ";
8720        }
8721
8722        if (t.shapeInfo.isUniform) return "\n      float " + r + "(int row, int col, int depth, int depth2) {\n        int index = round(dot(vec4(row, col, depth, depth2),\n                          vec4(" + i + ", " + a + ", " + o + ", 1)));\n        " + ri(t) + "\n      }\n    ";
8723        var h = t.shapeInfo.flatOffset,
8724            f = t.shapeInfo.texShape,
8725            d = f[0],
8726            p = f[1];
8727        if (p === i && null == h) return "\n      float " + r + "(int row, int col, int depth, int depth2) {\n        float texR = float(row);\n        float texC =\n            dot(vec3(col, depth, depth2),\n                vec3(" + a + ", " + o + ", 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2(" + p + ".0, " + d + ".0);\n        return sampleTexture(" + n + ", uv);\n      }\n    ";
8728        if (p === o && null == h) return "\n      float " + r + "(int row, int col, int depth, int depth2) {\n        float texR = dot(vec3(row, col, depth),\n                         vec3(" + e[1] * e[2] + ", " + e[2] + ", 1));\n        float texC = float(depth2);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2(" + p + ".0, " + d + ".0);\n        return sampleTexture(" + n + ", uv);\n      }\n    ";
8729        var v = ni(n);
8730        return "\n    float " + r + "(int row, int col, int depth, int depth2) {\n      // Explicitly use integer operations as dot() only w
8730orks on floats.\n      int index = row * " + i + " + col * " + a + " +\n          depth * " + o + " + depth2;\n      vec2 uv = uvFromFlat(" + d + ", " + p + ", index + " + v + ");\n      return sampleTexture(" + n + ", uv);\n    }\n  ";
8731      }(t);
8732
8733    case 5:
8734      return function (t) {
8735        var e = t.shapeInfo.logicalShape,
8736            n = t.name,
8737            r = "get" + n.charAt(0).toUpperCase() + n.slice(1),
8738            o = e[4],
8739            a = e[3] * o,
8740            i = e[2] * a,
8741            s = e[1] * i,
8742            u = M(e),
8743            c = u.newShape,
8744            l = u.keptDims;
8745
8746        if (c.length < e.length) {
8747          var h = ai(t, c);
8748          return "\n      " + $a(h) + "\n      float " + r + "(int row, int col, int depth, int depth2, int depth3) {\n        return " + r + "(" + ii(["row", "col", "depth", "depth2", "depth3"], l) + ");\n      }\n    ";
8749        }
8750
8751        if (t.shapeInfo.isUniform) return "\n      float " + r + "(int row, int col, int depth, int depth2, int depth3) {\n        float index = dot(\n          vec4(row, col, depth, depth2),\n          vec4(" + s + ", " + i + ", " + a + ", " + o + ")) +\n          depth3;\n        " + ri(t) + "\n      }\n    ";
8752        var f = t.shapeInfo.flatOffset,
8753            d = t.shapeInfo.texShape,
8754            p = d[0],
8755            v = d[1];
8756        if (v === s && null == f) return "\n      float " + r + "(int row, int col, int depth, int depth2, int depth3) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n                         vec4(" + i + ", " + a + ", " + o + ", 1));\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2(" + v + ".0, " + p + ".0);\n        return sampleTexture(" + n + ", uv);\n      }\n    ";
8757        if (v === o && null == f) return "\n      float " + r + "(int row, int col, int depth, int depth2, int depth3) {\n        float texR = dot(\n          vec4(row, col, depth, depth2),\n          vec4(" + e[1] * e[2] * e[3] + ",\n               " + e[2] * e[3] + ", " + e[3] + ", 1));\n        int texC = depth3;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2(" + v + ".0, " + p + ".0);\n        return sampleTexture(" + n + ", uv);\n      }\n    ";
8758        var m = ni(n);
8759        return "\n    float " + r + "(int row, int col, int depth, int depth2, int depth3) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * " + s + " + col * " + i + " + depth * " + a + " +\n          depth2 * " + o + " + depth3 + " + m + ";\n      vec2 uv = uvFromFlat(" + p + ", " + v + ", index);\n      return sampleTexture(" + n + ", uv);\n    }\n  ";
8760      }(t);
8761
8762    case 6:
8763      return function (t) {
8764        var e = t.shapeInfo.logicalShape,
8765            n = t.name,
8766            r = "get" + n.charAt(0).toUpperCase() + n.slice(1),
8767            o = M(e),
8768            a = o.newShape,
8769            i = o.keptDims;
8770
8771        if (a.length < e.length) {
8772          var s = ai(t, a);
8773          return "\n      " + $a(s) + "\n      float " + r + "(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        return " + r + "(" + ii(["row", "col", "depth", "depth2", "depth3", "depth4"], i) + ");\n      }\n    ";
8774        }
8775
8776        var u = e[5],
8777            c = e[4] * u,
8778            l = e[3] * c,
8779            h = e[2] * l,
8780            f = e[1] * h;
8781        if (t.shapeInfo.isUniform) return "\n      float " + r + "(int row, int col, int depth,\n                  int depth2, int depth3, int depth4) {\n        int index = round(dot(\n          vec4(row, col, depth, depth2),\n          vec4(" + f + ", " + h + ", " + l + ", " + c + ")) +\n          dot(\n            vec2(depth3, depth4),\n            vec2(" + u + ", 1)));\n        " + ri(t) + "\n      }\n    ";
8782        var d = t.shapeInfo.flatOffset,
8783            p = t.shapeInfo.texShape,
8784            v = p[0],
8785            m = p[1];
8786        if (m === f && null == d) return "\n      float " + r + "(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        int texR = row;\n        float texC = dot(vec4(col, depth, depth2, depth3),\n          vec4(" + h + ", " + l + ", " + c + ", " + u + ")) +\n               float(depth4);\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                   vec2(" + m + ".0, " + v + ".0);\n        return sampleTexture(" + n + ", uv);\n      }\n    ";
8787        if (m === u && null == d) return "\n      float " + r + "(int row, int col, int depth,\n                    int depth2, int depth3, int depth4) {\n        float texR = dot
8787(vec4(row, col, depth, depth2),\n          vec4(" + e[1] * e[2] * e[3] * e[4] + ",\n               " + e[2] * e[3] * e[4] + ",\n               " + e[3] * e[4] + ",\n               " + e[4] + ")) + float(depth3);\n        int texC = depth4;\n        vec2 uv = (vec2(texC, texR) + halfCR) /\n                  vec2(" + m + ".0, " + v + ".0);\n        return sampleTexture(" + n + ", uv);\n      }\n    ";
8788        var g = ni(n);
8789        return "\n    float " + r + "(int row, int col, int depth,\n                  int depth2, int depth3, int depth4) {\n      // Explicitly use integer operations as dot() only works on floats.\n      int index = row * " + f + " + col * " + h + " + depth * " + l + " +\n          depth2 * " + c + " + depth3 * " + u + " + depth4 + " + g + ";\n      vec2 uv = uvFromFlat(" + v + ", " + m + ", index);\n      return sampleTexture(" + n + ", uv);\n    }\n  ";
8790      }(t);
8791
8792    default:
8793      throw new Error(e.length + "-D input sampling is not yet supported");
8794  }
8795}
8796
8797function Qa(t) {
8798  var e, n, r;
8799
8800  switch (t.shapeInfo.logicalShape.length) {
8801    case 0:
8802      return e = t.name, n = "get" + e.charAt(0).toUpperCase() + e.slice(1), r = qa(), "\n    vec4 " + n + "() {\n      return " + r.texture2D + "(" + e + ", halfCR);\n    }\n  ";
8803
8804    case 1:
8805      return function (t) {
8806        var e = t.name,
8807            n = "get" + e.charAt(0).toUpperCase() + e.slice(1),
8808            r = t.shapeInfo.texShape,
8809            o = [Math.ceil(r[0] / 2), Math.ceil(r[1] / 2)],
8810            a = qa();
8811        return "\n    vec4 " + n + "(int index) {\n      vec2 uv = packedUVfrom1D(\n        " + o[0] + ", " + o[1] + ", index);\n      return " + a.texture2D + "(" + e + ", uv);\n    }\n  ";
8812      }(t);
8813
8814    case 2:
8815      return function (t) {
8816        var e = t.shapeInfo.logicalShape,
8817            n = t.name,
8818            r = "get" + n.charAt(0).toUpperCase() + n.slice(1),
8819            o = t.shapeInfo.texShape,
8820            a = o[0],
8821            i = o[1],
8822            s = qa();
8823        if (null != o && S(e, o)) return "\n      vec4 " + r + "(int row, int col) {\n        vec2 uv = (vec2(col, row) + halfCR) / vec2(" + i + ".0, " + a + ".0);\n\n        return " + s.texture2D + "(" + n + ", uv);\n      }\n    ";
8824        var u = [Math.ceil(o[0] / 2), Math.ceil(o[1] / 2)],
8825            c = Math.ceil(e[1] / 2);
8826        return "\n    vec4 " + r + "(int row, int col) {\n      vec2 uv = packedUVfrom2D(" + c + ", " + u[0] + ", " + u[1] + ", row, col);\n      return " + s.texture2D + "(" + n + ", uv);\n    }\n  ";
8827      }(t);
8828
8829    case 3:
8830      return function (t) {
8831        var e = t.shapeInfo.logicalShape,
8832            n = t.name,
8833            r = "get" + n.charAt(0).toUpperCase() + n.slice(1),
8834            o = t.shapeInfo.texShape,
8835            a = [Math.ceil(o[0] / 2), Math.ceil(o[1] / 2)];
8836
8837        if (1 === e[0]) {
8838          var i = e.slice(1),
8839              s = ai(t, i);
8840          return "\n        " + Qa(s) + "\n        vec4 " + r + "(int b, int row, int col) {\n          return " + r + "(" + ii(["b", "row", "col"], [1, 2]) + ");\n        }\n      ";
8841        }
8842
8843        var u = a[0],
8844            c = a[1],
8845            l = Math.ceil(e[2] / 2),
8846            h = l * Math.ceil(e[1] / 2),
8847            f = qa();
8848        return "\n    vec4 " + r + "(int b, int row, int col) {\n      vec2 uv = packedUVfrom3D(\n        " + u + ", " + c + ", " + h + ", " + l + ", b, row, col);\n      return " + f.texture2D + "(" + n + ", uv);\n    }\n  ";
8849      }(t);
8850
8851    default:
8852      return function (t) {
8853        for (var e = t.shapeInfo.logicalShape, n = e.length, r = t.name, o = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = t.shapeInfo.texShape, i = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)], s = i[0], u = i[1], c = Math.ceil(e[n - 1] / 2), l = c * Math.ceil(e[n - 2] / 2), h = "int b, int row, int col", f = "b * " + l + " + (row / 2) * " + c + " + (col / 2)", d = 2; d < n - 1; d++) h = "int b" + d + ", " + h, l *= e[n - d - 1], f = "b" + d + " * " + l + " + " + f;
8854
8855        var p = qa();
8856        return "\n    vec4 " + o + "(" + h + ") {\n      int index = " + f + ";\n      int texR = index / " + u + ";\n      int texC = index - texR * " + u + ";\n      vec2 uv = (vec2(texC, texR) + halfCR) / vec2(" + u + ", " + s + ");\n      return " + p.texture2D + "(" + r + ", uv);\n    }\n  ";
8857      }(t);
8858  }
8859}
8860
8861var Ja = "\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n  int texR = index / texNumC;\n  int texC = index - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n  int texelIndex = index / 2;\n  int texR = texelIndex / texNumC;\n  int texC = texelIndex - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",
8862    Za = "\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n  int texNumC, int row, int col) {\n  int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n  int texR = texelIndex / texNumC;\n  int texC = texelIndex - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",
8863    ti = "\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n    int texelsInBatch, int texelsInLogicalRow, int b,\n    int row, int col) {\n  int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n  int texR = index / texNumC;\n  int texC = index - texR * texNumC;\n  return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",
8864    ei = "\n  float getChannel(vec4 frag, vec2 innerDims) {\n    vec2 modCoord = mod(innerDims, 2.);\n    return modCoord.x == 0. ?\n      (modCoord.y == 0. ? frag.r : frag.g) :\n      (modCoord.y == 0. ? frag.b : frag.a);\n  }\n  float getChannel(vec4 frag, int dim) {\n    float modCoord = mod(float(dim), 2.);\n    return modCoord == 0. ? frag.r : frag.g;\n  }\n";
8865
8866function ni(t) {
8867  return "offset" + t;
8868}
8869
8870function ri(t) {
8871  var e = t.name,
8872      n = k(t.shapeInfo.logicalShape);
8873  return n < 2 ? "return " + e + ";" : "\n    for (int i = 0; i < " + n + ";
8873 i++) {\n      if (i == index) {\n        return " + e + "[i];\n      }\n    }\n  ";
8874}
8875
8876function oi(t) {
8877  if (t <= 1) return "int";
8878  if (2 === t) return "ivec2";
8879  if (3 === t) return "ivec3";
8880  if (4 === t) return "ivec4";
8881  if (5 === t) return "ivec5";
8882  if (6 === t) return "ivec6";
8883  throw Error("GPU for rank " + t + " is not yet supported");
8884}
8885
8886function ai(t, e) {
8887  var n = JSON.parse(JSON.stringify(t));
8888  return n.shapeInfo.logicalShape = e, n;
8889}
8890
8891function ii(t, e) {
8892  return e.map(function (e) {
8893    return t[e];
8894  }).join(", ");
8895}
8896
8897var si = function (t, e, n, r) {
8898  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, C(t.length > 2, function () {
8899    return "Packed arg" + (n.charAt(0).toUpperCase() + n.slice(1)) + " supports only inputs with rank above 2.";
8900  });
8901  var o = t[t.length - 1],
8902      a = Math.ceil(o / e);
8903  this.outputShape = t.slice(0, -1), a > 1 && this.outputShape.push(a), r || this.variableNames.push("bestIndicesA");
8904  var i,
8905      s,
8906      u = this.outputShape,
8907      c = u.length,
8908      l = oi(c),
8909      h = Ha("coords", c);
8910
8911  if (1 === a) {
8912    var f = oi(s = c + 1);
8913    i = "\n        " + f + " sourceLocR = " + f + "(" + h.join() + ", 0);\n        ++" + h[c - 1] + ";\n        " + f + " sourceLocG = " + f + "(" + h.join() + ", 0);\n        ++" + h[c - 2] + ";\n        " + f + " sourceLocA = " + f + "(" + h.join() + ", 0);\n        --" + h[c - 1] + ";\n        " + f + " sourceLocB = " + f + "(" + h.join() + ", 0);\n        --" + h[c - 2] + ";";
8914  } else s = c, i = "\n        " + l + " sourceLocR = coords;\n        ++" + h[c - 1] + ";\n        " + l + " sourceLocG = coords;\n        ++" + h[c - 2] + ";\n        " + l + " sourceLocA = coords;\n        --" + h[c - 1] + ";\n        " + l + " sourceLocB = coords;\n        --" + h[c - 2] + ";";
8915
8916  var d = ["x", "y", "z", "w", "u", "v"].slice(0, s),
8917      p = "." + d[s - 1],
8918      v = d.map(function (t) {
8919    return "int " + t;
8920  }),
8921      m = Ha("sourceLocR", s - 1).concat("inIdx.r"),
8922      g = Ha("sourceLocG", s - 1).concat("inIdx.g"),
8923      y = Ha("sourceLocB", s - 1).concat("inIdx.b"),
8924      x = Ha("sourceLocA", s - 1).concat("inIdx.a"),
8925      b = "max" === n ? "greaterThan" : "lessThan",
8926      w = r ? "" : "\n          inIdx = round(vec4(getBestIndicesAChannel(" + m.join() + "),\n                             getBestIndicesAChannel(" + g.join() + "),\n                             getBestIndicesAChannel(" + y.join() + "),\n                             getBestIndicesAChannel(" + x.join() + ")));",
8927      E = "vec4(\n            getAChannel(" + m.join() + "),\n            hasNextCol ? getAChannel(" + g.join() + ") : 0.,\n            hasNextRow ? getAChannel(" + y.join() + ") : 0.,\n            hasNextRow && hasNextCol ? getAChannel(" + x.join() + ") : 0.)",
8928      R = r ? "" : "\n      float getBestIndicesAChannel(" + v.join() + ") {\n        return getChannel(getBestIndicesA(" + d.join() + "),\n                                          vec2(" + d.slice(-2).join() + "));\n      }";
8929  this.userCode = "\n      float getAChannel(" + v.join() + ") {\n        return getChannel(getA(" + d.join() + "),\n                               vec2(" + d.slice(-2).join() + "));\n      }\n      " + R + "\n      void main() {\n        " + l + " coords = getOutputCoords();\n        bool hasNextCol = " + h[c - 1] + " < " + (u[c - 1] - 1) + ";\n        bool hasNextRow = " + h[c - 2] + " < " + (u[c - 2] - 1) + ";\n        " + i + "\n        ivec4 srcIdx = ivec4(sourceLocR" + p + ", sourceLocG" + p + ",\n          sourceLocB" + p + ", sourceLocA" + p + ") * " + e + ";\n        ivec4 inIdx = srcIdx;\n        vec4 bestIndex = vec4(inIdx);\n        vec4 bestValue = " + E + ";\n\n        for (int i = 0; i < " + e + "; i++) {\n          inIdx = srcIdx;\n          " + w + "\n          vec4 candidate = " + E + ";\n          bvec4 nan = isnan(candidate);\n          bvec4 replace = bvec4(\n            vec4(" + b + "(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n          bestValue = vec4(replace.x  ? candidate.x : bestValue.x,\n                           replace.y  ? candidate.y : bestValue.y,\n                           replace.z  ? candidate.z : bestValue.z,\n                           replace.w  ? candidate.w : bestValue.w);\n          bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n          srcIdx++;\n        }\n        setOutput(bestIndex);\n      }\n    ";
8930},
8931    ui = function (t) {
8932  this.variableNames = ["dy"], this.outputShape = t.inShape;
8933  var e = t.filterHeight,
8934      n = t.filterWidth,
8935      r = t.strideHeight,
8936      o = t.strideWidth,
8937      a = t.dilationHeight,
8938      i = t.dilationWidth,
8939      s = t.effectiveFilterHeight,
8940      u = t.effectiveFilterWidth,
8941      c = s - 1 - t.padInfo.top,
8942      l = u - 1 - t.padInfo.left,
8943      h = 1 / (e * n);
8944  this.userCode = "\n      const ivec2 pads = ivec2(" + c + ", " + l + ");\n      const float avgMultiplier = float(" + h + ");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < " + s + ";\n            wR += " + a + ") {\n          float dyR = float(dyRCorner + wR) / " + r + ".0;\n\n          if (dyR < 0.0 || dyR >= " + t.outHeight + ".0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          for (int wC = 0; wC < " + u + ";\n            wC+= " + i + ") {\n            float dyC = float(dyCCorner + wC) / " + o + ".0;\n\n            if (dyC < 0.0 || dyC >= " + t.outWidth + ".0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            float dyValue = getDy(b, idyR, idyC, d);\n\n            dotProd += dyValue * avgMultiplier;\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
8945},
8946    ci = function (t) {
8947  this.variableNames = ["dy"], this.outputShape = t.inShape;
8948  var e = t.filterDepth,
8949      n = t.filterHeight,
8950      r = t.filterWidth,
8951      o = t.strideDepth,
8952      a = t.strideHeight,
8953      i = t.strideWidth,
8954      s = t.dilationDepth,
8955      u = t.dilationHeight,
8956      c = t.dilationWidth,
8957      l = t.effectiveFilterDepth,
8958      h = t.effectiveFilterHeight,
8959      f = t.effectiveFilterWidth,
8960      d = l - 1 - t.padInfo.front,
8961      p = h - 1 - t.padInfo.top,
8962      v = f - 1 - t.padInfo.left,
8963      m = 1 / (e * n * r);
8964  this.userCode = "\n      const ivec3 pads = ivec3(" + d + ", " + p + ", " + v + ");\n      const float avgMultiplier = float(" + m + ");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n        // dx(x
vendor: 4,386 bytes, lines 8964-8994
8964D, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < " + l + ";\n            wD += " + s + ") {\n          float dyD = float(dyDCorner + wD) / " + o + ".0;\n\n          if (dyD < 0.0 || dyD >= " + t.outDepth + ".0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < " + h + ";\n              wR += " + u + ") {\n            float dyR = float(dyRCorner + wR) / " + a + ".0;\n\n            if (dyR < 0.0 || dyR >= " + t.outHeight + ".0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < " + f + ";\n                wC += " + c + ") {\n              float dyC = float(dyCCorner + wC) / " + i + ".0;\n\n              if (dyC < 0.0 || dyC >= " + t.outWidth + ".0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n              dotProd += dyValue * avgMultiplier;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
8965},
8966    li = function (t, e, n, r, o, a) {
8967  this.outputShape = [], this.variableNames = ["x", "mean", "variance"], Fr(t, e), Fr(t, n);
8968  var i = "0.0";
8969  null != r && (Fr(t, r), this.variableNames.push("offset"), i = "getOffsetAtOutCoords()");
8970  var s = "1.0";
8971  null != o && (Fr(t, o), this.variableNames.push("scale"), s = "getScaleAtOutCoords()"), this.outputShape = t, this.userCode = "\n      void main() {\n        float x = getXAtOutCoords();\n        float mean = getMeanAtOutCoords();\n        float variance = getVarianceAtOutCoords();\n        float offset = " + i + ";\n        float scale = " + s + ";\n        float inv = scale * inversesqrt(variance + float(" + a + "));\n        setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n      }\n    ";
8972},
8973    hi = function (t, e, n, r, o, a) {
8974  this.packedInputs = !0, this.packedOutput = !0, this.variableNames = ["x", "mean", "variance"], Fr(t, e), Fr(t, n);
8975  var i = "vec4(0.0)";
8976  null != r && (Fr(t, r), this.variableNames.push("offset"), i = "getOffsetAtOutCoords()");
8977  var s = "vec4(1.0)";
8978  null != o && (Fr(t, o), this.variableNames.push("scale"), s = "getScaleAtOutCoords()"), this.outputShape = t, this.userCode = "\n      void main() {\n        vec4 offset = " + i + ";\n        vec4 scale = " + s + ";\n\n        vec4 x = getXAtOutCoords();\n        vec4 mean = getMeanAtOutCoords();\n        vec4 variance = getVarianceAtOutCoords();\n\n        vec4 inv = scale * inversesqrt(variance + vec4(" + a + "));\n\n        setOutput((x - mean) * inv + offset);\n      }\n    ";
8979},
8980    fi = "return areal * breal - aimag * bimag;",
8981    di = "return areal * bimag + aimag * breal;",
8982    pi = function (t, e, n) {
8983  this.variableNames = ["AReal", "AImag", "BReal", "BImag"], this.outputShape = Fr(e, n), this.userCode = "\n      float binaryOpComplex(\n          float areal, float aimag, float breal, float bimag) {\n        " + t + "\n      }\n\n      void main() {\n        float areal = getARealAtOutCoords();\n        float aimag = getAImagAtOutCoords();\n        float breal = getBRealAtOutCoords();\n        float bimag = getBImagAtOutCoords();\n        setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n      }\n    ";
8984},
8985    vi = "return a + b;",
8986    mi = "return a - b;",
8987    gi = "return a * b;",
8988    yi = "\nif (a == b) {\n  return 1.0;\n};\nreturn a / b;",
8989    xi = "return (a < 0.) ? b * a : a;",
8990    bi = function (t, e, n) {
8991  this.variableNames = ["A", "B"], this.outputShape = Fr(e, n), this.userCode = "\n      float binaryOperation(float a, float b) {\n        " + t + "\n      }\n\n      void main() {\n        float a = getAAtOutCoords();\n        float b = getBAtOutCoords();\n        setOutput(binaryOperation(a, b));\n      }\n    ";
8992},
8993    wi = "\n  // vec4 one = vec4(equal(a, b));\n  // return one + (vec4(1.0) - one) * a / b;\n  vec4 result = a / b;\n  if(a.x == b.x) {\n    result.x = 1.;\n  }\n  if(a.y == b.y) {\n    result.y = 1.;\n  }\n  if(a.z == b.z) {\n    result.z = 1.;\n  }\n  if(a.w == b.w) {\n    result.w = 1.;\n  }\n\n  return result;\n",
8994    Ci = "\n  vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));
8994\n  return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",
8995    Ei = function (t, e, n, r) {
8996  void 0 === r && (r = !1), this.variableNames = ["A", "B"], this.supportsBroadcasting = !0, this.packedInputs = !0, this.packedOutput = !0, this.outputShape = Fr(e, n);
8997  var o = this.outputShape.length,
8998      a = "";
8999  if (r) if (0 === o || 1 === k(this.outputShape)) a = "\n          result.y = 0.;\n          result.z = 0.;\n          result.w = 0.;\n        ";else if (a = "\n          " + oi(o) + " coords = getOutputCoords();\n        ", 1 === o) a += "\n            result.y = (coords + 1) >= " + this.outputShape[0] + " ? 0. : result.y;\n            result.z = 0.;\n            result.w = 0.;\n          ";else {
9000    var i = Ha("coords", o);
9001    a += "\n            bool nextRowOutOfBounds =\n              (" + i[o - 2] + " + 1) >= " + this.outputShape[o - 2] + ";\n            bool nextColOutOfBounds =\n              (" + i[o - 1] + " + 1) >= " + this.outputShape[o - 1] + ";\n            result.y = nextColOutOfBounds ? 0. : result.y;\n            result.z = nextRowOutOfBounds ? 0. : result.z;\n            result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n          ";
9002  }
9003  this.userCode = "\n      vec4 binaryOperation(vec4 a, vec4 b) {\n        " + t + "\n      }\n\n      void main() {\n        vec4 a = getAAtOutCoords();\n        vec4 b = getBAtOutCoords();\n\n        vec4 result = binaryOperation(a, b);\n        " + a + "\n\n        setOutput(result);\n      }\n    ";
9004},
9005    Ri = function () {
9006  function t(t) {
9007    this.variableNames = ["A"], this.outputShape = t, this.userCode = "\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        float value = getAAtOutCoords();\n        if (isnan(value)) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, minVal, maxVal));\n      }\n    ";
9008  }
9009
9010  return t.prototype.getCustomSetupFunc = function (t, e) {
9011    var n = this;
9012    return function (r, o) {
9013      null == n.minLoc && (n.minLoc = r.getUniformLocationNoThrow(o, "minVal"), n.maxLoc = r.getUniformLocationNoThrow(o, "maxVal")), r.gl.uniform1f(n.minLoc, t), r.gl.uniform1f(n.maxLoc, e);
9014    };
9015  }, t;
9016}(),
9017    Ii = function () {
9018  function t(t) {
9019    this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t, this.userCode = "\n      uniform float minVal;\n      uniform float maxVal;\n\n      void main() {\n        vec4 value = getAAtOutCoords();\n\n        if (any(isnan(value))) {\n          setOutput(value);\n          return;\n        }\n\n        setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n      }\n    ";
9020  }
9021
9022  return t.prototype.getCustomSetupFunc = function (t, e) {
9023    var n = this;
9024    return function (r, o) {
9025      null == n.minLoc && (n.minLoc = r.getUniformLocationNoThrow(o, "minVal"), n.maxLoc = r.getUniformLocationNoThrow(o, "maxVal")), r.gl.uniform1f(n.minLoc, t), r.gl.uniform1f(n.maxLoc, e);
9026    };
9027  }, t;
9028}(),
9029    ki = function (t) {
9030  this.variableNames = ["real", "imag"], this.outputShape = t, this.userCode = "\n      void main() {\n        float re = abs(getRealAtOutCoords());\n        float im = abs(getImagAtOutCoords());\n        float mx = max(re, im);\n\n        // sadly the length function in glsl is not underflow-safe\n        // (at least not on Intel GPUs). So the safe solution is\n        // to ensure underflow-safety in all cases.\n        setOutput(\n          mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n        );\n      }\n    ";
9031},
9032    Si = function (t) {
9033  this.outputShape = [], this.outputShape = Sn(t, 1), this.variableNames = t.map(function (t, e) {
9034    return "T" + e;
9035  });
9036  var e = new Array(t.length - 1);
9037  e[0] = t[0][1];
9038
9039  for (var n = 1; n < e.length; n++) e[n] = e[n - 1] + t[n][1];
9040
9041  var r = ["if (yC < " + e[0] + ") setOutput(getT0(yR, yC));"];
9042
9043  for (n = 1; n < e.length; n++) {
9044    var o = e[n - 1];
9045    r.push("else if (yC < " + e[n] + ") setOutput(getT" + n + "(yR, yC-" + o + "));");
9046  }
9047
9048  var a = e.length,
9049      i = e[e.length - 1];
9050  r.push("else setOutput(getT" + a + "(yR, yC-" + i + "));"), this.userCode = "\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int yR = coords.x;\n        int yC = coords.y;\n\n        " + r.join("\n        ") + "\n      }\n    ";
9051},
9052    Ai = function (t, e) {
9053  this.packedInputs = !0, this.packedOutput = !0, this.outputShape = [], this.outputShape = Sn(t, e);
9054  var n = this.outputShape,
9055      r = n.length,
9056      o = oi(r),
9057      a = Ha("coords", r),
9058      i = ["x", "y", "z", "w", "u", "v"].slice(0, r);
9059  this.variableNames = t.map(function (t, e) {
9060    return "T" + e;
9061  });
9062  var s = new Array(t.length - 1);
9063  s[0] = t[0][e];
9064
9065  for (var u = 1; u < s.length; u++) s[u] = s[u - 1] + t[u][e];
9066
9067  var c = i[e],
9068      l = i.slice(-2),
9069      h = i.join(),
9070      f = "if (" + c + " < " + s[0] + ") {\n        return getChannel(\n            getT0(" + h + "), vec2(" + l.join() + "));\n        }";
9071
9072  for (u = 1; u < s.length; u++) {
9073    var d = s[u - 1];
9074    f += "\n        if (" + c + " < " + s[u] + "  && " + c + " >= " + s[u - 1] + ") {\n          return getChannel(\n            getT" + u + "(" + Ti(i, c, d) + "),\n            vec2(" + Ti(l, c, d) + "));\n        }";
9075  }
9076
9077  var p = s.length,
9078      v = s[s.length - 1];
9079  f += "\n        return getChannel(\n          getT" + p + "(" + Ti(i, c, v) + "),\n          vec2(" + Ti(l, c, v) + "));", this.userCode = "\n      float getValue(" + i.map(function (t) {
9080    return "int " + t;
9081  }) + ") {\n        " + f + "\n      }\n\n      void main() {\n        " + o + " coords = getOutputCoords();\n        vec4 result = vec4(getValue(" + a + "), 0., 0., 0.);\n\n        " + a[r - 1] + " = " + a[r - 1] + " + 1;\n        if (" + a[r - 1] + " < " + n[r - 1] + ") {\n          result.g = getValue(" + a + ");\n        }\n\n        " + a[r - 2] + " = " + a[r - 2] + " + 1;\n        if (" + a[r - 2] + " < " + n[r - 2] + ") {\n          result.a = getValue(" + a + ");\n        }\n\n        " + a[r - 1] + " = " + a[r - 1] + " - 1;\n        if (" + a[r - 2] + " < " + n[r - 2] + " &&\n            " + a[r - 1] + " < " + n[r - 1] + ") {\n          result.b = getValue(" + a + ");\n        }\n        setOutput(result);\n      }\n    ";
9082};
9083
9084function Ti(t, e, n) {
9085  var r = t.indexOf(e);
9086  return t.map(function (t, e) {
9087    return e === r ? t + " - " + n : t;
9088  }).join();
9089}
9090
9091var Di = function (t) {
9092  this.variableNames = ["x", "dy"], this.outputShape = t.filterShape;
9093  var e = t.strideHeight,
9094      n = t.strideWidth,
9095      r = t.padInfo.top,
9096      o = t.padInfo.left,
9097      a = "channelsLast" === t.dataFormat;
9098  this.userCode = "\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int d2 = coords.w;\n\n        // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int b = 0;
9098 b < " + t.batchSize + "; b++) {\n          for (int yR = 0; yR < " + t.outHeight + "; yR++) {\n            int xR = wR + yR * " + e + " - " + r + ";\n\n            if (xR < 0 || xR >= " + t.inHeight + ") {\n              continue;\n            }\n\n            for (int yC = 0; yC < " + t.outWidth + "; yC++) {\n              int xC = wC + yC * " + n + " - " + o + ";\n\n              if (xC < 0 || xC >= " + t.inWidth + ") {\n                continue;\n              }\n\n              if (" + a + ") {\n                float dyValue = getDy(b, yR, yC, d2);\n                float xValue = getX(b, xR, xC, d1);\n                dotProd += (xValue * dyValue);\n              } else {\n                float dyValue = getDy(b, d2, yR, yC);\n                float xValue = getX(b, d1, xR, xC);\n                dotProd += (xValue * dyValue);\n              }\n\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
9099},
9100    Ni = function (t) {
9101  this.variableNames = ["dy", "W"], this.outputShape = t.inShape;
9102  var e = t.filterHeight,
9103      n = t.filterWidth,
9104      r = t.strideHeight,
9105      o = t.strideWidth,
9106      a = "channelsLast" === t.dataFormat,
9107      i = e - 1 - t.padInfo.top,
9108      s = n - 1 - t.padInfo.left,
9109      u = a ? 1 : 2,
9110      c = a ? 2 : 3,
9111      l = a ? 3 : 1;
9112  this.userCode = "\n      const ivec2 pads = ivec2(" + i + ", " + s + ");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d1 = coords[" + l + "];\n\n        ivec2 dyCorner = ivec2(coords[" + u + "], coords[" + c + "]) - pads;\n        int dyRCorner = dyCorner.x;\n        int dyCCorner = dyCorner.y;\n\n        // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < " + e + "; wR++) {\n          float dyR = float(dyRCorner + wR) / " + r + ".0;\n\n          if (dyR < 0.0 || dyR >= " + t.outHeight + ".0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          int wRPerm = " + e + " - 1 - wR;\n\n          for (int wC = 0; wC < " + n + "; wC++) {\n            float dyC = float(dyCCorner + wC) / " + o + ".0;\n\n            if (dyC < 0.0 || dyC >= " + t.outWidth + ".0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            int wCPerm = " + n + " - 1 - wC;\n\n            for (int d2 = 0; d2 < " + t.outChannels + "; d2++) {\n\n              if (" + a + ") {\n                float xValue = getDy(batch, idyR, idyC, d2);\n                float wValue = getW(wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              } else {\n                float xValue = getDy(batch, d2, idyR, idyC);\n                float wValue = getW(wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              }\n\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
9113},
9114    Fi = function (t) {
9115  this.variableNames = ["x", "dy"], this.outputShape = t.filterShape;
9116  var e = t.strideDepth,
9117      n = t.strideHeight,
9118      r = t.strideWidth,
9119      o = t.padInfo.front,
9120      a = t.padInfo.top,
9121      i = t.padInfo.left;
9122  this.userCode = "\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int wF = coords.x;\n        int wR = coords.y;\n        int wC = coords.z;\n        int d1 = coords.w;\n        int d2 = coords.u;\n\n        float dotProd = 0.0;\n\n        for (int b = 0; b < " + t.batchSize + "; b++) {\n          for (int yF = 0; yF < " + t.outDepth + "; yF++) {\n            int xF = wF + yF * " + e + " - " + o + ";\n\n            if (xF < 0 || xF >= " + t.inDepth + ") {\n              continue;\n            }\n\n            for (int yR = 0; yR < " + t.outHeight + "; yR++) {\n              int xR = wR + yR * " + n + " - " + a + ";\n\n              if (xR < 0 || xR >= " + t.inHeight + ") {\n                continue;\n              }\n\n              for (int yC = 0; yC < " + t.outWidth + "; yC++) {\n                int xC = wC + yC * " + r + " - " + i + ";\n\n                if (xC < 0 || xC >= " + t.inWidth + ") {\n                  continue;\n                }\n\n                float dyValue = getDy(b, yF, yR, yC, d2);\n                float xValue = getX(b, xF, xR, xC, d1);\n                dotProd += (xValue * dyValue);\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
9123},
9124    _i = function (t) {
9125  this.variableNames = ["dy", "W"], this.outputShape = t.inShape;
9126  var e = t.filterDepth,
9127      n = t.filterHeight,
9128      r = t.filterWidth,
9129      o = t.strideDepth,
9130      a = t.strideHeight,
9131      i = t.strideWidth,
9132      s = e - 1 - t.padInfo.front,
9133      u = n - 1 - t.padInfo.top,
9134      c = r - 1 - t.padInfo.left;
9135  this.userCode = "\n      const ivec3 pads = ivec3(" + s + ", " + u + ", " + c + ");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d1 = coords.u;\n\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyFCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        float dotProd = 0.0;\n        for (int wF = 0; wF < " + e + ";
9135 wF++) {\n          float dyF = float(dyFCorner + wF) / " + o + ".0;\n\n          if (dyF < 0.0 || dyF >= " + t.outDepth + ".0 || fract(dyF) > 0.0) {\n            continue;\n          }\n          int idyF = int(dyF);\n\n          int wFPerm = " + e + " - 1 - wF;\n\n          for (int wR = 0; wR < " + n + "; wR++) {\n            float dyR = float(dyRCorner + wR) / " + a + ".0;\n\n            if (dyR < 0.0 || dyR >= " + t.outHeight + ".0 ||\n              fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            int wRPerm = " + n + " - 1 - wR;\n\n            for (int wC = 0; wC < " + r + "; wC++) {\n              float dyC = float(dyCCorner + wC) / " + i + ".0;\n\n              if (dyC < 0.0 || dyC >= " + t.outWidth + ".0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              int wCPerm = " + r + " - 1 - wC;\n\n              for (int d2 = 0; d2 < " + t.outChannels + "; d2++) {\n                float xValue = getDy(batch, idyF, idyR, idyC, d2);\n                float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n                dotProd += xValue * wValue;\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
9136},
9137    Oi = function (t) {
9138  this.variableNames = ["x", "dy"], this.outputShape = t.filterShape;
9139  var e = t.strideHeight,
9140      n = t.strideWidth,
9141      r = t.padInfo.top,
9142      o = t.padInfo.left,
9143      a = t.outChannels / t.inChannels;
9144  this.userCode = "\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int wR = coords.x;\n        int wC = coords.y;\n        int d1 = coords.z;\n        int dm = coords.w;\n        int d2 = d1 * " + a + " + dm;\n\n        float dotProd = 0.0;\n\n        // TO DO: Vec4 over the batch size\n        for (int b = 0; b < " + t.batchSize + "; b++) {\n          for (int yR = 0; yR < " + t.outHeight + "; yR++) {\n            int xR = wR + yR * " + e + " - " + r + ";\n\n            if (xR < 0 || xR >= " + t.inHeight + ") {\n              continue;\n            }\n\n            for (int yC = 0; yC < " + t.outWidth + "; yC++) {\n              int xC = wC + yC * " + n + " - " + o + ";\n\n              if (xC < 0 || xC >= " + t.inWidth + ") {\n                continue;\n              }\n\n              float dyValue = getDy(b, yR, yC, d2);\n              float xValue = getX(b, xR, xC, d1);\n              dotProd += (xValue * dyValue);\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
9145},
9146    Mi = function (t) {
9147  this.variableNames = ["dy", "W"], this.outputShape = t.inShape;
9148  var e = t.filterHeight,
9149      n = t.filterWidth,
9150      r = t.strideHeight,
9151      o = t.strideWidth,
9152      a = e - 1 - t.padInfo.top,
9153      i = n - 1 - t.padInfo.left,
9154      s = t.outChannels / t.inChannels;
9155  this.userCode = "\n      const ivec2 pads = ivec2(" + a + ", " + i + ");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d1 = coords[3];\n        ivec2 dyCorner = coords.yz - pads;\n        int dyRCorner = dyCorner.x;\n        int dyCCorner = dyCorner.y;\n\n        float dotProd = 0.0;\n\n        for (int wR = 0; wR < " + e + "; wR++) {\n          float dyR = float(dyRCorner + wR) / " + r + ".0;\n\n          if (dyR < 0.0 || dyR >= " + t.outHeight + ".0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          int wRPerm = " + e + " - 1 - wR;\n\n          for (int wC = 0; wC < " + n + "; wC++) {\n            float dyC = float(dyCCorner + wC) / " + o + ".0;\n\n            if (dyC < 0.0 || dyC >= " + t.outWidth + ".0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            int wCPerm = " + n + " - 1 - wC;\n\n            // TO DO: Vec4 over the channelMul\n            for (int dm = 0; dm < " + s + "; dm++) {\n              int d2 = d1 * " + s + " + dm;\n              float xValue = getDy(batch, idyR, idyC, d2);\n              float wValue = getW(wRPerm, wCPerm, d1, dm);\n              dotProd += xValue * wValue;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
9156},
9157    Bi = function (t, e, n, r) {
9158  void 0 === e && (e = !1), void 0 === n && (n = null), void 0 === r && (r = !1), this.variableNames = ["x", "W"], this.outputShape = t.outShape;
9159  var o = t.padInfo.top,
9160      a = t.padInfo.left,
9161      i = t.strideHeight,
9162      s = t.strideWidth,
9163      u = t.dilationHeight,
9164      c = t.dilationWidth,
9165      l = t.filterHeight,
9166      h = t.filterWidth,
9167      f = 4 * Math.floor(t.inChannels / 4),
9168      d = t.inChannels % 4,
9169      p = "channelsLast" === t.dataFormat,
9170      v = p ? 1 : 2,
9171      m = p ? 2 : 3,
9172      g = p ? 3 : 1,
9173      y = "",
9174      x = "";
9175  n && (y = r ? "float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          " + n + "\n        }" : "\n          float activation(float x) {\n            " + n + "\n          }\n        ", x = "result = activation(result);");
9176  var b = e ? "result += getBiasAtOutCoords();" : "";
9177  e && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), this.userCode = "\n      " + y + "\n\n      const ivec2 strides = ivec2(" + i + ", " + s + ");\n      const ivec2 pads = ivec2(" + o + ", " + a + ");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d2 = coords[" + g + "];\n\n        ivec2 xRCCorner =\n            ivec2(coords[" + v + "], coords[" + m + "]) * strides - pads;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < " + l + "; wR++) {\n          int xR = xRCorner + wR * " + u + ";\n\n          if (xR < 0 || xR >= " + t.inHeight + ") {\n            continue;\n          }\n\n          for (int wC = 0; wC < " + h + "; wC++) {\n            int xC = xCCorner + wC * " + c + ";\n\n            if (xC < 0 || xC >= " + t.inWidth + ") {\n              continue;\n            }\n\n            for (int d1 = 0; d1 < " + f + "; d1 += 4) {\n              vec4 wValues = vec4(\n                getW(wR, wC, d1, d2),\n                getW(wR, wC, d1 + 1, d2),\n                getW(wR, wC, d1 + 2, d2),\n                getW(wR, wC, d1 + 3, d2)\n              );\n\n              if (" + p + ") {\n                vec4 xValues = vec4(\n                  getX(batch, xR, xC, d1),\n                  getX(batch, xR, xC, d1 + 1),\n                  getX(batch, xR, xC, d1 + 2),\n                  getX(batch, xR, xC, d1 + 3)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec4 xValues = vec4(\n                  getX(batch, d1, xR, xC),\n                  getX(batch, d1 + 1, xR, xC),\n                  getX(batch, d1 + 2, xR, xC),\n                  getX(batch, d1 + 3, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n            }\n\n            if (" + (1 === d) + ") {\n\n              if (" + p + ") {\n                dotProd +=\n                    getX(batch, xR, xC, " + f + ") *\n                    getW(wR, wC, " + f + ", d2);\n              } else {\n                dotProd +=\n                    getX(batch, " + f + ", xR, xC) *\n                    getW(wR, wC, " + f + ", d2);\n              }\n\n            } else if (" + (2 === d) + ") {\n              vec2 wValues = vec2(\n                getW(wR, wC, " + f + ", d2),\n                getW(wR, wC, " + f + " + 1, d2)\n              );\n\n              if (" + p + ") {\n                vec2 xValues = vec2(\n                  getX(batch, xR, xC, " + f + "),\n                  getX(batch, xR, xC, " + f + " + 1)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec2 xValues = vec2(\n                  getX(batch, " + f + ", xR, xC),\n                  getX(batch, " + f + " + 1, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            } else if (" + (3 === d) + ") {\n              vec3 wValues = vec3(\n                getW(wR, wC, " + f + ", d2),\n                getW(wR, wC, " + f + " + 1, d2),\n                getW(wR, wC, " + f + " + 2, d2)\n              );\n\n              if (" + p + ") {\n                vec3 xValues = vec3(\n                  getX(batch, xR, xC, " + f + "),\n                  getX(batch, xR, xC, " + f + " + 1),\n                  getX(batch, xR, xC, " + f + " + 2)\n                );\n                dotProd += dot(xValues, wValues);\n              } else {\n                vec3 xValues = vec3(\n                  getX(batch, " + f + ", xR, xC),\n                  getX(batch, " + f + " + 1, xR, xC),\n                  getX(batch, " + f + " + 2, xR, xC)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n\n            }\n          }\n        }\n\n        float result = dotProd;\n        " + b + "\n        " + x + "\n        setOutput(result);\n      }\n    ";
9178},
9179    Pi = function (t) {
9180  this.variableNames = ["x", "W"], this.outputShape = t.outShape;
9181  var e = t.padInfo.front,
9182      n = t.padInfo.top,
9183      r = t.padInfo.left,
9184      o = t.strideDepth,
9185      a = t.strideHeight,
9186      i = t.strideWidth,
9187      s = t.dilationDepth,
9188      u = t.dilationHeight,
9189      c = t.dilationWidth,
9190      l = t.filterDepth,
9191      h = t.filterHeight,
9192      f = t.filterWidth,
9193      d = 4 * Math.floor(t.inChannels / 4),
9194      p = t.inChannels % 4;
9195  this.userCode = "\n      const ivec3 strides = ivec3(" + o + ", " + a + ", " + i + ");\n      const ivec3 pads = ivec3(" + e + ", " + n + ", " + r + ");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int d2 = coords.u;\n\n        ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xFCorner = xFRCCorner.x;\n        int xRCorner = xFRCCorner.y;\n        int xCCorner = xFRCCorner.z;\n\n        // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n        // y(yF, yR, yC, d2). ? = to be determined. : = across all\n        // values in that axis.\n        float dotProd = 0.0;\n        for (int wF = 0; wF < " + l + ";
9195 wF++) {\n          int xF = xFCorner + wF * " + s + ";\n\n          if (xF < 0 || xF >= " + t.inDepth + ") {\n            continue;\n          }\n\n          for (int wR = 0; wR < " + h + "; wR++) {\n            int xR = xRCorner + wR * " + u + ";\n\n            if (xR < 0 || xR >= " + t.inHeight + ") {\n              continue;\n            }\n\n            for (int wC = 0; wC < " + f + "; wC++) {\n              int xC = xCCorner + wC * " + c + ";\n\n              if (xC < 0 || xC >= " + t.inWidth + ") {\n                continue;\n              }\n\n              for (int d1 = 0; d1 < " + d + "; d1 += 4) {\n                vec4 xValues = vec4(\n                  getX(batch, xF, xR, xC, d1),\n                  getX(batch, xF, xR, xC, d1 + 1),\n                  getX(batch, xF, xR, xC, d1 + 2),\n                  getX(batch, xF, xR, xC, d1 + 3)\n                );\n                vec4 wValues = vec4(\n                  getW(wF, wR, wC, d1, d2),\n                  getW(wF, wR, wC, d1 + 1, d2),\n                  getW(wF, wR, wC, d1 + 2, d2),\n                  getW(wF, wR, wC, d1 + 3, d2)\n                );\n\n                dotProd += dot(xValues, wValues);\n              }\n\n              if (" + (1 === p) + ") {\n                dotProd +=\n                  getX(batch, xF, xR, xC, " + d + ") *\n                  getW(wF, wR, wC, " + d + ", d2);\n              } else if (" + (2 === p) + ") {\n                vec2 xValues = vec2(\n                  getX(batch, xF, xR, xC, " + d + "),\n                  getX(batch, xF, xR, xC, " + d + " + 1)\n                );\n                vec2 wValues = vec2(\n                  getW(wF, wR, wC, " + d + ", d2),\n                  getW(wF, wR, wC, " + d + " + 1, d2)\n                );\n                dotProd += dot(xValues, wValues);\n              } else if (" + (3 === p) + ") {\n                vec3 xValues = vec3(\n                  getX(batch, xF, xR, xC, " + d + "),\n                  getX(batch, xF, xR, xC, " + d + " + 1),\n                  getX(batch, xF, xR, xC, " + d + " + 2)\n                );\n                vec3 wValues = vec3(\n                  getW(wF, wR, wC, " + d + ", d2),\n                  getW(wF, wR, wC, " + d + " + 1, d2),\n                  getW(wF, wR, wC, " + d + " + 2, d2)\n                );\n                dotProd += dot(xValues, wValues);\n              }\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
9196},
9197    Li = function (t, e, n, r) {
9198  void 0 === e && (e = !1), void 0 === n && (n = null), void 0 === r && (r = !1), this.variableNames = ["x", "W"], this.outputShape = t.outShape;
9199  var o = t.inHeight,
9200      a = t.inWidth,
9201      i = t.padInfo.top,
9202      s = t.padInfo.left,
9203      u = t.strideHeight,
9204      c = t.strideWidth,
9205      l = t.dilationHeight,
9206      h = t.dilationWidth,
9207      f = t.filterHeight,
9208      d = t.filterWidth,
9209      p = t.outChannels / t.inChannels,
9210      v = "",
9211      m = "";
9212  n && (v = r ? "float activation(float a) {\n          float b = getPreluActivationWeightsAtOutCoords();\n          " + n + "\n        }" : "\n          float activation(float x) {\n            " + n + "\n          }\n        ", m = "result = activation(result);");
9213  var g = e ? "result += getBiasAtOutCoords();" : "";
9214  e && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), this.userCode = "\n      " + v + "\n\n      const ivec2 strides = ivec2(" + u + ", " + c + ");\n      const ivec2 pads = ivec2(" + i + ", " + s + ");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords.x;\n        ivec2 xRCCorner = coords.yz * strides - pads;\n        int d2 = coords.w;\n        int d1 = d2 / " + p + ";\n        int q = d2 - d1 * " + p + ";\n\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n        for (int wR = 0; wR < " + f + "; wR++) {\n          int xR = xRCorner + wR * " + l + ";\n\n          if (xR < 0 || xR >= " + o + ") {\n            continue;\n          }\n\n          for (int wC = 0; wC < " + d + "; wC++) {\n            int xC = xCCorner + wC * " + h + ";\n\n            if (xC < 0 || xC >= " + a + ") {\n              continue;\n            }\n\n            float xVal = getX(batch, xR, xC, d1);\n            float wVal = getW(wR, wC, d1, q);\n            dotProd += xVal * wVal;\n          }\n        }\n\n        float result = dotProd;\n        " + g + "\n        " + m + "\n        setOutput(result);\n      }\n    ";
9215},
9216    Wi = function (t, e, n, r) {
9217  void 0 === e && (e = !1), void 0 === n && (n = null), void 0 === r && (r = !1), this.variableNames = ["x", "W"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t.outShape;
9218
9219  for (var o = t.inHeight, a = t.inWidth, i = t.padInfo.top, s = t.padInfo.left, u = t.strideHeight, c = t.strideWidth, l = t.dilationHeight, h = t.dilationWidth, f = t.filterHeight, d = t.filterWidth, p = d, v = "int xR; int xC; int xCOffset;", m = 0; m < f; m++) for (var g = 0; g < d; g++) v += "\n          vec4 xTexelR" + m + "C" + 2 * g + " = vec4(0.);\n          vec4 wR" + m + "C" + g + " = vec4(0.);\n          vec4 xR" + m + "C" + g + " = vec4(0.);";
9220
9221  for (m = 0; m < f; m++) for (var y = 0; y < p; y++) {
9222    if (v += "\n          xR = xRCorner + " + m * l + ";\n          xC = xCCorner + " + (g = 2 * y) * h + ";\n        ", 1 === c) {
9223      if (g < d && (v += s % 2 == 1 ? "\n                xCOffset = xC + 1;\n                if(xR >= 0 && xR < " + o + " && xCOffset >= 0 && xCOffset < " + a + ") {\n                  xTexelR" + m + "C" + g + " = getX(batch, xR, xCOffset, d1);\n\n                  // Need to manually clear unused channels in case\n                  // we're reading from recycled texture.\n                  if(xCOffset + 1 >= " + a + ") {\n                    xTexelR" + m + "C" + g + ".zw = vec2(0.);\n                  }\n                } else {\n                  xTexelR" + m + "C" + g + " = vec4(0.);\n                }\n\n                xCOffset = xC + 1 - 2;\n                if(xR >= 0 && xR < " + o + " && xCOffset >= 0 && xCOffset < " + a + ") {\n                  vec4 previous = getX(batch, xR, xCOffset, d1);\n\n                  // Need to manually clear unused channels in case\n                  // we're reading from recycled texture.\n                  if(xCOffset + 1 >= " + a + ") {\n                    previous.zw = vec2(0.);\n                  }\n\n                  xR" + m + "C" + g + " = vec4(previous.zw, xTexelR" + m + "C" + g + ".xy);\n                } else {\n                  xR" + m + "C" + g + " = vec4(0, 0, xTexelR" + m + "C" + g + ".xy);\n                }\n              " : "\n                if(xR >= 0 && xR < " + o + " && xC >= 0 && xC < " + a + ") {\n                  xTexelR" + m + "C" + g + " = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR" + m + "C" + g + " = vec4(0.);\n                }\n\n                xR" + m + "C" + g + " = xTexelR" + m + "C" + g + ";\n              ", g + 1 < d)) {
9224        var x = s % 2 == 0 ? b(h) : h;
9225        h % 2 == 0 && s % 2 == 1 || h % 2 != 0 && s % 2 != 1 ? (v += "\n                  xCOffset = xC + " + s % 2 + " + " + x + ";\n\n                  if(xR >= 0 && xR < " + o + " &&\n                    xCOffset >= 0 && xCOffset < " + a + ") {\n                    xTexelR" + m + "C" + (g + 2) + " = getX(batch, xR, xCOffset, d1);\n                  }\n                ", h > 1 && (v += "\n                    xCOffset -= 2;\n                    if(xR >= 0 && xR < " + o + " &&\n                      xCOffset >= 0 && xCOffset < " + a + ") {\n                      xTexelR" + m + "C" + g + " = getX(batch, xR, xCOffset, d1);\n                    } else {\n                      xTexelR" + m + "C" + g + " = vec4(0.);\n                    }\n                  "), v += "\n                  xR" + m + "C" + (g + 1) + " = vec4(\n                    xTexelR" + m + "C" + g + ".zw, xTexelR" + m + "C" + (g + 2) + ".xy);\n                ") : v += "\n                  xCOffset = xC + " + x + ";\n\n                  if(xR >= 0 && xR < " + o + " &&\n                    xCOffset >= 0 && xCOffset < " + a + ") {\n                    xTexelR" + m + "C" + (g + 2) + " = getX(batch, xR, xCOffset, d1);\n                  }\n\n                  xR" + m + "C" + (g + 1) + " = xTexelR" + m + "C" + (g + 2) + ";\n                ";
9226      }
9227    } else g < d && (v += "\n              if(xR >= 0 && xR < " + o + ") {\n            ", s % 2 == 1 ? (v += "\n                xCOffset = xC + 1 - " + c + ";\n                if(xCOffset >= 0 && xCOffset < " + a + ") {\n                  xTexelR" + m + "C" + g + " = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR" + m + "C" + g + " = vec4(0.);\n                }\n\n                if(xC + 1 >= 0 && xC + 1 < " + a + ") {\n                  xTexelR" + m + "C" + (g + 2) + " = getX(batch, xR, xC + 1, d1);\n                } else {\n                  xTexelR" + m + "C" + (g + 2) + " = vec4(0.);\n                }\n\n                xR" + m + "C" + g + " = vec4(\n                  xTexelR" + m + "C" + g + ".zw, xTexelR" + m + "C" + (g + 2) + ".zw);\n              ", g + 1 < d && (v += "\n                  vec4 final = vec4(0.);\n                  xCOffset = xC + 1 + " + c + ";\n                  if(xCOffset >= 0 && xCOffset < " + a + ") {\n                    final = getX(batch, xR, xCOffset, d1);\n                  }\n                  xR" + m + "C" + (g + 1) + " = vec4(xTexelR" + m + "C" + (g + 2) + ".xy, final.xy);\n                ")) : (v += "\n                if(xC >= 0 && xC < " + a + ") {\n                  xTexelR" + m + "C" + g + " = getX(batch, xR, xC, d1);\n                } else {\n                  xTexelR" + m + "C" + g + " = vec4(0.);\n                }\n\n                xCOffset = xC + " + c + ";\n                if(xCOffset >= 0 && xCOffset < " + a + ") {\n                  xTexelR" + m + "C" + (g + 2) + " = getX(batch, xR, xCOffset, d1);\n                } else {\n                  xTexelR" + m + "C" + (g + 2) + " = vec4(0.);\n                }\n\n                xR" + m + "C" + g + " = vec4(\n                  xTexelR" + m + "C" + g + ".xy, xTexelR" + m + "C" + (g + 2) + ".xy);\n              ", g + 1 < d && (v += "\n                  xR" + m + "C" + (g + 1) + " = vec4(\n                    xTexelR" + m + "C" + g + ".zw, xTexelR" + m + "C" + (g + 2) + ".zw);
vendor: 6,334 bytes, lines 9227-9291
9227\n                ")), v += "}");
9228
9229    g < d && (v += "\n            vec4 wTexelR" + m + "C" + g + " = getW(" + m + ", " + g + ", d1, q);\n            wR" + m + "C" + g + " = vec4(wTexelR" + m + "C" + g + ".xz, wTexelR" + m + "C" + g + ".xz);\n          ", g + 1 < d && (v += "\n              vec4 wTexelR" + m + "C" + (g + 1) + " = getW(" + m + ", " + (g + 1) + ", d1, q);\n              wR" + m + "C" + (g + 1) + " =\n                vec4(wTexelR" + m + "C" + (g + 1) + ".xz, wTexelR" + m + "C" + (g + 1) + ".xz);"));
9230  }
9231
9232  for (m = 0; m < f; m++) for (g = 0; g < d; g++) v += "dotProd += xR" + m + "C" + g + " * wR" + m + "C" + g + ";";
9233
9234  var w = "",
9235      C = "";
9236  n && (w = r ? "vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          " + n + "\n        }" : "vec4 activation(vec4 x) {\n          " + n + "\n        }", C = "result = activation(result);");
9237  var E = e ? "result += getBiasAtOutCoords();" : "";
9238  e && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), this.userCode = "\n      " + w + "\n\n      const ivec2 strides = ivec2(" + u + ", " + c + ");\n      const ivec2 pads = ivec2(" + i + ", " + s + ");\n\n      void main() {\n\n        ivec4 coords = getOutputCoords();\n        int batch = coords.x;\n        ivec2 xRCCorner = coords.yz * strides - pads;\n        int d2 = coords.w;\n        int d1 = d2;\n        int q = 0;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        vec4 dotProd = vec4(0.);\n\n        " + v + "\n\n        vec4 result = dotProd;\n        " + E + "\n        " + C + "\n        setOutput(result);\n      }\n    ";
9239},
9240    Ui = function (t, e, n, r, o) {
9241  this.variableNames = ["Image", "Boxes", "BoxInd"], this.outputShape = [];
9242  var a = t[0],
9243      i = t[1],
9244      s = t[2],
9245      u = t[3],
9246      c = e[0],
9247      l = n[0],
9248      h = n[1];
9249  this.outputShape = [c, l, h, u];
9250  var f = "bilinear" === r ? 1 : 0,
9251      d = [i - 1 + ".0", s - 1 + ".0"],
9252      p = d[0],
9253      v = d[1],
9254      m = l > 1 ? ["" + (i - 1) / (l - 1), "(y2-y1) * height_ratio", "y1*" + p + " + float(y)*(height_scale)"] : ["0.0", "0.0", "0.5 * (y1+y2) * " + p],
9255      g = m[0],
9256      y = m[1],
9257      x = m[2],
9258      b = h > 1 ? ["" + (s - 1) / (h - 1), "(x2-x1) * width_ratio", "x1*" + v + " + float(x)*(width_scale)"] : ["0.0", "0.0", "0.5 * (x1+x2) * " + v],
9259      w = b[0],
9260      C = b[1],
9261      E = b[2];
9262  this.userCode = "\n      const float height_ratio = float(" + g + ");\n      const float width_ratio = float(" + w + ");\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int y = coords[1];\n        int x = coords[2];\n        int d = coords[3];\n\n        // get box vals\n        float y1 = getBoxes(b,0);\n        float x1 = getBoxes(b,1);\n        float y2 = getBoxes(b,2);\n        float x2 = getBoxes(b,3);\n\n        // get image in batch index\n        int bInd = round(getBoxInd(b));\n        if(bInd < 0 || bInd >= " + a + ") {\n          return;\n        }\n\n        float height_scale = " + y + ";\n        float width_scale = " + C + ";\n\n        float in_y = " + x + ";\n        if( in_y < 0.0 || in_y > " + p + " ) {\n          setOutput(float(" + o + "));\n          return;\n        }\n        float in_x = " + E + ";\n        if( in_x < 0.0 || in_x > " + v + " ) {\n          setOutput(float(" + o + "));\n          return;\n        }\n\n        vec2 sourceFracIndexCR = vec2(in_x,in_y);\n        if(" + f + " == 1) {\n          // Compute the four integer indices.\n          ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n          ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n          float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n          float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n          float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n          float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n          vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n          float top = topLeft + (topRight - topLeft) * fracCR.x;\n          float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n          float newValue = top + (bottom - top) * fracCR.y;\n          setOutput(newValue);\n        } else {\n          // Compute the coordinators of nearest neighbor point.\n          ivec2 sourceNearestCR = ivec2(floor(\n            sourceFracIndexCR + vec2(0.5,0.5)));\n          float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n          setOutput(newValue);\n        }\n      }\n    ";
9263},
9264    Vi = function (t, e, n) {
9265  this.variableNames = ["x"], this.outputShape = t;
9266  var r = t.length,
9267      o = t[t.length - 1],
9268      a = n ? "<" : ">";
9269
9270  this.userCode = "\n      int getIndex(int i) {\n        " + (n ? "return " + o + " -i - 1;" : "return i;") + "\n      }\n\n      void main() {\n        " + oi(r) + " coords = getOutputCoords();\n        int end = " + zi(r, "coords") + ";\n        float val = 0.0;\n        for (int i = " + o + " - 1; i >= 0; i -= 1) {\n          int idx = getIndex(i);\n          if (idx " + a + " end) {\n            continue;\n          }\n          if (idx == end && " + e + ") {\n            continue;\n          }\n          " + zi(r, "coords") + " = idx;\n          val += getX(" + function (t, e) {
9271    if (1 === t) return "" + e;
9272    if (2 === t) return e + ".x, " + e + ".y";
9273    if (3 === t) return e + ".x, " + e + ".y, " + e + ".z";
9274    if (4 === t) return e + ".x, " + e + ".y, " + e + ".z, " + e + ".w";
9275    throw Error("Cumulative sum for rank " + t + " is not yet supported");
9276  }(r, "coords") + ");\n        }\n        setOutput(val);\n      }\n    ";
9277};
9278
9279function zi(t, e) {
9280  if (1 === t) return "" + e;
9281  if (2 === t) return e + ".y";
9282  if (3 === t) return e + ".z";
9283  if (4 === t) return e + ".w";
9284  throw Error("Cumulative sum for rank " + t + " is not yet supported");
9285}
9286
9287var Gi = function (t) {
9288  this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0, this.outPackingScheme = Vt.DENSE;
9289  var e = Yt(t),
9290      n = qa();
9291  this.outputShape = t, this.userCode = "\n      ivec3 outCoordsFromFlatIndex(int index) {\n        " + Ka(["r", "c", "d"], t) + "\n        return ivec3(r, c, d);\n      }
9291\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2(" + e[0] + ", " + e[1] + "));\n        int index = 4 * (resTexRC.x * " + e[1] + " + resTexRC.y);\n\n        vec4 result = vec4(0.);\n\n        for (int i=0; i<4; i++) {\n          int flatIndex = index + i;\n          ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n          result[i] = getA(rc.x, rc.y, rc.z);\n        }\n\n        " + n.output + " = result;\n      }\n    ";
9292},
9293    Hi = function (t) {
9294  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outPackingScheme = Vt.DENSE;
9295  var e = Yt(t),
9296      n = qa();
9297  this.outputShape = t, this.userCode = "\n      ivec3 outCoordsFromFlatIndex(int index) {\n        " + Ka(["r", "c", "d"], t) + "\n        return ivec3(r, c, d);\n      }\n\n      void main() {\n        ivec2 resTexRC = ivec2(resultUV.yx *\n          vec2(" + e[0] + ", " + e[1] + "));\n        int index = 4 * (resTexRC.x * " + e[1] + " + resTexRC.y);\n\n        vec4 result = vec4(0.);\n\n        for (int i=0; i<4; i++) {\n          int flatIndex = index + i;\n          ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n          result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n        }\n\n        " + n.output + " = result;\n      }\n    ";
9298},
9299    qi = function () {
9300  function t(t, e, n) {
9301    this.variableNames = ["x"], this.outputShape = [], this.outputShape = t, this.blockSize = e, this.dataFormat = n, this.userCode = "\n    void main() {\n      ivec4 coords = getOutputCoords();\n      int b = coords[0];\n      int h = " + this.getHeightCoordString() + ";\n      int w = " + this.getWidthCoordString() + ";\n      int d = " + this.getDepthCoordString() + ";\n\n      int in_h = h / " + e + ";\n      int offset_h = imod(h, " + e + ");\n      int in_w = w / " + e + ";\n      int offset_w = imod(w, " + e + ");\n      int offset_d = (offset_h * " + e + " + offset_w) *\n        " + this.getOutputDepthSize() + ";\n      int in_d = d + offset_d;\n\n      float result = " + this.getInputSamplingString() + ";\n      setOutput(result);\n    }\n  ";
9302  }
9303
9304  return t.prototype.getHeightCoordString = function () {
9305    return "NHWC" === this.dataFormat ? "coords[1]" : "coords[2]";
9306  }, t.prototype.getWidthCoordString = function () {
9307    return "NHWC" === this.dataFormat ? "coords[2]" : "coords[3]";
9308  }, t.prototype.getDepthCoordString = function () {
9309    return "NHWC" === this.dataFormat ? "coords[3]" : "coords[1]";
9310  }, t.prototype.getOutputDepthSize = function () {
9311    return "NHWC" === this.dataFormat ? this.outputShape[3] : this.outputShape[1];
9312  }, t.prototype.getInputSamplingString = function () {
9313    return "NHWC" === this.dataFormat ? "getX(b, in_h, in_w, in_d)" : "getX(b, in_d, in_h, in_w)";
9314  }, t;
9315}(),
9316    Ki = function (t) {
9317  this.variableNames = ["X"], this.outputShape = [t, t], this.userCode = "\n      void main() {\n          ivec2 coords = getOutputCoords();\n          float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n          setOutput(val);\n      }\n    ";
9318},
9319    ji = function (t) {
9320  this.variableNames = ["A"], this.outTexUsage = zt.DOWNLOAD;
9321  var e = qa();
9322  this.outputShape = t, this.userCode = "\n      " + Xa + "\n\n      void main() {\n        float x = getAAtOutCoords();\n        " + e.output + " = encode_float(x);\n      }\n    ";
9323},
9324    Xi = function (t) {
9325  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !1, this.outTexUsage = zt.DOWNLOAD;
9326  var e = qa();
9327  this.outputShape = t, this.userCode = "\n      " + Xa + "\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n        float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n        " + e.output + " = encode_float(x);\n      }\n    ";
9328},
9329    Yi = function (t, e, n) {
9330  void 0 === n && (n = !1), this.variableNames = ["A"];
9331  var r = qa(),
9332      o = e[0],
9333      a = e[1];
9334  this.outputShape = t;
9335  var i = "result";
9336  n && (i = "floor(result * 255. + 0.5)"), this.userCode = "\n      " + ja(t) + "\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n\n        int flatIndex = getFlatIndex(coords);\n        int offset = imod(flatIndex, 4);\n\n        flatIndex = idiv(flatIndex, 4, 1.);\n        \n        int r = flatIndex / " + a + ";\n        int c = imod(flatIndex, " + a + ");\n        vec2 uv = (vec2(c, r) + halfCR) / vec2(" + a + ".0, " + o + ".0);\n        vec4 values = " + r.texture2D + "(A, uv);\n\n        float result;\n\n        if(offset == 0) {\n          result = values[0];\n        } else if(offset == 1) {\n          result = values[1];\n        } else if(offset == 2) {\n          result = values[2];\n        } else {\n          result = values[3];\n        }\n\n        " + r.output + " = vec4(" + i + ", 0., 0., 0.);\n      }\n    ";
9337},
9338    $i = function (t, e, n) {
9339  void 0 === n && (n = !1), this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0;
9340  var r = qa(),
9341      o = e[0],
9342      a = e[1];
9343  this.outputShape = t;
9344  var i = "",
9345      s = "result";
9346  n && (s = "floor(result * 255. + 0.5)");
9347
9348  for (var u = 0; u <= 1;
vendor: 4,406 bytes, lines 9348-9401
9348 u++) for (var c = 0; c <= 1; c++) {
9349    var l = 2 * u + c;
9350    i += "\n          localCoords = coords;\n          if(localCoords[2] + " + c + " < " + t[2] + ") {\n            localCoords[2] += " + c + ";\n            if(localCoords[1] + " + u + " < " + t[1] + ") {\n              localCoords[1] += " + u + ";\n\n              flatIndex = getFlatIndex(localCoords);\n              offset = imod(flatIndex, 4);\n\n              flatIndex = idiv(flatIndex, 4, 1.);\n\n              r = flatIndex / " + a + ";\n              c = imod(flatIndex, " + a + ");\n              uv = (vec2(c, r) + halfCR) / vec2(" + a + ".0, " + o + ".0);\n              values = " + r.texture2D + "(A, uv);\n\n              if(offset == 0) {\n                result[" + l + "] = values[0];\n              } else if(offset == 1) {\n                result[" + l + "] = values[1];\n              } else if(offset == 2) {\n                result[" + l + "] = values[2];\n              } else {\n                result[" + l + "] = values[3];\n              }\n            }\n          }\n        ";
9351  }
9352
9353  this.userCode = "\n      " + ja(t) + "\n\n      void main() {\n        ivec3 coords = getOutputCoords();\n\n        vec4 result = vec4(0.);\n        int flatIndex, r, c, offset;\n        ivec3 localCoords;\n        vec2 uv;\n        vec4 values;\n\n        " + i + "\n\n        " + r.output + " = " + s + ";\n      }\n    ";
9354},
9355    Qi = "return real * expR - imag * expI;",
9356    Ji = "return real * expI + imag * expR;",
9357    Zi = function (t, e, n) {
9358  this.variableNames = ["real", "imag"];
9359  var r = e[1];
9360  this.outputShape = e;
9361  var o = n ? "2.0 * " + Math.PI : "-2.0 * " + Math.PI,
9362      a = n ? r + ".0" : "1.0";
9363  this.userCode = "\n      const float exponentMultiplier = " + o + ";\n\n      float unaryOpComplex(float real, float expR, float imag, float expI) {\n        " + t + "\n      }\n\n      float mulMatDFT(int batch, int index) {\n        float indexRatio = float(index) / float(" + r + ");\n        float exponentMultiplierTimesIndexRatio =\n            exponentMultiplier * indexRatio;\n\n        float result = 0.0;\n\n        for (int i = 0; i < " + r + "; i++) {\n          // x = (-2|2 * PI / N) * index * i;\n          float x = exponentMultiplierTimesIndexRatio * float(i);\n          float expR = cos(x);\n          float expI = sin(x);\n          float real = getReal(batch, i);\n          float imag = getImag(batch, i);\n\n          result +=\n              unaryOpComplex(real, expR, imag, expI) / " + a + ";\n        }\n\n        return result;\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        setOutput(mulMatDFT(coords[0], coords[1]));\n      }\n    ";
9364},
9365    ts = function () {
9366  function t(t, e) {
9367    this.outputShape = [], this.variableNames = ["x"], this.outputShape = t, this.userCode = "\n      uniform float value;\n      void main() {\n        // Input can be obtained from uniform value.\n        setOutput(value);\n      }\n    ";
9368  }
9369
9370  return t.prototype.getCustomSetupFunc = function (t) {
9371    var e = this;
9372    return function (n, r) {
9373      null == e.valueLoc && (e.valueLoc = n.getUniformLocationNoThrow(r, "value")), n.gl.uniform1f(e.valueLoc, t);
9374    };
9375  }, t;
9376}(),
9377    es = function (t, e, n) {
9378  this.variableNames = ["A", "indices"];
9379  var r = t.slice();
9380  r[n] = e, this.outputShape = r, this.rank = r.length;
9381
9382  var o = oi(this.rank),
9383      a = function (t, e) {
9384    var n = t.length;
9385    if (n > 4) throw Error("Gather for rank " + n + " is not yet supported");
9386    if (1 === n) return "int(getIndices(resRC))";
9387
9388    for (var r = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], o = [], a = 0; a < t.length; a++) a === e ? o.push("int(getIndices(" + r[a] + "))") : o.push("" + r[a]);
9389
9390    return o.join();
9391  }(t, n);
9392
9393  this.userCode = "\n      void main() {\n        " + o + " resRC = getOutputCoords();\n        setOutput(getA(" + a + "));\n      }\n    ";
9394};
9395
9396var ns = function (t, e, n) {
9397  this.sliceDim = t, this.strides = e, this.variableNames = ["x", "indices"], this.outputShape = n;
9398  var r = oi(e.length),
9399      o = oi(n.length),
9400      a = this.sliceDim > 1 ? "strides[j]" : "strides";
9401  this.userCode = "\n        " + r + " strides = " + r + "(" + this.strides + ");\n         void main() {\n          " + o + " coords = getOutputCoords();\n          int flattenIndex = 0;\n          for (int j = 0; j < " + this.sliceDim + ";
9401 j++) {\n            int index = round(getIndices(coords[0], j));\n            flattenIndex += index * " + a + ";\n          }\n          setOutput(getX(flattenIndex, coords[1]));\n        }\n      ";
9402};
9403
9404function rs(t, e) {
9405  var n = qa();
9406  return oe(t, e, n.version + "\n    precision highp float;\n    " + n.attribute + " vec3 clipSpacePos;\n    " + n.attribute + " vec2 uv;\n    " + n.varyingVs + " vec2 resultUV;\n\n    void main() {\n      gl_Position = vec4(clipSpacePos, 1);\n      resultUV = uv;\n    }");
9407}
9408
9409function os(t, e) {
9410  return fe(t, e, new Float32Array([-1, 1, 0, 0, 1, -1, -1, 0, 0, 0, 1, 1, 0, 1, 1, 1, -1, 0, 1, 0]));
9411}
9412
9413function as(t, e) {
9414  return de(t, e, new Uint16Array([0, 1, 2, 2, 1, 3]));
9415}
9416
9417function is(t, e, n, r, o, a, i) {
9418  ve(n, r);
9419  var s = pe(t, e),
9420      u = t.TEXTURE_2D;
9421  return Jt(t, e, function () {
9422    return t.bindTexture(u, s);
9423  }), Jt(t, e, function () {
9424    return t.texParameteri(u, t.TEXTURE_WRAP_S, t.CLAMP_TO_EDGE);
9425  }), Jt(t, e, function () {
9426    return t.texParameteri(u, t.TEXTURE_WRAP_T, t.CLAMP_TO_EDGE);
9427  }), Jt(t, e, function () {
9428    return t.texParameteri(u, t.TEXTURE_MIN_FILTER, t.NEAREST);
9429  }), Jt(t, e, function () {
9430    return t.texParameteri(u, t.TEXTURE_MAG_FILTER, t.NEAREST);
9431  }), Jt(t, e, function () {
9432    return t.texImage2D(u, 0, o, n, r, 0, a, i, null);
9433  }), Jt(t, e, function () {
9434    return t.bindTexture(t.TEXTURE_2D, null);
9435  }), s;
9436}
9437
9438function ss(t, e, n, r, o) {
9439  var a = Xt(n, r);
9440  return is(t, e, a[0], a[1], o.internalFormatFloat, o.textureFormatFloat, t.FLOAT);
9441}
9442
9443function us(t, e, n, r, o) {
9444  var a = Xt(n, r);
9445  return is(t, e, a[0], a[1], o.internalFormatHalfFloat, o.textureFormatFloat, o.textureTypeHalfFloat);
9446}
9447
9448function cs(t, e, n, r, o) {
9449  var a = Xt(n, r);
9450  return is(t, e, a[0], a[1], t.RGBA, t.RGBA, t.UNSIGNED_BYTE);
9451}
9452
9453function ls(t, e, n, r, o) {
9454  var a = $t(n, r);
9455  return is(t, e, a[0], a[1], o.internalFormatPackedFloat, t.RGBA, t.FLOAT);
9456}
9457
9458function hs(t, e, n, r, o) {
9459  var a = $t(n, r);
9460  return is(t, e, a[0], a[1], o.internalFormatPackedHalfFloat, t.RGBA, o.textureTypeHalfFloat);
9461}
9462
9463function fs(t, e, n, r) {
9464  return Jt(t, e, function () {
9465    return t.bindBuffer(t.ARRAY_BUFFER, r);
9466  }), ge(t, e, n, "clipSpacePos", r, 3, 20, 0) && ge(t, e, n, "uv", r, 2, 20, 12);
9467}
9468
9469function ds(t, e, n, r, o, a, i) {
9470  var s, u, c;
9471  Jt(t, e, function () {
9472    return t.bindTexture(t.TEXTURE_2D, n);
9473  }), a instanceof Uint8Array ? (s = new Uint8Array(r * o * 4), u = t.UNSIGNED_BYTE, c = t.RGBA) : (s = new Float32Array(r * o * 4), u = t.FLOAT, c = i.internalFormatPackedFloat), s.set(a), Jt(t, e, function () {
9474    return t.texImage2D(t.TEXTURE_2D, 0, c, r, o, 0, t.RGBA, u, s);
9475  }), Jt(t, e, function () {
9476    return t.bindTexture(t.TEXTURE_2D, null);
9477  });
9478}
9479
9480function ps(t, e, n, r) {
9481  Jt(t, e, function () {
9482    return t.bindTexture(t.TEXTURE_2D, n);
9483  }), r.data instanceof Uint8Array ? Jt(t, e, function () {
9484    return t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, r.width, r.height, 0, t.RGBA, t.UNSIGNED_BYTE, r.data);
9485  }) : Jt(t, e, function () {
9486    return t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, r);
9487  }), Jt(t, e, function () {
9488    return t.bindTexture(t.TEXTURE_2D, null);
9489  });
9490}
9491
9492function vs(t, e, n, r, o) {
9493  var a = t.createBuffer();
9494  Jt(t, e, function () {
9495    return t.bindBuffer(t.PIXEL_PACK_BUFFER, a);
9496  });
9497  var i = 16 * n * r;
9498  return Jt(t, e, function () {
9499    return t.bufferData(t.PIXEL_PACK_BUFFER, i, t.STREAM_READ);
9500  }), Jt(t, e, function () {
9501    return t.readPixels(0, 0, r, n, t.RGBA, t.FLOAT, 0);
9502  }), Jt(t, e, function () {
9503    return t.bindBuffer(t.PIXEL_PACK_BUFFER, null);
9504  }), a;
9505}
9506
9507function ms(t, e, n) {
9508  var r = t,
9509      o = new Float32Array(n);
9510  return r.bindBuffer(r.PIXEL_PACK_BUFFER, e), r.getBufferSubData(r.PIXEL_PACK_BUFFER, 0, o), r.bindBuffer(r.PIXEL_PACK_BUFFER, null), o;
9511}
9512
9513function gs(t, e, n, r, o) {
9514  var a = Xt(n, r),
9515      i = a[0],
9516      s = a[1],
9517      u = new Uint8Array(n * r * 4);
9518  return Jt(t, e, function () {
9519    return t.readPixels(0, 0, i, s, o.downloadTextureFormat, t.UNSIGNED_BYTE, u);
9520  }), new Float32Array(u.buffer);
9521}
9522
9523function ys(t, e, n, r, o, a, i, s) {
9524  var u = t,
9525      c = new Float32Array(function (t, e) {
9526    var n = $t(t, e);
9527    return n[0] * n[1] * 4;
9528  }(a, i));
9529  return u.bindBuffer(u.PIXEL_PACK_BUFFER, e), u.getBufferSubData(u.PIXEL_PACK_BUFFER, 0, c), u.bindBuffer(u.PIXEL_PACK_BUFFER, null), c;
9530}
9531
9532function xs(t, e, n, r) {
9533  var o = new Float32Array(n * r * 4);
9534  return Jt(t, e, function () {
9535    return t.readPixels(0, 0, r, n, t.RGBA, t.FLOAT, o);
9536  }), o;
9537}
9538
9539var bs = Object.freeze({
9540  createVertexShader: rs,
9541  createVertexBuffer: os,
9542  createIndexBuffer: as,
9543  createFloat32MatrixTexture: ss,
9544  createFloat16MatrixTexture: us,
9545  createUnsignedBytesMatrixTexture: cs,
9546  createPackedMatrixTexture: ls,
9547  createFloat16PackedMatrixTexture: hs,
9548  bindVertexProgramAttributeStreams: fs,
9549  uploadDenseMatrixToTexture: ds,
9550  uploadPixelDataToTexture: ps,
9551  createBufferFromOutputTexture: vs,
9552  downloadFloat32MatrixFromBuffer: ms,
9553  downloadByteEncodedFloatMatrixFromOutputTexture: gs,
9554  downloadPackedMatrixFromBuffer: ys,
9555  downloadMatrixFromPackedOutputTexture: xs
9556}),
9557    ws = function () {
9558  function t(t) {
9559    this.outputTexture = null, this.program = null, this.disposed = !1, this.vertexAttrsAreBound = !1, this.itemsToPoll = [];
9560    var e = i().getNumber("WEBGL_VERSION");
9561    null != t ? (this.gl = t, Kt(e, t)) : this.gl = jt(e);
9562    var n = "WEBGL_color_buffer_float";
9563
9564    if (1 === i().getNumber("WEBGL_VERSION")) {
9565      if (this.textureFloatExtension = re(this.gl, this.debug, "OES_texture_float"), Pe(this.gl, "OES_texture_half_float")) this.textureHalfFloatExtension = re(this.gl, this.debug, "OES_texture_half_float");else if (i().get("WEBGL_FORCE_F16_TEXTURES")) throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");
9566      if (this.colorBufferFloatExtension = this.gl.getExtension(n), Pe(this.gl, "EXT_color_buffer_half_float")) this.colorBufferHalfFloatExtension = re(this.gl, this.debug, "EXT_color_buffer_half_float");else if (i().get("WEBGL_FORCE_F16_TEXTURES")) throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");
9567    } else if (n = "EXT_color_buffer_float", Pe(this.gl, n)) this.colorBufferFloatExtension = this.gl.getExtension(n);else {
9568      if (!Pe(this.gl, "EXT_color_buffer_half_float")) throw new Error("GL context does not support color renderable floats");
9569      this.colorBufferHalfFloatExtension = this.gl.getExtension("EXT_color_buffer_half_float");
9570    }
9571
9572    this.vertexBuffer = os(this.gl, this.debug), this.indexBuffer = as(this.gl, this.debug), this.framebuffer = me(this.gl, this.debug), this.textureConfig = Qt(this.gl, this.textureHalfFloatExtension);
9573  }
9574
9575  return Object.defineProperty(t.prototype, "debug", {
9576    get: function () {
9577      return i().getBool("DEBUG");
9578    },
9579    enumerable: !0,
9580    configurable: !0
9581  }), t.prototype.dispose = function () {
9582    var t = this;
9583
9584    if (!this.disposed) {
9585      null != this.program && console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."), null != this.outputTexture && console.warn("Disposing a GPGPUContext that still has a bound output matrix texture.  This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");
9586      var e = this.gl;
9587      Jt(e, this.debug, function () {
9588        return e.finish();
9589      }), Jt(e, this.debug, function () {
9590        return e.bindFramebuffer(e.FRAMEBUFFER, null);
9591      }), Jt(e, this.debug, function () {
9592        return e.deleteFramebuffer(t.framebuffer);
9593      }), Jt(e, this.debug, function () {
9594        return e.bindBuffer(e.ARRAY_BUFFER, null);
9595      }), Jt(e, this.debug, function () {
9596        return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null);
9597      }), Jt(e, this.debug, function () {
9598        return e.deleteBuffer(t.indexBuffer);
9599      }), this.disposed = !0;
9600    }
9601  }, t.prototype.createFloat32MatrixTexture = function (t, e) {
9602    return this.throwIfDisposed(), ss(this.gl, this.debug, t, e, this.textureConfig);
9603  }, t.prototype.createFloat16MatrixTexture = function (t, e) {
9604    return this.throwIfDisposed(), us(this.gl, this.debug, t, e, this.textureConfig);
9605  }, t.prototype.createUnsignedBytesMatrixTexture = function (t, e) {
9606    return this.throwIfDisposed(), cs(this.gl, this.debug, t, e, this.textureConfig);
9607  }, t.prototype.uploadPixelDataToTexture = function (t, e) {
9608    this.throwIfDisposed(), ps(this.gl, this.debug, t, e);
9609  }, t.prototype.uploadDenseMatrixToTexture = function (t, e, n, r) {
9610    this.throwIfDisposed(), ds(this.gl, this.debug, t, e, n, r, this.textureConfig);
9611  }, t.prototype.createFloat16PackedMatrixTexture = function (t, e) {
9612    return this.throwIfDisposed(), hs(this.gl, this.debug, t, e, this.textureConfig);
9613  }, t.prototype.createPackedMatrixTexture = function (t, e) {
9614    return this.throwIfDisposed(), ls(this.gl, this.debug, t, e, this.textureConfig);
9615  }, t.prototype.deleteMatrixTexture = function (t) {
9616    var e = this;
9617    this.throwIfDisposed(), this.outputTexture === t && (Ee(this.gl, this.debug, this.framebuffer), this.outputTexture = null), Jt(this.gl, this.debug, function () {
9618      return e.gl.deleteTexture(t);
9619    });
9620  }, t.prototype.downloadByteEncodedFloatMatrixFromOutputTexture = function (t, e, n) {
9621    var r = this;
9622    return this.downloadMatrixDriver(t, function () {
9623      return gs(r.gl, r.debug, e, n, r.textureConfig);
9624    });
9625  }, t.prototype.downloadPackedMatrixFromBuffer = function (t, e, n, r, o, a) {
9626    return ys(this.gl, t, 0, 0, 0, o, a, this.textureConfig);
9627  }, t.prototype.downloadFloat32MatrixFromBuffer = function (t, e) {
9628    return ms(this.gl, t, e);
9629  }, t.prototype.createBufferFromTexture = function (t, e, n) {
9630    this.bindTextureToFrameBuffer(t);
9631    var r = vs(this.gl, this.debug, e, n, this.textureConfig);
9632    return this.unbindTextureToFrameBuffer(), r;
9633  }, t.prototype.createAndWaitForFence = function () {
9634    var t = this.createFence(this.gl);
9635    return this.pollFence(t);
9636  }, t.prototype.createFence = function (t) {
9637    var e,
9638        n,
9639        r = this;
9640
9641    if (i().getBool("WEBGL_FENCE_API_ENABLED")) {
9642      var o = t,
9643          a = o.fenceSync(o.SYNC_GPU_COMMANDS_COMPLETE, 0);
9644      t.flush(), n = function () {
9645        var t = o.clientWaitSync(a, 0, 0);
9646        return t === o.ALREADY_SIGNALED || t === o.CONDITION_SATISFIED;
9647      }, e = a;
9648    } else i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 ? (e = this.beginQuery(), this.endQuery(), n = function () {
9649      return r.isQueryAvailable(e, i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"));
9650    }) : n = function () {
9651      return !0;
9652    };
9653
9654    return {
9655      query: e,
9656      isFencePassed: n
9657    };
9658  }, t.prototype.downloadMatrixFromPackedTexture = function (t, e, n) {
9659    var r = this;
9660    return this.downloadMatrixDriver(t, function () {
9661      return xs(r.gl, r.debug, e, n);
9662    });
9663  }, t.prototype.createProgram = function (t) {
9664    this.throwIfDisposed();
9665    var e = this.gl,
9666        n = ae(e, this.debug, t),
9667        r = rs(e, this.debug),
9668        o = ce(e, this.debug);
9669    return Jt(e, this.debug, function () {
9670      return e.attachShader(o, r);
9671    }), Jt(e, this.debug, function () {
9672      return e.attachShader(o, n);
9673    }), le(e, this.debug, o), this.debug && he(e, this.debug, o), this.vertexAttrsAreBound || (this.setProgram(o), this.vertexAttrsAreBound = fs(e, this.debug, this.program, this.vertexBuffer)), o;
9674  }, t.prototype.deleteProgram = function (t) {
9675    var e = this;
9676    this.throwIfDisposed(), t === this.program && (this.program = null), null != t && Jt(this.gl, this.debug, function () {
9677      return e.gl.deleteProgram(t);
9678    });
9679  }, t.prototype.setProgram = function (t) {
9680    var e = this;
9681    this.throwIfDisposed(), this.program = t, null != this.program && this.debug && he(this.gl, this.debug, this.program), Jt(this.gl, this.debug, function () {
9682      return e.gl.useProgram(t);
9683    });
9684  }, t.prototype.getUniformLocation = function (t, e, n) {
9685    return void 0 === n && (n = !0), this.throwIfDisposed(), n ? xe(this.gl, this.debug, t, e) : be(this.gl, t, e);
9686  }, t.prototype.getAttributeLocation = function (t, e) {
9687    var n = this;
9688    return this.throwIfDisposed(), Jt(this.gl, this.debug, function () {
9689      return n.gl.getAttribLocation(t, e);
9690    });
9691  }, t.prototype.getUniformLocationNoThrow = function (t, e) {
9692    return this.throwIfDisposed(), this.gl.getUniformLocation(t, e);
9693  }, t.prototype.setInputMatrixTexture = function (t, e, n) {
9694    this.throwIfDisposed(), this.throwIfNoProgram(), we(this.gl, this.debug, this.program, t, e, n);
9695  }, t.prototype.setOutputMatrixTexture = function (t, e, n) {
9696    this.setOutputMatrixTextureDriver(t, n, e);
9697  }, t.prototype.setOutputPackedMatrixTexture = function (t, e, n) {
9698    this.throwIfDisposed();
9699    var r = $t(e, n),
9700        o = r[0],
9701        a = r[1];
9702    this.setOutputMatrixTextureDriver(t, o, a);
9703  }, t.prototype.setOutputMatrixWriteRegion = function (t, e, n, r) {
9704    this.setOutputMatrixWriteRegionDriver(n, t, r, e);
9705  }, t.prototype.setOutputPackedMatrixWriteRegion = function (t, e, n, r) {
9706    throw new Error("setOutputPackedMatrixWriteRegion not implemented.");
9707  }, t.prototype.debugValidate = function () {
9708    null != this.program && he(this.gl, this.debug, this.program), Re(this.gl);
9709  }, t.prototype.executeProgram = function () {
9710    this.throwIfDisposed(), this.throwIfNoProgram();
9711    var t = this.gl;
9712    this.debug && this.debugValidate(), Jt(t, this.debug, function () {
9713      return t.drawElements(t.TRIANGLES, 6, t.UNSIGNED_SHORT, 0);
9714    });
9715  }, t.prototype.blockUntilAllProgramsCompleted = function () {
9716    var t = this;
9717    this.throwIfDisposed(), Jt(this.gl, this.debug, function () {
9718      return t.gl.finish();
9719    });
9720  }, t.prototype.getQueryTimerExtension = function () {
9721    return null == this.disjointQueryTimerExtension && (this.disjointQueryTimerExtension = re(this.gl, this.debug, 2 === i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") ? "EXT_disjoint_timer_query_webgl2" : "EXT_disjoint_timer_query")), this.disjointQueryTimerExtension;
9722  }, t.prototype.getQueryTimerExtensionWebGL2 = function () {
9723    return this.getQueryTimerExtension();
9724  }, t.prototype.getQueryTimerExtensionWebGL1 = function () {
9725    return this.getQueryTimerExtension();
9726  }, t.prototype.beginQuery = function () {
9727    if (2 === i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")) {
9728      var t = this.gl,
9729          e = this.getQueryTimerExtensionWebGL2(),
9730          n = t.createQuery();
9731      return t.beginQuery(e.TIME_ELAPSED_EXT, n), n;
9732    }
9733
9734    var r = this.getQueryTimerExtensionWebGL1(),
9735        o = r.createQueryEXT();
9736    return r.beginQueryEXT(r.TIME_ELAPSED_EXT, o), o;
9737  }, t.prototype.endQuery = function () {
9738    if (2 !== i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")) {
9739      var t = this.getQueryTimerExtensionWebGL1();
9740      t.endQueryEXT(t.TIME_ELAPSED_EXT);
9741    } else {
9742      var e = this.gl,
9743          n = this.getQueryTimerExtensionWebGL2();
9744      e.endQuery(n.TIME_ELAPSED_EXT);
9745    }
9746  }, t.prototype.waitForQueryAndGetTime = function (t) {
9747    return n(this, void 0, void 0, function () {
9748      var e = this;
9749      return r(this, function (n) {
9750        switch (n.label) {
9751          case 0:
9752            return [4, F(function () {
9753              return e.disposed || e.isQueryAvailable(t, i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"));
9754            })];
9755
9756          case 1:
9757            return n.sent(), [2, this.getQueryTime(t, i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))];
9758        }
9759      });
9760    });
9761  }, t.prototype.getQueryTime = function (t, e) {
9762    if (0 === e) return null;
9763
9764    if (2 === e) {
9765      var n = this.gl;
9766      return n.getQueryParameter(t, n.QUERY_RESULT) / 1e6;
9767    }
9768
9769    var r = this.getQueryTimerExtensionWebGL1();
9770    return r.getQueryObjectEXT(t, r.QUERY_RESULT_EXT) / 1e6;
9771  }, t.prototype.isQueryAvailable = function (t, e) {
9772    if (0 === e) return !0;
9773
9774    if (2 === e) {
9775      var n = this.gl,
9776          r = this.getQueryTimerExtensionWebGL2(),
9777          o = n.getQueryParameter(t, n.QUERY_RESULT_AVAILABLE);
9778      return null == this.disjoint && (this.disjoint = this.gl.getParameter(r.GPU_DISJOINT_EXT)), o && !this.disjoint;
9779    }
9780
9781    o = (r = this.getQueryTimerExtensionWebGL1()).getQueryObjectEXT(t, r.QUERY_RESULT_AVAILABLE_EXT);
9782    return null == this.disjoint && (this.disjoint = this.gl.getParameter(r.GPU_DISJOINT_EXT)), o && !this.disjoint;
9783  }, t.prototype.pollFence = function (t) {
9784    var e = this;
9785    return new Promise(function (n) {
9786      e.addItemToPoll(function () {
9787        return t.isFencePassed();
9788      }, function () {
9789        return n();
9790      });
9791    });
9792  }, t.prototype.pollItems = function () {
9793    for (var t = function (t) {
9794      for (var e = 0; e < t.length; ++e) {
9795        if (!t[e]()) break;
9796      }
9797
9798      return e - 1;
9799    }(this.itemsToPoll.map(function (t) {
9800      return t.isDoneFn;
9801    })), e = 0; e <= t; ++e) {
9802      (0, this.itemsToPoll[e].resolveFn)();
9803    }
9804
9805    this.itemsToPoll = this.itemsToPoll.slice(t + 1);
9806  }, t.prototype.addItemToPoll = function (t, e) {
9807    var n = this;
9808    this.itemsToPoll.push({
9809      isDoneFn: t,
9810      resolveFn: e
9811    }), this.itemsToPoll.length > 1 || F(function () {
9812      return n.pollItems(), 0 === n.itemsToPoll.length;
9813    });
9814  }, t.prototype.bindTextureToFrameBuffer = function (t) {
9815    this.throwIfDisposed(), Ce(this.gl, this.debug, t, this.framebuffer), this.debug && Re(this.gl);
9816  }, t.prototype.unbindTextureToFrameBuffer = function () {
9817    null != this.outputTexture ? (Ce(this.gl, this.debug, this.outputTexture, this.framebuffer), this.debug && Re(this.gl)) : Ee(this.gl, this.debug, this.framebuffer);
9818  }, t.prototype.downloadMatrixDriver = function (t, e) {
9819    this.bindTextureToFrameBuffer(t);
9820    var n = e();
9821    return this.unbindTextureToFrameBuffer(), n;
9822  }, t.prototype.setOutputMatrixTextureDriver = function (t, e, n) {
9823    this.throwIfDisposed();
9824    var r = this.gl;
9825    Ce(r, this.debug, t, this.framebuffer), this.debug && Re(r), this.outputTexture = t, Jt(r, this.debug, function () {
9826      return r.viewport(0, 0, e, n);
9827    }), Jt(r, this.debug, function () {
9828      return r.scissor(0, 0, e, n);
9829    });
9830  }, t.prototype.setOutputMatrixWriteRegionDriver = function (t, e, n, r) {
9831    var o = this;
9832    this.throwIfDisposed(), Jt(this.gl, this.debug, function () {
9833      return o.gl.scissor(t, e, n, r);
9834    });
9835  }, t.prototype.throwIfDisposed = function () {
9836    if (this.disposed) throw new Error("Attempted to use disposed GPGPUContext.");
9837  }, t.prototype.throwIfNoProgram = function () {
9838    if (null == this.program) throw new Error("No GPU program is currently set.");
9839  }, t;
9840}();
9841
9842function Cs(t, e) {
9843  if (t.length !== e.length) throw Error("Binary was compiled with " + t.length + " inputs, but was executed with " + e.length + " inputs");
9844  t.forEach(function (t, n) {
9845    var r = t.logicalShape,
9846        o = e[n],
9847        a = o.shape;
9848    if (!S(r, a)) throw Error("Binary was compiled with different shapes than the current args. Shapes " + r + " and " + a + " must match");
9849
9850    if (!t.isUniform || !o.isUniform) {
9851      var i = t.texShape,
9852          s = o.isUniform ? null : o.texData.texShape;
9853      if (!S(i, s)) throw Error("Binary was compiled with different texture shapes than the current args. Shape " + i + " and " + s + " must match");
9854    }
9855  });
9856}
9857
9858var Es = function (t, e, n) {
9859  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t;
9860
9861  for (var r = n.filterWidth, o = n.inChannels, a = n.strideWidth, i = n.strideHeight, s = n.padInfo, u = n.outWidth, c = n.dilationWidth, l = n.dilationHeight, h = n.dataFormat, f = s.left, d = s.top, p = o * r, v = qa(), m = "channelsLast" === h, g = m ? 0 : 1, y = m ? 1 : 2, x = "", b = 0; b <= 1; b++) for (var w = 0; w <= 1; w++) x += "\n          blockIndex = rc.y + " + w + ";\n          pos = rc.x + " + b + ";\n\n          if(blockIndex < " + t[1] + " && pos < " + t[0] + ") {\n            offsetY = int(blockIndex / (" + u + ")) * " + i + " - " + d + ";\n            d0 = offsetY + " + l + " * (pos / " + p + ");\n\n            if(d0 < " + e[g] + " && d0 >= 0) {\n\n              offsetX = int(mod(float(blockIndex), " + u + ".) * " + a + ". - " + f + ".);\n              d1 = offsetX + " + c + " * (int(mod(float(pos), " + p + ".) / " + o + ".));\n\n              if(d1 < " + e[y] + " && d1 >= 0) {\n\n                ch = int(mod(float(pos), " + o + ".));\n\n                if (" + m + ") {\n                  innerDims = vec2(d1, ch);\n                  result[" + (2 * b + w) + "] = getChannel(\n                    getA(d0, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                } else {\n                  innerDims = vec2(d0, d1);\n                  result[" + (2 * b + w) + "] = getChannel(\n                    getA(ch, int(innerDims.x),\n                    int(innerDims.y)), innerDims);\n                }\n              }\n            }\n          }\n        ";
9862
9863  this.userCode = "\n      void main() {\n        ivec2 rc = getOutputCoords();\n\n        vec4 result = vec4(0);\n\n        int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n        vec2 innerDims;\n\n        " + x + "\n\n        " + v.output + " = result;\n      }\n    ";
9864},
9865    Rs = function (t, e, n, r, o) {
9866  this.variableNames = ["x"], this.outputShape = [];
9867  var a,
9868      i = e,
9869      s = t[3] - 1;
9870  this.outputShape = t;
9871  var u = "float(" + n + ") + float(" + r + ") * sum";
9872  a = .5 === o ? "inversesqrt(" + u + ")" : 1 === o ? "1.0/(" + u + ")" : "exp(log(" + u + ") * float(-" + o + "));", this.userCode = "\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n        int d = coords[3];\n        float x = getX(b, r, c, d);\n        float sum = 0.0;
9872\n        for (int j = -" + i + "; j <= " + i + "; j++) {\n          int idx = d + j;\n          if (idx >= 0 && idx <=  " + s + ") {\n            float z = getX(b, r, c, idx);\n            sum += z * z;\n          }\n        }\n        float val = x * " + a + ";\n        setOutput(val);\n      }\n    ";
9873},
9874    Is = function (t, e, n, r, o) {
9875  this.variableNames = ["inputImage", "outputImage", "dy"], this.outputShape = [], this.outputShape = t, this.depth = t[3], this.depthRadius = e, this.bias = n, this.alpha = r, this.beta = o, this.userCode = "\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int r = coords[1];\n        int c = coords[2];\n\n        float result = 0.0;\n        for (int d = 0; d < " + this.depth + "; ++d) {\n          int depthBegin = int(max(0.0, float(d - " + e + ")));\n          int depthEnd = int(min(float(" + this.depth + "),\n              float(d + " + e + " + 1)));\n\n          const int MIN_DEPTH_BEGIN = 0;\n          const int MAX_DEPTH_END = " + this.depth + ";\n\n          float norm = 0.0;\n          for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n            if (k < depthBegin){\n              continue;\n            }\n            else if (k >= depthBegin && k < depthEnd) {\n              norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n            }\n            else {\n              break;\n            }\n          }\n\n          norm = float(" + r + ") * norm + float(" + n + ");\n\n          for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n            if (k < depthBegin){\n              continue;\n            }\n            else if (k >= depthBegin && k < depthEnd){\n              float dyi = -2.0 * float(" + r + ")\n                * float(" + o + ")\n                * getInputImage(b ,r ,c, k) * getOutputImage(b, r, c, d)\n                / norm;\n              if (k == d) {\n                dyi += pow(norm, -1.0 * " + o + ");\n              }\n              if (k == coords[3]) {\n                dyi *= getDy(b, r, c, d);\n                result += dyi;\n              }\n            }\n            else {\n              break;\n            }\n          }\n      }\n      setOutput(result);\n      }\n    ";
9876},
9877    ks = function (t, e, n, r, o) {
9878  this.variableNames = ["x"], this.outputShape = [], this.packedInputs = !0, this.packedOutput = !0;
9879  var a,
9880      i = e,
9881      s = t[3] - 1;
9882  this.outputShape = t;
9883  var u = "float(" + n + ") + float(" + r + ") * sum";
9884  a = .5 === o ? "inversesqrt(" + u + ")" : 1 === o ? "1.0/(" + u + ")" : "exp(log(" + u + ") * float(-" + o + "));", this.userCode = "\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords.x;\n        int r = coords.y;\n        int c = coords.z;\n        int d = coords.w;\n\n        bool hasNextCol = d < " + this.outputShape[3] + ";\n        bool hasNextRow = c < " + this.outputShape[2] + ";\n\n        vec4 sum = vec4(0.);\n        vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n        vec4 xAtOutputCoords = vec4(\n          getChannel(xFragAtOutputCoords, vec2(c, d)),\n          hasNextCol ?\n            getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n          hasNextRow ?\n            getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n        );\n\n        int firstChannel = d - " + i + ";\n        vec2 cache = vec2(0.);\n        if(firstChannel >= 0){\n          vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n          cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n            if(hasNextRow){\n              cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n            }\n        }\n\n        ivec2 depth = ivec2(d, d + 1);\n        for (int j = - " + i + "; j <= " + i + "; j++) {\n          ivec2 idx = depth + j;\n          bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n          bvec2 belowUpperBound = lessThanEqual(idx, ivec2(" + s + "));\n\n          bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n          bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n          if(depthInRange || depthPlusOneInRange){\n            vec4 z = vec4(0.);\n            vec4 xFragAtCurrentDepth;\n            z.xz = cache.xy;\n            if(depthPlusOneInRange && hasNextCol){\n              xFragAtCurrentDepth = idx.y != d ?\n                getX(b, r, c, idx.y) : xFragAtOutputCoords;\n              z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n              if(hasNextRow){\n                z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n              }\n            }\n            cache.xy = z.yw;\n            sum += z * z;\n          }\n        }\n        vec4 result = xAtOutputCoords * " + a + ";\n        setOutput(result);\n      }\n    ";
9885},
9886    Ss = function (t) {
9887  this.variableNames = ["dy", "maxPos"], this.outputShape = t.inShape;
9888  var e = t.strideHeight,
9889      n = t.strideWidth,
9890      r = t.dilationHeight,
9891      o = t.effectiveFilterHeight,
9892      a = t.effectiveFilterWidth,
9893      i = o - 1 - t.padInfo.top,
9894      s = a - 1 - t.padInfo.left,
9895      u = o * a - 1;
9896  this.userCode = "\n      const ivec2 pads = ivec2(" + i + ", " + s + ");\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n\n        ivec2 dyRCCorner = coords.yz - pads;\n        int dyRCorner = dyRCCorner.x;\n        int dyCCorner = dyRCCorner.y;\n\n        // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n        for (int wR = 0; wR < " + o + ";\n          wR += " + r + ") {\n          float dyR = float(dyRCorner + wR) / " + e + ".0;\n\n          if (dyR < 0.0 || dyR >= " + t.outHeight + ".0 || fract(dyR) > 0.0) {\n            continue;\n          }\n          int idyR = int(dyR);\n\n          for (int wC = 0; wC < " + a + "; wC++) {\n            float dyC = float(dyCCorner + wC) / " + n + ".0;\n\n            if (dyC < 0.0 || dyC >= " + t.outWidth + ".0 ||\n                fract(dyC) > 0.0) {\n              continue;\n            }\n            int idyC = int(dyC);\n\n            float dyValue = getDy(b, idyR, idyC, d);\n            int maxPosValue = " + u + " - int(getMaxPos(b, idyR, idyC, d));\n\n            // Get the current value, check it against the value from the\n            // position matrix.\n            int curPosValue = wR * " + a + " + wC;\n            float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n            dotProd += dyValue * mask;\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
9897},
9898    As = function (t) {
9899  this.variableNames = ["dy", "maxPos"], this.outputShape = t.inShape;
9900  var e = t.strideDepth,
9901      n = t.strideHeight,
9902      r = t.strideWidth,
9903      o = t.dilationDepth,
9904      a = t.dilationHeight,
9905      i = t.dilationWidth,
9906      s = t.effectiveFilterDepth,
9907      u = t.effectiveFilterHeight,
9908      c = t.effectiveFilterWidth,
9909      l = s - 1 - t.padInfo.front,
9910      h = u - 1 - t.padInfo.top,
9911      f = c - 1 - t.padInfo.left,
9912      d = s * u * c - 1;
9913  this.userCode = "\n      const ivec3 pads = ivec3(" + l + ", " + h + ", " + f + ");\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n        int dyDCorner = dyCorner.x;\n        int dyRCorner = dyCorner.y;\n        int dyCCorner = dyCorner.z;\n\n        // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n        // dx(x
vendor: 31,258 bytes, lines 9913-10128
9913D, xR, xC, ch).\n        // ? = to be determined. : = across all values in that axis.\n        float dotProd = 0.0;\n\n        for (int wD = 0; wD < " + s + ";\n           wD += " + o + ") {\n          float dyD = float(dyDCorner + wD) / " + e + ".0;\n\n          if (dyD < 0.0 || dyD >= " + t.outDepth + ".0 || fract(dyD) > 0.0) {\n            continue;\n          }\n          int idyD = int(dyD);\n\n          for (int wR = 0; wR < " + u + ";\n              wR += " + a + ") {\n            float dyR = float(dyRCorner + wR) / " + n + ".0;\n\n            if (dyR < 0.0 || dyR >= " + t.outHeight + ".0 ||\n                fract(dyR) > 0.0) {\n              continue;\n            }\n            int idyR = int(dyR);\n\n            for (int wC = 0; wC < " + c + ";\n                wC += " + i + ") {\n              float dyC = float(dyCCorner + wC) / " + r + ".0;\n\n              if (dyC < 0.0 || dyC >= " + t.outWidth + ".0 ||\n                  fract(dyC) > 0.0) {\n                continue;\n              }\n              int idyC = int(dyC);\n\n              float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n              int maxPosValue = " + d + " -\n                  int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n              // Get the current value, check it against the value from the\n              // position matrix.\n              int curPosValue =\n                  wD * " + u + " * " + c + " +\n                  wR * " + c + " + wC;\n              float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n              dotProd += dyValue * mask;\n            }\n          }\n        }\n        setOutput(dotProd);\n      }\n    ";
9914},
9915    Ts = function (t, e, n, r, o, a, i) {
9916  void 0 === n && (n = !1), void 0 === r && (r = !1), void 0 === o && (o = !1), void 0 === a && (a = null), void 0 === i && (i = !1), this.variableNames = ["matrixA", "matrixB"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e;
9917  var s = n ? t[1] : t[2],
9918      u = Math.ceil(s / 2),
9919      c = n ? "i * 2, rc.y" : "rc.y, i * 2",
9920      l = r ? "rc.z, i * 2" : "i * 2, rc.z",
9921      h = n ? ["a.xxyy", "a.zzww"] : ["a.xxzz", "a.yyww"],
9922      f = r ? ["b.xzxz", "b.ywyw"] : ["b.xyxy", "b.zwzw"],
9923      d = "",
9924      p = "";
9925  a && (d = i ? "vec4 activation(vec4 a) {\n          vec4 b = getPreluActivationWeightsAtOutCoords();\n          " + a + "\n        }" : "vec4 activation(vec4 x) {\n          " + a + "\n        }", p = "result = activation(result);");
9926  var v = o ? "result += getBiasAtOutCoords();" : "";
9927  o && this.variableNames.push("bias"), i && this.variableNames.push("preluActivationWeights"), this.userCode = "\n      " + d + "\n\n      const float sharedDimension = " + u + ".0;\n\n      vec4 dot2x2ARowBCol(ivec3 rc) {\n        vec4 result = vec4(0);\n        for (int i = 0; i < " + u + "; i++) {\n          vec4 a = getMatrixA(rc.x, " + c + ");\n          vec4 b = getMatrixB(rc.x, " + l + ");\n\n          // These swizzled products need to be separately added.\n          // See: https://github.com/tensorflow/tfjs/issues/1735\n          result += (" + h[0] + " * " + f[0] + ");\n          result += (" + h[1] + " * " + f[1] + ");\n        }\n        return result;\n      }\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n        vec4 result = dot2x2ARowBCol(rc);\n\n        " + v + "\n\n        " + p + "\n\n        setOutput(result);\n      }\n    ";
9928},
9929    Ds = function () {
9930  function t(t, e, n) {
9931    this.variableNames = ["probs"], this.outputShape = [t, n], this.userCode = "\n      uniform float seed;\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n\n        float r = random(seed);\n        float cdf = 0.0;\n\n        for (int i = 0; i < " + (e - 1) + "; i++) {\n          cdf += getProbs(batch, i);\n\n          if (r < cdf) {\n            setOutput(float(i));\n            return;\n          }\n        }\n\n        // If no other event happened, last event happened.\n        setOutput(float(" + (e - 1) + "));\n      }\n    ";
9932  }
9933
9934  return t.prototype.getCustomSetupFunc = function (t) {
9935    var e = this;
9936    return function (n, r) {
9937      null == e.seedLoc && (e.seedLoc = n.getUniformLocation(r, "seed")), n.gl.uniform1f(e.seedLoc, t);
9938    };
9939  }, t;
9940}(),
9941    Ns = function (t, e, n, r) {
9942  this.variableNames = ["indices"], this.outputShape = [t, e], this.userCode = "\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int index = round(getIndices(coords.x));\n        setOutput(mix(float(" + r + "), float(" + n + "),\n                      float(index == coords.y)));\n      }\n    ";
9943},
9944    Fs = function (t) {
9945  this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0, this.outputShape = t;
9946  var e = t.length;
9947  if (0 === e) this.userCode = "\n        void main() {\n          setOutput(vec4(getA(), 0., 0., 0.));\n        }\n      ";else {
9948    var n = Ha("rc", e),
9949        r = oi(e),
9950        o = function (t, e, n) {
9951      if (1 === t) return "rc > " + e[0];
9952
9953      for (var r = "", o = t - 2; o < t; o++) r += n[o] + " >= " + e[o], o < t - 1 && (r += "||");
9954
9955      return r;
9956    }(e, t, n),
9957        a = function (t, e, n, r) {
9958      if (1 === t) return "";
9959      var o = r.slice(-2);
9960      return "\n    int r = " + o[0] + ";\n    int c = " + o[1] + ";\n    int rp1 = r + 1;\n    int cp1 = c + 1;\n\n    bool cEdge = cp1 >= " + e + ";\n    bool rEdge = rp1 >= " + n + ";\n  ";
9961    }(e, t[t.length - 1], t[t.length - 2], n),
9962        i = function (t, e) {
9963      var n = t.length,
9964          r = function (t, e) {
9965        for (var n = [], r = 0; r <= 1; r++) for (var o = 0; o <= 1; o++) {
9966          for (var a = (0 === r ? "r" : "rp1") + ", " + (0 === o ? "c" : "cp1"), i = 2; i < t; i++) a = e[e.length - 1 - i] + "," + a;
9967
9968          n.push(a);
9969        }
9970
9971        return n;
9972      }(n, e);
9973
9974      return 1 === n ? "getA(rc),\n            rc + 1 >= " + t[0] + " ? 0. : getA(rc + 1),\n            0, 0" : "getA(" + r[0] + "),\n          cEdge ? 0. : getA(" + r[1] + "),\n          rEdge ? 0. : getA(" + r[2] + "),\n          rEdge || cEdge ? 0. : getA(" + r[3] + ")";
9975    }(t, n);
9976
9977    this.userCode = "\n        void main() {\n          " + r + " rc = getOutputCoords();\n\n          if(" + o + ") {\n            setOutput(vec4(0));\n          } else {\n            " + a + "\n\n            setOutput(vec4(" + i + "));\n          }\n        }\n      ";
9978  }
9979};
9980
9981var _s = function (t, e, n) {
9982  this.variableNames = ["x"], this.outputShape = e.map(function (e, n) {
9983    return e[0] + t[n] + e[1];
9984  });
9985  var r = t.length,
9986      o = oi(r),
9987      a = e.map(function (t) {
9988    return t[0];
9989  }).join(","),
9990      i = e.map(function (e, n) {
9991    return e[0] + t[n];
9992  }).join(","),
9993      s = ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, r);
9994  this.userCode = 1 !== r ? "\n      " + o + " start = " + o + "(" + a + ");\n      " + o + " end = " + o + "(" + i + ");\n\n      void main() {\n        " + o + " outC = getOutputCoords();\n        if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n          setOutput(float(" + n + "));\n        } else {\n          " + o + " coords = outC - start;\n          setOutput(getX(" + s + "));\n        }\n      }\n    " : "\n        int start = " + a + ";\n        int end = " + i + ";\n\n        void main() {\n          int outC = getOutputCoords();\n          if (outC < start || outC >= end) {\n            setOutput(float(" + n + "));\n          } else {\n            setOutput(getX(outC - start));\n          }\n        }\n      ";
9995},
9996    Os = function (t, e, n) {
9997  this.variableNames = ["x"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e.map(function (e, n) {
9998    return e[0] + t[n] + e[1];
9999  });
10000
10001  for (var r = t.length, o = oi(r), a = e.map(function (t) {
10002    return t[0];
10003  }).join(","), i = e.map(function (e, n) {
10004    return e[0] + t[n];
10005  }).join(","), s = Ha("rc", r), u = Ha("source", r), c = s[r - 1] + " < " + this.outputShape[r - 1], l = 1 === r ? "source" : "vec2(" + u.slice(-2).join() + ")", h = [o + " rc = outputLoc;", s[r - 1] + " += 1;\n       if(" + c + ") {\n      ", 1 === r ? "" : "}\n       rc = outputLoc;\n       " + s[r - 2] + " += 1;\n       if(" + s[r - 2] + " < " + this.outputShape[r - 2] + ") {", 1 === r ? "" : "  " + s[r - 1] + " += 1;\n         if(" + c + ") {"], f = 1 === r ? "rc < start || rc >= end" : "any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))", d = "", p = 0, v = 1 === r ? 2 : 4; p < v; p++) d += "\n        " + h[p] + "\n        if (" + f + ") {\n          result[" + p + "] = float(" + n + ");\n        } else {\n          " + o + " source = rc - start;\n          result[" + p + "] = getChannel(getX(" + u.join() + "), " + l + ");\n        }\n      ";
10006
10007  d += 1 === r ? "} " : "}}", this.userCode = "\n      const " + o + " start = " + o + "(" + a + ");\n      const " + o + " end = " + o + "(" + i + ");\n\n      void main() {\n        " + o + " outputLoc = getOutputCoords();\n        vec4 result = vec4(0.);\n        " + d + "\n        setOutput(result);\n      }\n    ";
10008},
10009    Ms = function (t, e, n) {
10010  if (this.variableNames = ["x"], "avg" === e && n) throw new Error("Cannot compute positions for average pool.");
10011  var r = t.filterWidth,
10012      o = t.strideHeight,
10013      a = t.strideWidth,
10014      i = t.dilationHeight,
10015      s = t.dilationWidth,
10016      u = t.effectiveFilterHeight,
10017      c = t.effectiveFilterWidth,
10018      l = t.padInfo.top,
10019      h = t.padInfo.left;
10020  this.outputShape = t.outShape;
10021  var f = "avg" === e,
10022      d = "0.0";
10023  if (f || (d = "-1.0 / 1e-20"), n) this.userCode = "\n        const ivec2 strides = ivec2(" + o + ", " + a + ");\n        const ivec2 pads = ivec2(" + l + ", " + h + ");\n\n        void main() {\n          ivec4 coords = getOutputCoords();\n          int batch = coords[0];\n          int d = coords[3];\n\n          ivec2 xRCCorner = coords.yz * strides - pads;\n          int xRCorner = xRCCorner.x;\n          int xCCorner = xRCCorner.y;\n\n          // max/min x(?, ?, d) to get y(yR, yC, d).\n          // ? = to be determined\n          float minMaxValue = 0.0;\n          float minMaxValueFound = 0.0;\n          int minMaxPosition = 0;\n          float avgValue = 0.0;\n\n          for (int wR = 0; wR < " + u + ";\n              wR += " + i + ") {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= " + t.inHeight + ") {\n              continue;\n            }\n\n            for (int wC = 0; wC < " + c + ";\n                wC += " + s + ") {\n              int xC = xCCorner + wC;\n\n              if (xC < 0 || xC >= " + t.inWidth + ") {\n                continue;\n              }\n\n              float value = getX(batch, xR, xC, d);\n\n              // If a min / max value has already been found, use it. If not,\n              // use the current value.\n              float currMinMaxValue = mix(\n                  value, minMaxValue, minMaxValueFound);\n              if (value >= currMinMaxValue) {\n                minMaxValue = value;\n                minMaxValueFound = 1.0;\n                minMaxPosition = wR * " + c + " + wC;\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      ";else {
10024    var p = e + "(" + e + "(" + e + "(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";
10025    "avg" === e && (p = "avgValue / count");
10026    var v = 4 * Math.floor(r / 4),
10027        m = r % 4,
10028        g = "\n      if (" + f + ") {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    ";
10029    this.userCode = "\n      const ivec2 strides = ivec2(" + o + ", " + a + ");\n      const ivec2 pads = ivec2(" + l + ", " + h + ");\n      const float initializationValue = " + d + ";\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float count = 0.0;\n\n      float getValue(int batch, int xR, int xC, int d) {\n        if (xC < 0 || xC >= " + t.inWidth + ") {\n          return initializationValue;\n        }\n        count += 1.0;\n        return getX(batch, xR, xC, d);\n      }\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int batch = coords[0];\n        int d = coords[3];\n\n        ivec2 xRCCorner = coords.yz * strides - pads;\n        int xRCorner = xRCCorner.x;\n        int xCCorner = xRCCorner.y;\n\n        // max/min x(?, ?, d) to get y(yR, yC, d).\n        // ? = to be determined\n        vec4 minMaxValue = vec4(" + d + ");\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wR = 0; wR < " + u + ";\n            wR += " + i + ") {\n          int xR = xRCorner + wR;\n\n          if (xR < 0 || xR >= " + t.inHeight + ") {\n            continue;\n          }\n\n          for (int wC = 0; wC < " + v + "; wC += 4) {\n            int xC = xCCorner + wC * " + s + ";\n\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + " + s + ", d),\n              getValue(batch, xR, xC + 2 * " + s + ", d),\n              getValue(batch, xR, xC + 3 * " + s + ", d)\n            );\n\n            " + g + "\n          }\n\n          int xC = xCCorner + " + v + ";\n          if (" + (1 === m) + ") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              initializationValue,\n              initializationValue,\n              initializationValue\n            );\n\n            " + g + "\n          } else if (" + (2 === m) + ") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + " + s + ", d),\n              initializationValue,\n              initializationValue\n            );\n\n            " + g + "\n          } else if (" + (3 === m) + ") {\n            vec4 values = vec4(\n              getValue(batch, xR, xC, d),\n              getValue(batch, xR, xC + " + s + ", d),\n              getValue(batch, xR, xC + 2 * " + s + ", d),\n              initializationValue\n            );\n\n            " + g + "\n          }\n        }\n        setOutput(" + p + ");\n      }\n    ";
10030  }
10031},
10032    Bs = function (t, e, n) {
10033  if (this.variableNames = ["x"], "avg" === e && n) throw new Error("Cannot compute positions for average pool.");
10034  var r = t.filterWidth,
10035      o = t.strideDepth,
10036      a = t.strideHeight,
10037      i = t.strideWidth,
10038      s = t.dilationDepth,
10039      u = t.dilationHeight,
10040      c = t.dilationWidth,
10041      l = t.effectiveFilterDepth,
10042      h = t.effectiveFilterHeight,
10043      f = t.effectiveFilterWidth,
10044      d = t.padInfo.front,
10045      p = t.padInfo.top,
10046      v = t.padInfo.left;
10047  this.outputShape = t.outShape;
10048  var m = "avg" === e,
10049      g = "0.0";
10050  if (m || (g = "-1.0 / 1e-20"), n) this.userCode = "\n        const ivec3 strides =\n            ivec3(" + o + ", " + a + ", " + i + ");\n        const ivec3 pads = ivec3(" + d + ", " + p + ", " + v + ");\n\n        void main() {\n          ivec5 coords = getOutputCoords();\n          int batch = coords.x;\n          int ch = coords.u;\n\n          ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n          int xDCorner = xCorner.x;\n          int xRCorner = xCorner.y;\n          int xCCorner = xCorner.z;\n\n          // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n          // ? = to be determined\n          float minMaxValue = 0.0;\n          float minMaxValueFound = 0.0;\n          int minMaxPosition = 0;\n\n          for (int wD = 0; wD < " + l + ";\n              wD += " + s + ") {\n            int xD = xDCorner + wD;\n\n            if (xD < 0 || xD >= " + t.inDepth + ") {\n              continue;\n            }\n\n            for (int wR = 0; wR < " + h + ";\n                wR += " + u + ") {\n              int xR = xRCorner + wR;\n\n              if (xR < 0 || xR >= " + t.inHeight + ") {\n                continue;\n              }\n\n              for (int wC = 0; wC < " + f + ";\n                  wC += " + c + ") {\n                int xC = xCCorner + wC;\n\n                if (xC < 0 || xC >= " + t.inWidth + ") {\n                  continue;\n                }\n\n                float value = getX(batch, xD, xR, xC, ch);\n\n                // If a min / max value has already been found, use it. If not,\n                // use the current value.\n                float currMinMaxValue = mix(\n                    value, minMaxValue, minMaxValueFound);\n                if (value >= currMinMaxValue) {\n                  minMaxValue = value;\n                  minMaxValueFound = 1.0;\n                  minMaxPosition =\n                      wD * " + h + " * " + f + " +\n                      wR * " + f + " + wC;;\n                }\n              }\n            }\n          }\n          setOutput(float(minMaxPosition));\n        }\n      ";else {
10051    var y = e + "(" + e + "(" + e + "(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";
10052    "avg" === e && (y = "avgValue / count");
10053    var x = 4 * Math.floor(r / 4),
10054        b = r % 4,
10055        w = "\n      if (" + m + ") {\n        avgValue += dot(values, ones);\n      } else {\n        minMaxValue = max(values, minMaxValue);\n      }\n    ";
10056    this.userCode = "\n      const ivec3 strides =\n        ivec3(" + o + ", " + a + ", " + i + ");\n      const ivec3 pads = ivec3(" + d + ", " + p + ", " + v + ");\n      const float initializationValue = " + g + ";\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float count = 0.0;\n\n      float getValue(int batch, int xD, int xR, int xC, int ch) {\n        if (xC < 0 || xC >= " + t.inWidth + ") {\n          return initializationValue;\n        }\n        count += 1.0;\n        return getX(batch, xD, xR, xC, ch);\n      }\n\n      void main() {\n        ivec5 coords = getOutputCoords();\n        int batch = coords.x;\n        int ch = coords.u;\n\n        ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n        int xDCorner = xCorner.x;\n        int xRCorner = xCorner.y;\n        int xCCorner = xCorner.z;\n\n        // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n        // ? = to be determined\n        vec4 minMaxValue = vec4(" + g + ");\n        float avgValue = 0.0;\n        count = 0.0;\n\n        for (int wD = 0; wD < " + l + ";\n            wD += " + s + ") {\n          int xD = xDCorner + wD;\n\n          if (xD < 0 || xD >= " + t.inDepth + ") {\n            continue;\n          }\n\n          for (int wR = 0; wR < " + h + ";\n            wR += " + u + ") {\n            int xR = xRCorner + wR;\n\n            if (xR < 0 || xR >= " + t.inHeight + ") {\n              continue;\n            }\n\n            for (int wC = 0; wC < " + x + "; wC += 4) {\n              int xC = xCCorner + wC * " + c + ";\n\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + " + c + ", ch),\n                getValue(batch, xD, xR, xC + 2 * " + c + ", ch),\n                getValue(batch, xD, xR, xC + 3 * " + c + ", ch)\n              );\n\n              " + w + "\n            }\n\n            int xC = xCCorner + " + x + ";\n            if (" + (1 === b) + ") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                initializationValue,\n                initializationValue,\n                initializationValue\n              );\n\n              " + w + "\n            } else if (" + (2 === b) + ") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + " + c + ", ch),\n                initializationValue,\n                initializationValue\n              );\n\n              " + w + "\n            } else if (" + (3 === b) + ") {\n              vec4 values = vec4(\n                getValue(batch, xD, xR, xC, ch),\n                getValue(batch, xD, xR, xC + " + c + ", ch),\n                getValue(batch, xD, xR, xC + 2 * " + c + ", ch),\n                initializationValue\n              );\n\n              " + w + "\n            }\n          }\n          setOutput(" + y + ");\n        }\n      }\n    ";
10057  }
10058},
10059    Ps = function (t, e) {
10060  this.variableNames = ["x"];
10061  var n = t.windowSize,
10062      r = t.batchSize,
10063      o = t.inSize,
10064      a = Math.ceil(o / n);
10065  this.outputShape = [r, a];
10066  var i = "0.0",
10067      s = "";
10068  "prod" === e ? i = "1.0" : "min" === e ? (i = "1.0 / 1e-20", s = "min") : "max" === e && (i = "-1.0 / 1e-20", s = "max");
10069  var u = e + "(" + e + "(" + e + "(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])";
10070  "sum" === e ? u = "sumValue" : "prod" === e ? u = "prodValue" : "all" === e ? u = "allValue" : "any" === e && (u = "anyValue");
10071  var c = 4 * Math.floor(n / 4),
10072      l = n % 4,
10073      h = "\n      if (" + ("sum" === e) + ") {\n        sumValue += dot(values, ones);\n      } else if (" + ("prod" === e) + ") {\n        vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n        prodValue *= tmp[0] * tmp[1];\n      } else {\n        minMaxValue = " + s + "(values, minMaxValue);\n      }\n    ",
10074      f = "vec4";
10075  "all" === e ? (i = "1.0", h = "\n        bool reducedAllValue = all(values);\n        float floatedReducedAllValue = float(reducedAllValue);\n        allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n      ", f = "bvec4") : "any" === e && (i = "0.0", h = "\n        bool reducedAnyValue = any(values);\n        float floatedReducedAnyValue = float(reducedAnyValue);\n        anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n      ", f = "bvec4");
10076  var d = "";
10077  o % n > 0 && (d = "\n        if (inIdx < 0 || inIdx >= " + o + ") {\n          return initializationValue;\n        }\n      "), this.userCode = "\n      const float initializationValue = " + i + ";\n      const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n      float getValue(int batch, int inIdx) {\n        " + d + "\n        return getX(batch, inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = outIdx * " + n + ";\n\n        vec4 minMaxValue = vec4(" + i + ");\n        float prodValue = 1.0;\n        float sumValue = 0.0;\n        float allValue = 1.0;\n        float anyValue = 0.0;\n\n        for (int i = 0; i < " + c + "; i += 4) {\n          int inIdx = inOffset + i;\n          " + f + " values = " + f + "(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          " + h + "\n        }\n\n        int inIdx = inOffset + " + c + ";\n        if (" + (1 === l) + ") {\n          " + f + " values = " + f + "(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          " + h + "\n        } else if (" + (2 === l) + ") {\n          " + f + " values = " + f + "(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          " + h + "\n        } else if (" + (3 === l) + ") {\n          " + f + " values = " + f + "(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            initializationValue\n          );\n\n          " + h + "\n        }\n        setOutput(" + u + ");\n      }\n    ";
10078},
10079    Ls = function (t, e) {
10080  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t;
10081
10082  for (var n = "", r = 0; r < 4; r++) {
10083    var o = "thisRC = rc;";
10084    r % 2 == 1 && (o += "thisRC.z += 1;"), r > 1 && (o += "thisRC.y += 1;"), n += "\n        " + o + "\n        " + (r > 0 ? "if(thisRC.y < rows && thisRC.z < cols){" : "") + "\n          int flatIndex = getFlatIndex(thisRC);\n\n          ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n          vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n          result[" + r + "] =\n            getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n        " + (r > 0 ? "}" : "") + "\n      ";
10085  }
10086
10087  this.userCode = "\n      \n    ivec3 inputCoordsFromReshapedOutCoords(int index) {\n      " + Ka(["r", "c", "d"], e) + "\n      return ivec3(r, c, d);\n    }\n  \n      " + ja(t) + "\n\n      void main() {\n        ivec3 rc = getOutputCoords();\n\n        vec4 result = vec4(0.);\n\n        ivec3 thisRC;\n        int rows = " + t[1] + ";\n        int cols = " + t[2] + ";\n\n        " + n + "\n\n        setOutput(result);\n      }\n    ";
10088};
10089
10090var Ws = function (t, e, n) {
10091  this.variableNames = ["dy"], this.outputShape = [], this.outputShape = e.shape;
10092  var r = e.shape,
10093      o = r[1],
10094      a = r[2],
10095      i = t.shape,
10096      s = i[1],
10097      u = i[2],
10098      c = [n && s > 1 ? o - 1 : o, n && u > 1 ? a - 1 : a],
10099      l = [n && s > 1 ? s - 1 : s, n && u > 1 ? u - 1 : u],
10100      h = c[0] / l[0],
10101      f = c[1] / l[1],
10102      d = 1 / h,
10103      p = 1 / f,
10104      v = 2 * Math.ceil(d) + 2,
10105      m = 2 * Math.ceil(p) + 2;
10106  this.userCode = "\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float(" + h + ");\n        const float widthScale = float(" + f + ");\n\n        const float invHeightScale = float(" + d + ");\n        const float invWidthScale = float(" + p + ");\n\n        const int winHeight = int(" + v + ");\n        const int winWidth = int(" + m + ");\n\n        // Compute bounds for where in dy we will look\n        float startRLerp = floor(float(r) * invHeightScale);\n        int startDyR = int(startRLerp - float(winHeight / 2));\n\n        float startCLerp = floor(float(c) * invWidthScale);\n        int startDyC = int(startCLerp - float(winWidth / 2));\n\n        // Loop over dy\n        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n          int dyR = dyROffset + startDyR;\n\n          // Guard against the window exceeding the bounds of dy\n          if (dyR < 0 || dyR >= " + s + ") {\n            continue;\n          }\n\n          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n            int dyC = dyCOffset + startDyC;\n\n            // Guard against the window exceeding the bounds of dy\n            if (dyC < 0 || dyC >= " + u + ") {\n              continue;\n            }\n\n            float dxR = float(dyR) * heightScale;\n            int topDxRIndex = int(floor(dxR));\n            int bottomDxRIndex = int(min(ceil(dxR), " + (o - 1) + ".0));\n            float dxRLerp = dxR - float(topDxRIndex);\n            float inverseDxRLerp = 1.0 - dxRLerp;\n\n            float dxC = float(dyC) * widthScale;\n            int leftDxCIndex = int(floor(dxC));\n            int rightDxCIndex = int(min(ceil(dxC), " + (a - 1) + ".0));\n            float dxCLerp = dxC - float(leftDxCIndex);\n            float inverseDxCLerp = 1.0 - dxCLerp;\n\n            if (r == topDxRIndex && c == leftDxCIndex) {\n              // topLeft\n              accumulator +=\n                getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n            }\n\n            if (r == topDxRIndex && c == rightDxCIndex) {\n              // topRight\n              accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n            }\n\n            if (r == bottomDxRIndex && c == leftDxCIndex) {\n              // bottomLeft\n              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n            }\n\n            if (r == bottomDxRIndex && c == rightDxCIndex) {\n              // bottomRight\n              accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n            }\n          }\n        }\n        // End loop over dy\n\n        setOutput(accumulator);\n      }\n    ";
10107},
10108    Us = function (t, e, n, r) {
10109  this.variableNames = ["A"], this.outputShape = [];
10110  var o = t[0],
10111      a = t[1],
10112      i = t[2],
10113      s = t[3];
10114  this.outputShape = [o, e, n, s];
10115  var u = [r && e > 1 ? a - 1 : a, r && n > 1 ? i - 1 : i],
10116      c = [r && e > 1 ? e - 1 : e, r && n > 1 ? n - 1 : n];
10117  this.userCode = "\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          " + u[0] / c[0] + ",\n          " + u[1] / c[1] + ");\n      const vec2 inputShapeRC = vec2(" + a + ".0, " + i + ".0);\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        ivec2 yRC = coords.yz;\n\n        // Fractional source index.\n        vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n        // Compute the four integer indices.\n        ivec2 sourceFloorRC = ivec2(sourceFracIndexRC);\n        ivec2 sourceCeilRC = ivec2(\n          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n        float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n        float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n        float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n        float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n        vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n        float top = topLeft + (topRight - topLeft) * fracRC.y;\n        float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n        float newValue = top + (bottom - top) * fracRC.x;\n\n        setOutput(newValue);\n      }\n    ";
10118},
10119    Vs = function (t, e, n, r) {
10120  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = [];
10121  var o = t[0],
10122      a = t[1],
10123      i = t[2],
10124      s = t[3];
10125  this.outputShape = [o, e, n, s];
10126  var u = [r && e > 1 ? a - 1 : a, r && n > 1 ? i - 1 : i],
10127      c = [r && e > 1 ? e - 1 : e, r && n > 1 ? n - 1 : n];
10128  this.userCode = "\n      const vec3 effectiveInputOverOutputRatioRC = vec3(\n          " + u[0] / c[0] + ",\n          " + u[1] / c[1] + ",\n          " + u[1] / c[1] + ");\n      const vec3 inputShapeRC = vec3(" + a + ".0, " + i + ".0,\n                                     " + i + ".0);\n\n      float getAValue(int b, int r, int c, int d) {\n        return getChannel(getA(b, r, c, d), vec2(c, d));\n      }\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        // Calculate values for next column in yRC.z.\n        ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n        // Fractional source index.\n        vec3 sourceFracIndexRC = vec3(yRC) * effectiveInputOverOutputRatioRC;\n\n        // Compute the four integer indices.\n        ivec3 sourceFloorRC = ivec3(sourceFracIndexRC);\n        ivec3 sourceCeilRC = ivec3(\n          min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n        // Should we calculate next column and row elements in 2x2 packed cell.\n        bool hasNextCol = d < " + (s - 1) + ";\n        bool hasNextRow = coords.z < " + (n - 1) + "
vendor: 2,064 bytes, line 10128
10128;\n\n        // In parallel, construct four corners for all four components in\n        // packed 2x2 cell.\n        vec4 topLeft = vec4(\n          getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 bottomLeft = vec4(\n          getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n        vec4 topRight = vec4(\n          getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec4 bottomRight = vec4(\n          getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n          hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n                     : 0.0,\n          hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n                     : 0.0,\n          (hasNextRow && hasNextCol) ?\n            getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n        vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n        vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n        vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n        vec4 newValue = mix(top, bottom, fracRC.x);\n\n        setOutput(newValue);\n      }\n    
vendor: 7,315 bytes, lines 10128-10215
10128";
10129},
10130    zs = function (t, e, n) {
10131  this.variableNames = ["dy"], this.outputShape = [], this.outputShape = e.shape;
10132  var r = e.shape,
10133      o = r[1],
10134      a = r[2],
10135      i = t.shape,
10136      s = i[1],
10137      u = i[2],
10138      c = [n && s > 1 ? o - 1 : o, n && u > 1 ? a - 1 : a],
10139      l = [n && s > 1 ? s - 1 : s, n && u > 1 ? u - 1 : u],
10140      h = c[0] / l[0],
10141      f = c[1] / l[1],
10142      d = 1 / h,
10143      p = 1 / f,
10144      v = 2 * Math.ceil(d) + 2,
10145      m = 2 * Math.ceil(p) + 2;
10146  this.userCode = "\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        int r = coords[1];\n        int c = coords[2];\n\n        float accumulator = 0.0;\n\n        const float heightScale = float(" + h + ");\n        const float widthScale = float(" + f + ");\n\n        const float invHeightScale = float(" + d + ");\n        const float invWidthScale = float(" + p + ");\n\n        const int winHeight = int(" + v + ");\n        const int winWidth = int(" + m + ");\n\n        // Compute bounds for where in dy we will look\n        float startRLerp = floor(float(r) * invHeightScale);\n        int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n        float startCLerp = floor(float(c) * invWidthScale);\n        int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n        // Loop over dy\n        for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n          int dyR = dyROffset + startDyR;\n\n          // Guard against the window exceeding the bounds of dy\n          if (dyR < 0 || dyR >= " + s + ") {\n            continue;\n          }\n\n          for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n            int dyC = dyCOffset + startDyC;\n\n            // Guard against the window exceeding the bounds of dy\n            if (dyC < 0 || dyC >= " + u + ") {\n              continue;\n            }\n\n            float sourceFracRow =\n              float(" + c[0] + ") *\n                (float(dyR) / float(" + l[0] + "));\n\n            float sourceFracCol =\n                float(" + c[1] + ") *\n                  (float(dyC) / float(" + l[1] + "));\n\n            int sourceNearestRow = int(min(\n                float(int(" + o + ") - 1),\n                " + n + " ? float(round(sourceFracRow)) :\n                                  float(floor(sourceFracRow))));\n\n            int sourceNearestCol = int(min(\n                float(int(" + a + ") - 1),\n                " + n + " ? float(round(sourceFracCol)) :\n                                  float(floor(sourceFracCol))));\n\n            if (r == sourceNearestRow && c == sourceNearestCol) {\n              accumulator += getDy(b, dyR, dyC, d);\n            }\n          }\n        }\n        // End loop over dy\n\n        setOutput(accumulator);\n      }\n    ";
10147},
10148    Gs = function (t, e, n, r) {
10149  this.variableNames = ["A"], this.outputShape = [];
10150  var o = t[0],
10151      a = t[1],
10152      i = t[2],
10153      s = t[3];
10154  this.outputShape = [o, e, n, s];
10155  var u = [r && e > 1 ? a - 1 : a, r && n > 1 ? i - 1 : i],
10156      c = [r && e > 1 ? e - 1 : e, r && n > 1 ? n - 1 : n],
10157      l = r ? "0.5" : "0.0";
10158  this.userCode = "\n      const vec2 effectiveInputOverOutputRatioRC = vec2(\n          " + u[0] / c[0] + ",\n          " + u[1] / c[1] + ");\n      const vec2 inputShapeRC = vec2(" + a + ".0, " + i + ".0);\n\n      void main() {\n        ivec4 coords = getOutputCoords();\n        int b = coords[0];\n        int d = coords[3];\n        ivec2 yRC = coords.yz;\n\n        // Fractional source index.\n        vec2 sourceFracIndexRC = vec2(yRC) * effectiveInputOverOutputRatioRC;\n\n        // Compute the coordinators of nearest neighbor point.\n        ivec2 sourceNearestRC = ivec2(\n          min(inputShapeRC - 1.0, floor(sourceFracIndexRC + " + l + ")));\n\n        float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n        setOutput(newValue);\n      }\n    ";
10159},
10160    Hs = function (t, e) {
10161  this.variableNames = ["x"];
10162  var n = t.length;
10163  if (n > 4) throw new Error("WebGL backend: Reverse of rank-" + n + " tensor is not yet supported");
10164
10165  if (this.outputShape = t, 1 !== n) {
10166    var r = t.map(function (n, r) {
10167      return function (n) {
10168        return -1 !== e.indexOf(n) && 1 !== t[n] ? t[n] + " - coords[" + n + "] - 1" : "coords[" + n + "]";
10169      }(r);
10170    }).join(","),
10171        o = oi(n);
10172    this.userCode = "\n      void main() {\n        " + o + " coords = getOutputCoords();\n        setOutput(getX(" + r + "));\n      }\n    ";
10173  } else this.userCode = "\n        void main() {\n          int coord = getOutputCoords();\n          setOutput(getX(" + t[0] + " - coord - 1));\n        }\n      ";
10174},
10175    qs = function (t, e) {
10176  this.variableNames = ["x"], this.packedInputs = !0, this.packedOutput = !0;
10177  var n = t.length;
10178  if (n > 4) throw new Error("WebGL backend: Reverse of rank-" + n + " tensor is not yet supported");
10179  this.outputShape = t;
10180  var r = Ha("rc", n),
10181      o = r[n - 1] + " + 1 < " + this.outputShape[n - 1],
10182      a = r[n - 2] + " + 1 < " + this.outputShape[n - 2],
10183      i = oi(n);
10184
10185  function s(n) {
10186    var r = t.map(function (r, o) {
10187      return function (n, r) {
10188        return -1 !== e.indexOf(n) && 1 !== t[n] ? t[n] + " - " + r[n] + " - 1" : "" + r[n];
10189      }(o, n);
10190    });
10191    return "getChannel(getX(" + r.join(",") + "), vec2(" + r.slice(-2).join(",") + "))";
10192  }
10193
10194  this.userCode = 1 === n ? "\n        void main(){\n          int rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = getChannel(getX(" + t[0] + " - rc - 1),\n            " + t[0] + " - rc - 1);\n          if(" + o + "){\n              result.g = getChannel(getX(" + t[0] + " - (rc  + 1) - 1),\n                " + t[0] + " - (rc  + 1) - 1);\n          }\n          setOutput(result);\n        }\n      " : "\n        void main() {\n          " + i + " rc = getOutputCoords();\n          vec4 result = vec4(0.);\n          result.r = " + function (t) {
10195    return s(t);
10196  }(r.slice()) + ";\n          if(" + o + "){\n            result.g = " + function (t) {
10197    return t[n - 1] = "(" + t[n - 1] + " + 1)", s(t);
10198  }(r.slice()) + ";\n          }\n          if(" + a + ") {\n            result.b = " + function (t) {
10199    return t[n - 2] = "(" + t[n - 2] + " + 1)", s(t);
10200  }(r.slice()) + ";\n            if(" + o + ") {\n              result.a = " + function (t) {
10201    return t[n - 1] = "(" + t[n - 1] + " + 1)", t[n - 2] = "(" + t[n - 2] + " + 1)", s(t);
10202  }(r.slice()) + ";\n            }\n          }\n          setOutput(result);\n        }\n    ";
10203},
10204    Ks = function (t, e, n, r, o, a, i) {
10205  void 0 === i && (i = !0), this.variableNames = ["updates", "indices", "defaultValue"], this.outputShape = a;
10206  var s = oi(o.length),
10207      u = oi(a.length),
10208      c = "";
10209  1 === n ? c = "i" : 2 === n && (c = "i, j");
10210  var l = "getIndices(" + c + ")",
10211      h = "";
10212  1 === r ? h = "i" : 2 === r && (h = "i, coords[1]");
10213  var f = "getUpdates(" + h + ")",
10214      d = e > 1 ? "strides[j]" : "strides";
10215  this.userCode = "\n        " + s + " strides = " + s + "(" + o + ");\n\n        void main() {\n          " + u + " coords = getOutputCoords();\n          float sum = 0.0;\n          bool found = false;\n          for (int i = 0; i < " + t + ";
10215 i++) {\n            int flattenedIndex = 0;\n            for (int j = 0; j < " + e + "; j++) {\n              int index = round(" + l + ");\n              flattenedIndex += index * " + d + ";\n            }\n            if (flattenedIndex == coords[0]) {\n              sum += " + f + ";\n              found = true;\n            }\n          }\n          setOutput(mix(getDefaultValue(), sum, float(found)));\n        }\n      ";
10216},
10217    js = function (t, e) {
10218  this.variableNames = ["x", "segmentIds"];
10219  var n = t.windowSize,
10220      r = t.batchSize,
10221      o = t.inSize,
10222      a = t.numSegments,
10223      i = a * Math.ceil(o / n);
10224  this.outputShape = [r, i];
10225  var s = 4 * Math.floor(n / 4),
10226      u = n % 4,
10227      c = "\n        sumValue += dot(values, segFilter);\n    ",
10228      l = "";
10229  o % n > 0 && (l = "\n        if (inIdx < 0 || inIdx >= " + o + ") {\n          return initializationValue;\n        }\n      ");
10230  var h = "";
10231  o % n > 0 && (h = "\n        if (inIdx < 0 || inIdx >= " + o + ") {\n          return -1.0;\n        }\n      "), this.userCode = "\n      const float initializationValue = 0.0;\n\n      float getValue(int batch, int inIdx) {\n        " + l + "\n        return getX(batch, inIdx);\n      }\n\n      float getSegmentIdAtIndex(int inIdx) {\n        " + h + "\n        return getSegmentIds(inIdx);\n      }\n\n      void main() {\n        ivec2 coords = getOutputCoords();\n        int batch = coords[0];\n        int outIdx = coords[1];\n        int inOffset = int(floor(float(outIdx) / float(\n          " + a + ")) * float(" + n + "));\n        int currentSeg = int(mod(float(outIdx), float(" + a + ")));\n\n        float sumValue = 0.0;\n\n        for (int i = 0; i < " + s + "; i += 4) {\n          int inIdx = inOffset + i;\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            getValue(batch, inIdx + 3)\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n          );\n\n          " + c + "\n        }\n\n        int inIdx = inOffset + " + s + ";\n        if (" + (1 === u) + ") {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            initializationValue,\n            initializationValue,\n            initializationValue\n          );\n\n          int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            0,\n            0,\n            0\n          );\n\n          " + c + "\n        } else if (" + (2 === u) + ") {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            initializationValue,\n            initializationValue\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n              0,\n              0\n          );\n\n          " + c + "\n        } else if (" + (3 === u) + ") {\n          vec4 values = vec4(\n            getValue(batch, inIdx),\n            getValue(batch, inIdx + 1),\n            getValue(batch, inIdx + 2),\n            initializationValue\n          );\n\n          vec4 segFilter = vec4(\n            int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n            int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n            0\n          );\n\n          " + c + "\n        }\n        setOutput(sumValue);\n      }\n    ";
10232},
10233    Xs = function (t, e, n) {
10234  var r, o;
10235  if (this.variableNames = ["c", "a", "b"], this.outputShape = e, n > 4) throw Error("Where for rank " + n + " is not yet supported");
10236  if (1 === n) o = "resRC", r = "resRC";else {
10237    for (var a = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], i = [], s = [], u = 0; u < e.length; u++) s.push("" + a[u]), u < t && i.push("" + a[u]);
10238
10239    r = i.join(), o = s.join();
10240  }
10241  var c = oi(n);
10242  this.userCode = "\n      void main() {\n        " + c + " resRC = getOutputCoords();\n        float cVal = getC(" + r + ");\n        if (cVal >= 1.0) {\n          setOutput(getA(" + o + "));\n        } else {\n          setOutput(getB(" + o + "));\n        }\n      }\n    ";
10243},
10244    Ys = function () {
10245  function t(t) {
10246    this.variableNames = ["source"], this.outputShape = t, this.rank = t.length;
10247
10248    var e,
10249        n = oi(this.rank),
10250        r = "uniform int start[" + this.rank + "];",
10251        o = function (t) {
10252      if (1 === t) return "sourceLoc";
10253      if (t <= 6) return $s.slice(0, t).map(function (t) {
10254        return "sourceLoc." + t;
10255      }).join(",");
10256      throw Error("Slicing for rank " + t + " is not yet supported");
10257    }(this.rank);
10258
10259    e = "\n        " + n + " sourceLoc;\n        " + n + " coords = getOutputCoords();\n        " + t.map(function (t, e) {
10260      return "sourceLoc." + $s[e] + " = start[" + e + "] + coords." + $s[e] + ";";
10261    }).join("\n") + "\n      ", this.userCode = "\n      " + r + "\n      void main() {\n        " + e + "\n        setOutput(getSource(" + o + "));\n      }\n    ";
10262  }
10263
10264  return t.prototype.getCustomSetupFunc = function (t) {
10265    var e = this;
10266    if (t.length !== this.rank) throw Error("The rank (" + this.rank + ") of the program must match the length of start (" + t.length + ")");
10267    return function (n, r) {
10268      null == e.startLoc && (e.startLoc = n.getUniformLocationNoThrow(r, "start"), null == e.startLoc) || n.gl.uniform1iv(e.startLoc, t);
10269    };
10270  }, t;
10271}(),
10272    $s = ["x", "y", "z", "w", "u", "v"];
10273
10274var Qs = function () {
10275  function t(t) {
10276    this.variableNames = ["source"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t, this.rank = t.length;
10277    var e = oi(this.rank),
10278        n = Ha("coords", this.rank),
10279        r = Ha("sourceLoc", this.rank),
10280        o = 1 === this.rank ? "sourceLoc" : "vec2(" + r.slice(-2).join() + ")",
10281        a = "getChannel(getSource(" + r.join() + "), " + o + ")",
10282        i = "\n      result.x = " + a + ";\n      if (++" + n[this.rank - 1] + " < " + t[this.rank - 1] + ") {\n        ++" + r[this.rank - 1] + ";\n        result.y = " + a + ";\n        --" + r[this.rank - 1] + ";\n      }\n    ",
10283        s = 1 === this.rank ? "" : "\n      --" + n[this.rank - 1] + ";\n      if (++" + n[this.rank - 2] + " < " + t[this.rank - 2] + ") {\n        ++" + r[this.rank - 2] + ";\n        result.z = " + a + ";\n        if (++" + n[this.rank - 1] + " < " + t[this.rank - 1] + ") {\n          ++" + r[this.rank - 1] + ";\n          result.w = " + a + ";\n        }\n      }\n    ",
10284        u = this.rank <= 4 ? "sourceLoc = coords +\n            " + e + "(" + t.map(function (t, e) {
10285      return "start[" + e + "]";
10286    }).join() + ");" : t.map(function (t, e) {
10287      return r[e] + " = " + n[e] + " + start[" + e + "];";
10288    }).join("\n");
10289    this.userCode = "\n      uniform int start[" + this.rank + "];\n      void main() {\n        " + e + " coords = getOutputCoords();\n        " + e + " sourceLoc;\n        " + u + "\n        vec4 result = vec4(0.);\n        " + i + "\n        " + s + "\n        setOutput(result);\n      }\n    ";
10290  }
10291
10292  return t.prototype.getCustomSetupFunc = function (t) {
10293    var e = this;
10294    if (t.length !== this.rank) throw Error("The rank (" + this.rank + ") of the program must match the length of start (" + t.length + ")");
10295    return function (n, r) {
10296      null == e.startLoc && (e.startLoc = n.getUniformLocationNoThrow(r, "start"), null == e.startLoc) || n.gl.uniform1iv(e.startLoc, t);
10297    };
10298  }, t;
10299}(),
10300    Js = function (t, e, n) {
10301  this.variableNames = ["x"], this.outputShape = n;
10302  var r = n.length,
10303      o = oi(n.length),
10304      a = oi(n.length),
10305      i = "";
10306  if (1 === r) i = "coords * strides + begin";else {
10307    var s = 0;
10308    i = n.map(function (t, e) {
10309      return s++, 1 === n.length ? "coords * strides[" + e + "] + begin[" + e + "]" : "coords[" + (s - 1) + "] * strides[" + e + "] + begin[" + e + "]";
10310    }).join(",");
10311  }
10312  this.userCode = "\n      " + o + " begin = " + o + "(" + t + ");\n      " + o + " strides = " + o + "(" + e + ");\n\n      void main() {\n        " + a + " coords = getOutputCoords();\n        setOutput(getX(" + i + "));\n      }\n    ";
10313},
10314    Zs = function () {
10315  function t(t) {
10316    this.gpgpu = t, this.numUsedTextures = 0, this.numFreeTextures = 0, this.freeTextures = {}, this.logEnabled = !1, this.usedTextures = {};
10317  }
10318
10319  return t.prototype.acquireTexture = function (t, e, n) {
10320    var r,
10321        o = tu(e, n),
10322        a = eu(t, o, n);
10323
10324    if (a in this.freeTextures || (this.freeTextures[a] = []), a in this.usedTextures || (this.usedTextures[a] = []), this.freeTextures[a].length > 0) {
10325      this.numFreeTextures--, this.numUsedTextures++, this.log();
10326      var i = this.freeTextures[a].shift();
10327      return this.usedTextures[a].push(i), i;
10328    }
10329
10330    return this.numUsedTextures++, this.log(), o === Gt.PACKED_2X2_FLOAT32 ? r = this.gpgpu.createPackedMatrixTexture(t[0], t[1]) : o === Gt.PACKED_2X2_FLOAT16 ? r = this.gpgpu.createFloat16PackedMatrixTexture(t[0], t[1]) : o === Gt.UNPACKED_FLOAT32 ? r = this.gpgpu.createFloat32MatrixTexture(t[0], t[1]) : o === Gt.UNPACKED_FLOAT16 ? r = this.gpgpu.createFloat16MatrixTexture(t[0], t[1]) : o === Gt.PACKED_4X1_UNSIGNED_BYTE && (r = this.gpgpu.createUnsignedBytesMatrixTexture(t[0], t[1])), this.usedTextures[a].push(r), r;
10331  }, t.prototype.releaseTexture = function (t, e, n, r) {
10332    if (null != this.freeTextures) {
10333      var o = eu(e, tu(n, r), r);
10334      o in this.freeTextures || (this.freeTextures[o] = []), this.freeTextures[o].push(t), this.numFreeTextures++, this.numUsedTextures--;
10335      var a = this.usedTextures[o],
10336          i = a.indexOf(t);
10337      if (i < 0) throw new Error("Cannot release a texture that was never provided by this texture manager");
10338      a.splice(i, 1), this.log();
10339    }
10340  }, t.prototype.log = function () {
10341    if (this.logEnabled) {
10342      var t = this.numFreeTextures + this.numUsedTextures;
10343      console.log("Free/Used", this.numFreeTextures + " / " + this.numUsedTextures, "(" + t + ")");
10344    }
10345  }, t.prototype.getNumUsedTextures = function () {
10346    return this.numUsedTextures;
10347  }, t.prototype.getNumFreeTextures = function () {
10348    return this.numFreeTextures;
10349  }, t.prototype.dispose = function () {
10350    var t = this;
10351
10352    if (null != this.freeTextures) {
10353      for (var e in this.freeTextures) this.freeTextures[e].forEach(function (e) {
10354        t.gpgpu.deleteMatrixTexture(e);
10355      });
10356
10357      for (var e in this.usedTextures) this.usedTextures[e].forEach(function (e) {
10358        t.gpgpu.deleteMatrixTexture(e);
10359      });
10360
10361      this.freeTextures = null, this.usedTextures = null, this.numUsedTextures = 0, this.numFreeTextures = 0;
10362    }
10363  }, t;
10364}();
10365
10366function tu(t, e) {
10367  if (t === zt.UPLOAD) return Gt.PACKED_2X2_FLOAT32;
10368  if (t === zt.RENDER || null == t) return function (t) {
10369    return i().getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? t ? Gt.PACKED_2X2_FLOAT32 : Gt.UNPACKED_FLOAT32 : t ? Gt.PACKED_2X2_FLOAT16 : Gt.UNPACKED_FLOAT16;
10370  }(e);
10371  if (t === zt.DOWNLOAD || t === zt.PIXELS) return Gt.PACKED_4X1_UNSIGNED_BYTE;
10372  throw new Error("Unknown logical texture type " + t);
10373}
10374
10375function eu(t, e, n) {
10376  return t[0] + "_" + t[1] + "_" + e + "_" + n;
10377}
10378
10379var nu = function (t, e) {
10380  this.variableNames = ["A"];
10381
10382  for (var n = new Array(t.length), r = 0; r < n.length; r++) n[r] = t[r] * e[r];
10383
10384  this.outputShape = n, this.rank = n.length;
10385
10386  var o = oi(this.rank),
10387      a = function (t) {
10388    var e = t.length;
10389    if (e > 5) throw Error("Tile for rank " + e + " is not yet supported");
10390    if (1 === e) return "imod(resRC, " + t[0] + ")";
10391
10392    for (var n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u"], r = [], o = 0; o < t.length;
vendor: 10,461 bytes, lines 10392-10594
10392 o++) r.push("imod(" + n[o] + ", " + t[o] + ")");
10393
10394    return r.join();
10395  }(t);
10396
10397  this.userCode = "\n      void main() {\n        " + o + " resRC = getOutputCoords();\n        setOutput(getA(" + a + "));\n      }\n    ";
10398};
10399
10400var ru = function (t, e) {
10401  this.variableNames = ["A"];
10402
10403  for (var n = new Array(t.length), r = 0; r < n.length; r++) n[r] = t[e[r]];
10404
10405  this.outputShape = n, this.rank = n.length;
10406
10407  var o = oi(this.rank),
10408      a = function (t) {
10409    var e = t.length;
10410    if (e > 6) throw Error("Transpose for rank " + e + " is not yet supported");
10411
10412    for (var n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u", "resRC.v"], r = new Array(e), o = 0; o < t.length; o++) r[t[o]] = n[o];
10413
10414    return r.join();
10415  }(e);
10416
10417  this.userCode = "\n    void main() {\n      " + o + " resRC = getOutputCoords();\n      setOutput(getA(" + a + "));\n    }\n    ";
10418};
10419
10420var ou = function (t, e) {
10421  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0;
10422
10423  for (var n = new Array(t.length), r = 0; r < n.length; r++) n[r] = t[e[r]];
10424
10425  if (this.outputShape = n, this.rank = n.length, this.rank > 6) throw Error("Packed transpose for rank " + this.rank + " is not yet supported.");
10426  var o = oi(this.rank),
10427      a = Ga("rc", this.rank),
10428      i = new Array(this.rank);
10429
10430  for (r = 0; r < e.length; r++) i[e[r]] = a[r];
10431
10432  var s = "vec2(" + i.slice(-2).join() + ")",
10433      u = "++" + a[this.rank - 1] + " < " + n[this.rank - 1],
10434      c = "getChannel(getA(" + i.join() + "), " + s + ")";
10435  this.userCode = "\n    void main() {\n      " + o + " rc = getOutputCoords();\n      vec4 result = vec4(0.);\n      result[0] = " + c + ";\n      if(" + u + ") {\n        result[1] = " + c + ";\n      }\n      --" + a[this.rank - 1] + ";\n      if(++" + a[this.rank - 2] + " < " + n[this.rank - 2] + ") {\n        result[2] = " + c + ";\n        if(" + u + ") {\n          result[3] = " + c + ";\n        }\n      }\n      setOutput(result);\n    }\n    ";
10436},
10437    au = 1.7580993408473768,
10438    iu = 1.0507009873554805,
10439    su = function (t, e) {
10440  this.variableNames = ["A"], this.outputShape = t, this.userCode = "\n      float unaryOperation(float x) {\n        " + e + "\n      }\n\n      void main() {\n        float x = getAAtOutCoords();\n        float y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    ";
10441},
10442    uu = "if (isnan(x)) return x;",
10443    cu = "return x;",
10444    lu = "return abs(x);",
10445    hu = uu + "\n  return (x < 0.0) ? 0.0 : x;\n",
10446    fu = uu + "\n  return (x < 0.0) ? 0.0 : min(6.0, x);\n",
10447    du = "return (x >= 0.0) ? x : (exp(x) - 1.0);",
10448    pu = "\n  // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n  // see: https://arxiv.org/abs/1706.02515\n  float scaleAlpha = " + au + ";\n  float scale = " + iu + ";\n  return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n";
10449
10450var vu = "return -x;",
10451    mu = "return ceil(x);",
10452    gu = "return floor(x);",
10453    yu = "return exp(x);",
10454    xu = "return exp(x) - 1.0;",
10455    bu = uu + "\n  return sin(x);\n",
10456    wu = uu + "\n  return cos(x);\n",
10457    Cu = uu + "\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return asin(x);\n",
10458    Eu = uu + "\n  if (abs(x) > 1.) {\n    return NAN;\n  }\n  return acos(x);\n",
10459    Ru = uu + "\n  return atan(x);\n",
10460    Iu = uu + "return log(x + sqrt(x * x + 1.0));",
10461    ku = uu + "\n  if (x < 1.0) return NAN;\n  return log(x + sqrt(x * x - 1.0));",
10462    Su = uu + "\n  if ((x < -1.0) || (x > 1.0)) return NAN;\n  return (log(1.0 + x) - log(1.0 - x)) / 2.0;",
10463    Au = "return x;",
10464    Tu = "return x;",
10465    Du = "\n  vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n",
10466    Nu = "\n  vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n  bvec4 isNaN = isnan(x);\n\n  result.r = isNaN.r ? x.r : result.r;\n  result.g = isNaN.g ? x.g : result.g;\n  result.b = isNaN.b ? x.b : result.b;\n  result.a = isNaN.a ? x.a : result.a;\n\n  return result;\n",
10467    Fu = "\n  vec4 result;\n\n  result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n  result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n  result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n  result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n  return result;\n",
10468    _u = function (t, e) {
10469  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t, this.userCode = "\n      vec4 unaryOperation(vec4 x) {\n        " + e + "\n      }\n\n      void main() {\n        vec4 x = getAAtOutCoords();\n        vec4 y = unaryOperation(x);\n\n        setOutput(y);\n      }\n    ";
10470},
10471    Ou = function (t) {
10472  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !1, this.outputShape = t;
10473
10474  var e = t.length,
10475      n = Ha("rc", e),
10476      r = oi(e),
10477      o = function (t, e) {
10478    if (1 === t) return "rc";
10479
10480    for (var n = "", r = 0; r < t; r++) n += e[r], r < t - 1 && (n += ",");
10481
10482    return n;
10483  }(e, n),
10484      a = n.slice(-2),
10485      i = e <= 1 ? "rc" : "vec2(" + a.join(",") + ")";
10486
10487  this.userCode = "\n      void main() {\n        " + r + " rc = getOutputCoords();\n        vec4 packedInput = getA(" + o + ");\n\n        setOutput(getChannel(packedInput, " + i + "));\n      }\n    ";
10488},
10489    Mu = {};
10490
10491function Bu(t, e) {
10492  if (void 0 === e && (e = !1), "linear" === t) return e ? Tu : cu;
10493  if ("relu" === t) return e ? Du : hu;
10494  if ("elu" === t) return e ? Fu : du;
10495  if ("relu6" === t) return e ? Nu : fu;
10496  if ("prelu" === t) return e ? Ci : xi;
10497  throw new Error("Activation " + t + " has not been implemented for the WebGL backend.");
10498}
10499
10500var Pu = 600;
10501
10502var Lu = function (t) {
10503  function o(e) {
10504    var n,
10505        r = t.call(this) || this;
10506    if (r.pendingRead = new WeakMap(), r.pendingDisposal = new WeakSet(), r.dataRefCount = new WeakMap(), r.numBytesInGPU = 0, r.uploadWaitMs = 0, r.downloadWaitMs = 0, r.warnedAboutMemory = !1, r.pendingDeletes = 0, r.disposed = !1, !i().getBool("HAS_WEBGL")) throw new Error("WebGL is not supported on this device");
10507
10508    if (null == e) {
10509      var o = jt(i().getNumber("WEBGL_VERSION"));
10510      r.binaryCache = (n = i().getNumber("WEBGL_VERSION")) in Mu ? Mu[n] : (Mu[n] = {}, Mu[n]), r.gpgpu = new ws(o), r.canvas = o.canvas, r.gpgpuCreatedLocally = !0;
10511    } else r.gpgpu = e, r.binaryCache = {}, r.gpgpuCreatedLocally = !1, r.canvas = e.gl.canvas;
10512
10513    return r.textureManager = new Zs(r.gpgpu), r.numMBBeforeWarning = null == i().global.screen ? 1024 : i().global.screen.height * i().global.screen.width * window.devicePixelRatio * Pu / 1024 / 1024, r.texData = new aa(r, Lt), r;
10514  }
10515
10516  return e(o, t), o.prototype.numDataIds = function () {
10517    return this.texData.numDataIds() + (this.cpuBackend ? this.cpuBackend.numDataIds() : 0) - this.pendingDeletes;
10518  }, o.prototype.write = function (t, e, n) {
10519    if (i().getBool("DEBUG") && this.checkNumericalProblems(t), "complex64" === n && null != t) throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");
10520    var r = {};
10521    return this.texData.set(r, {
10522      shape: e,
10523      dtype: n,
10524      values: t,
10525      usage: zt.UPLOAD
10526    }), r;
10527  }, o.prototype.move = function (t, e, n, r) {
10528    if (i().getBool("DEBUG") && this.checkNumericalProblems(e), "complex64" === r) throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");
10529    this.texData.set(t, {
10530      shape: n,
10531      dtype: r,
10532      values: e,
10533      usage: zt.UPLOAD
10534    });
10535  }, o.prototype.readSync = function (t) {
10536    var e = this.texData.get(t),
10537        n = e.values,
10538        r = e.dtype,
10539        o = e.complexTensors,
10540        a = e.slice,
10541        i = e.shape,
10542        s = e.isPacked;
10543
10544    if (null != a) {
10545      var u = void 0;
10546      u = s ? new _u(i, Au) : new su(i, Au);
10547      var c = this.runWebGLProgram(u, [{
10548        dataId: t,
10549        shape: i,
10550        dtype: r
10551      }], r),
10552          l = this.readSync(c.dataId);
10553      return this.disposeData(c.dataId), l;
10554    }
10555
10556    if (null != n) return this.convertAndCacheOnCPU(t);
10557    if ("string" === r) return n;
10558    var h,
10559        f,
10560        d = null != this.activeTimers;
10561    (d && (h = et()), "complex64" === r) ? f = Ra(o.real.dataSync(), o.imag.dataSync()) : f = this.getValuesFromTexture(t);
10562    return d && (this.downloadWaitMs += et() - h), this.convertAndCacheOnCPU(t, f);
10563  }, o.prototype.read = function (t) {
10564    return n(this, void 0, void 0, function () {
10565      var e, n, o, a, s, u, c, l, h, f, d, p, v, m, g, y, x, b, w, C, E, R;
10566      return r(this, function (r) {
10567        switch (r.label) {
10568          case 0:
10569            if (this.pendingRead.has(t)) return e = this.pendingRead.get(t), [2, new Promise(function (t) {
10570              return e.push(t);
10571            })];
10572            if (n = this.texData.get(t), o = n.values, a = n.shape, s = n.slice, u = n.dtype, c = n.complexTensors, l = n.isPacked, null != s) return h = void 0, h = l ? new _u(a, Au) : new su(a, Au), f = this.runWebGLProgram(h, [{
10573              dataId: t,
10574              shape: a,
10575              dtype: u
10576            }], u), d = this.read(f.dataId), this.disposeData(f.dataId), [2, d];
10577            if (null != o) return [2, this.convertAndCacheOnCPU(t)];
10578            if (!i().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED") && 2 === i().getNumber("WEBGL_VERSION")) throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");
10579            return p = null, "complex64" !== u && i().get("WEBGL_BUFFER_SUPPORTED") && (v = this.decode(t), m = this.texData.get(v.dataId), p = (R = this.gpgpu).createBufferFromTexture.apply(R, [m.texture].concat(Yt(a)))), this.pendingRead.set(t, []), "complex64" === u ? [3, 2] : [4, this.gpgpu.createAndWaitForFence()];
10580
10581          case 1:
10582            r.sent(), r.label = 2;
10583
10584          case 2:
10585            return "complex64" !== u ? [3, 4] : [4, Promise.all([c.real.data(), c.imag.data()])];
10586
10587          case 3:
10588            return y = r.sent(), x = y[0], b = y[1], g = Ra(x, b), [3, 5];
10589
10590          case 4:
10591            null == p ? g = this.getValuesFromTexture(t) : (w = k(a), g = this.gpgpu.downloadFloat32MatrixFromBuffer(p, w)), r.label = 5;
10592
10593          case 5:
10594            return null != v && this.disposeData(v.dataId), C = this.convertAndCacheOnCPU(t, g), E = this.pendingRead.get(t), this.pendingRead.delete(t), E.forEac
10594h(function (t) {
10595              return t(C);
10596            }), this.pendingDisposal.has(t) && (this.pendingDisposal.delete(t), this.disposeData(t), this.pendingDeletes--), [2, C];
10597        }
10598      });
10599    });
10600  }, o.prototype.checkNumericalProblems = function (t) {
10601    if (null != t) for (var e = 0; e < t.length; e++) {
10602      var n = t[e];
10603
10604      if (!ee(n)) {
10605        if (i().getBool("WEBGL_RENDER_FLOAT32_CAPABLE")) throw Error("The value " + n + " cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'");
10606        throw Error("The value " + n + " cannot be represented on this device.");
10607      }
10608    }
10609  }, o.prototype.getValuesFromTexture = function (t) {
10610    var e,
10611        n = this.texData.get(t),
10612        r = n.shape,
10613        o = n.dtype,
10614        a = n.isPacked,
10615        s = k(r);
10616
10617    if (i().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")) {
10618      var u = this.decode(t),
10619          c = this.texData.get(u.dataId),
10620          l = (e = this.gpgpu).downloadMatrixFromPackedTexture.apply(e, [c.texture].concat(Yt(r))).subarray(0, s);
10621      return this.disposeData(u.dataId), l;
10622    }
10623
10624    var h = i().getBool("WEBGL_PACK") && !0 === a,
10625        f = h ? De(r) : r,
10626        d = h ? new Xi(f) : new ji(f),
10627        p = this.runWebGLProgram(d, [{
10628      shape: f,
10629      dtype: o,
10630      dataId: t
10631    }], "float32"),
10632        v = this.texData.get(p.dataId),
10633        m = this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(v.texture, v.texShape[0], v.texShape[1]).subarray(0, s);
10634    return this.disposeData(p.dataId), m;
10635  }, o.prototype.time = function (t) {
10636    return n(this, void 0, void 0, function () {
10637      var e, n, o, a, s, u, c;
10638      return r(this, function (r) {
10639        switch (r.label) {
10640          case 0:
10641            return e = this.activeTimers, n = [], o = !1, null == this.programTimersStack ? (this.programTimersStack = n, o = !0) : this.activeTimers.push(n), this.activeTimers = n, t(), a = I(this.activeTimers.map(function (t) {
10642              return t.query;
10643            })).filter(function (t) {
10644              return null != t;
10645            }), s = I(this.activeTimers.map(function (t) {
10646              return t.name;
10647            })).filter(function (t) {
10648              return null != t;
10649            }), this.activeTimers = e, o && (this.programTimersStack = null), u = {
10650              uploadWaitMs: this.uploadWaitMs,
10651              downloadWaitMs: this.downloadWaitMs,
10652              kernelMs: null,
10653              wallMs: null
10654            }, i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? [4, Promise.all(a)] : [3, 2];
10655
10656          case 1:
10657            return c = r.sent(), u.kernelMs = w(c), u.getExtraProfileInfo = function () {
10658              return c.map(function (t, e) {
10659                return {
10660                  name: s[e],
10661                  ms: t
10662                };
10663              }).map(function (t) {
10664                return t.name + ": " + t.ms;
10665              }).join(", ");
10666            }, [3, 3];
10667
10668          case 2:
10669            u.kernelMs = {
10670              error: "WebGL query timers are not supported in this environment."
10671            }, r.label = 3;
10672
10673          case 3:
10674            return this.uploadWaitMs = 0, this.downloadWaitMs = 0, [2, u];
10675        }
10676      });
10677    });
10678  }, o.prototype.memory = function () {
10679    return {
10680      unreliable: !1,
10681      numBytesInGPU: this.numBytesInGPU
10682    };
10683  }, o.prototype.startTimer = function () {
10684    return i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? this.gpgpu.beginQuery() : {
10685      startMs: et(),
10686      endMs: null
10687    };
10688  }, o.prototype.endTimer = function (t) {
10689    return i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? (this.gpgpu.endQuery(), t) : (t.endMs = et(), t);
10690  }, o.prototype.getQueryTime = function (t) {
10691    return n(this, void 0, void 0, function () {
10692      var e;
10693      return r(this, function (n) {
10694        return i().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? [2, this.gpgpu.waitForQueryAndGetTime(t)] : [2, (e = t).endMs - e.startMs];
10695      });
10696    });
10697  }, o.prototype.disposeData = function (t) {
10698    if (!this.pendingDisposal.has(t)) {
10699      if (this.pendingRead.has(t)) return this.pendingDisposal.add(t), void this.pendingDeletes++;
10700
10701      if (this.texData.has(t)) {
10702        this.releaseGPUData(t);
10703        var e = this.texData.get(t).complexTensors;
10704        null != e && (e.real.dispose(), e.imag.dispose()), this.texData.delete(t);
10705      }
10706    }
10707  }, o.prototype.releaseGPUData = function (t) {
10708    var e = this.texData.get(t),
10709        n = e.texture,
10710        r = e.dtype,
10711        o = e.texShape,
10712        a = e.usage,
10713        i = e.isPacked,
10714        s = e.slice,
10715        u = s && s.origDataId || t,
10716        c = this.dataRefCount.get(u);
10717    c > 1 ? this.dataRefCount.set(u, c - 1) : (this.dataRefCount.delete(u), null != n && (this.numBytesInGPU -= this.computeBytes(o, r), this.textureManager.releaseTexture(n, o, a, i)));
10718    var l = this.texData.get(t);
10719    l.texture = null, l.texShape = null, l.isPacked = !1, l.slice = null;
10720  }, o.prototype.getTexture = function (t) {
10721    return this.uploadToGPU(t), this.texData.get(t).texture;
10722  }, o.prototype.getDataInfo = function (t) {
10723    return this.texData.get(t);
10724  }, o.prototype.getCPUBackend = function () {
10725    return i().getBool("WEBGL_CPU_FORWARD") ? (null == this.cpuBackend && (this.cpuBackend = Lt.findBackend("cpu")), this.cpuBackend) : null;
10726  }, o.prototype.shouldExecuteOnCPU = function (t, e) {
10727    var n = this;
10728    return void 0 === e && (e = 128), null != this.getCPUBackend() && t.every(function (t) {
10729      return null == n.texData.get(t.dataId).texture && t.size < e;
10730    });
10731  }, o.prototype.getGPGPUContext = function () {
10732    return this.gpgpu;
10733  }, o.prototype.complex = function (t, e) {
10734    var n = this.makeOutput(t.shape, "complex64");
10735    return this.texData.get(n.dataId).complexTensors = {
10736      real: Lt.keep(t.clone()),
10737      imag: Lt.keep(e.clone())
10738    }, n;
10739  }, o.prototype.real = function (t) {
10740    return this.texData.get(t.dataId).complexTensors.real.clone();
10741  }, o.prototype.imag = function (t) {
10742    return this.texData.get(t.dataId).complexTensors.imag.clone();
10743  }, o.prototype.slice = function (t, e, n) {
10744    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.slice(t, e, n);
10745    if (0 === k(n)) return Fn([], n, t.dtype);
10746    var r = this.texData.get(t.dataId).isPacked,
10747        o = jo(t.shape, e, n);
10748
10749    if (r || !o) {
10750      var a = i().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new Qs(n) : new Ys(n),
10751          s = a.getCustomSetupFunc(e);
10752      return this.compileAndRun(a, [t], null, s);
10753    }
10754
10755    return this.uploadToGPU(t.dataId), this.shallowSlice(t, e, n);
10756  }, o.prototype.shallowSlice = function (t, e, n) {
10757    var r = this.texData.get(t.dataId),
10758        o = this.makeOutput(n, t.dtype),
10759        a = this.texData.get(o.dataId);
vendor: 16,384 bytes, lines 10760-11122
10760    Object.assign(a, r), a.shape = n, a.dtype = t.dtype;
10761    var i = Xo(e, t.strides);
10762    r.slice && (i += r.slice.flatOffset), a.slice = {
10763      flatOffset: i,
10764      origDataId: r.slice && r.slice.origDataId || t.dataId
10765    };
10766    var s = this.dataRefCount.get(a.slice.origDataId) || 1;
10767    return this.dataRefCount.set(a.slice.origDataId, s + 1), o;
10768  }, o.prototype.stridedSlice = function (t, e, n, r) {
10769    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.stridedSlice(t, e, n, r);
10770    var o = Ho(e, n, r);
10771    if (o.some(function (t) {
10772      return 0 === t;
10773    })) return Fn([], o);
10774    var a = new Js(e, r, o);
10775    return this.compileAndRun(a, [t]);
10776  }, o.prototype.reverse = function (t, e) {
10777    var n = i().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new qs(t.shape, e) : new Hs(t.shape, e);
10778    return this.compileAndRun(n, [t]);
10779  }, o.prototype.concat = function (t, e) {
10780    if ("complex64" === t[0].dtype) {
10781      var n = t.map(function (t) {
10782        return Dn(t);
10783      }),
10784          r = t.map(function (t) {
10785        return Nn(t);
10786      });
10787      return Tn(this.concat(n, e), this.concat(r, e));
10788    }
10789
10790    if (this.shouldExecuteOnCPU(t)) return this.cpuBackend.concat(t, e);
10791    if (1 === t.length) return t[0];
10792
10793    if (t.length > i().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")) {
10794      var o = Math.floor(t.length / 2),
10795          a = this.concat(t.slice(0, o), e),
10796          s = this.concat(t.slice(o), e);
10797      return this.concat([a, s], e);
10798    }
10799
10800    if (i().getBool("WEBGL_PACK_ARRAY_OPERATIONS") && t[0].rank > 1) {
10801      var u = new Ai(t.map(function (t) {
10802        return t.shape;
10803      }), e);
10804      return this.compileAndRun(u, t);
10805    }
10806
10807    var c = Sn(t.map(function (t) {
10808      return t.shape;
10809    }), e),
10810        l = t.map(function (t) {
10811      return t.as2D(-1, k(t.shape.slice(e)));
10812    }),
10813        h = new Si(l.map(function (t) {
10814      return t.shape;
10815    }));
10816    return this.compileAndRun(h, l).reshape(c);
10817  }, o.prototype.neg = function (t) {
10818    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.neg(t);
10819    if (i().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(t, vu, t.dtype);
10820    var e = new su(t.shape, vu);
10821    return this.compileAndRun(e, [t]);
10822  }, o.prototype.batchMatMul = function (t, e, n, r) {
10823    var o = n ? t.shape[2] : t.shape[1],
10824        a = r ? e.shape[1] : e.shape[2],
10825        i = n ? t.shape[1] : t.shape[2],
10826        s = t.shape[0];
10827
10828    if ((1 === o || 1 === a) && i > 1e3) {
10829      n && (t = t.transpose([0, 2, 1])), r && (e = e.transpose([0, 2, 1]));
10830      var u = 1 === a ? t : t.as3D(s, i, 1),
10831          c = 1 === a ? 2 : 1,
10832          l = 1 === a ? e.as3D(s, 1, i) : e;
10833      return this.multiply(u, l).sum(c, !0);
10834    }
10835
10836    var h = Tt(t.dtype, e.dtype),
10837        f = new Ts(t.shape, [s, o, a], n, r);
10838    return this.compileAndRun(f, [t, e], h);
10839  }, o.prototype.fusedBatchMatMul = function (t) {
10840    var e = t.a,
10841        n = t.b,
10842        r = t.transposeA,
10843        o = t.transposeB,
10844        a = t.bias,
10845        i = t.activation,
10846        s = t.preluActivationWeights,
10847        u = r ? e.shape[2] : e.shape[1],
10848        c = o ? n.shape[1] : n.shape[2],
10849        l = e.shape[0],
10850        h = Tt(e.dtype, n.dtype),
10851        f = null != a,
10852        d = null != s,
10853        p = i ? Bu(i, !0) : null,
10854        v = new Ts(e.shape, [l, u, c], r, o, f, p, d),
10855        m = [e, n];
10856    return a && m.push(a), s && m.push(s), this.compileAndRun(v, m, h);
10857  }, o.prototype.multiply = function (t, e) {
10858    if ("complex64" === t.dtype) {
10859      var n = this.texData.get(t.dataId),
10860          r = this.texData.get(e.dataId),
10861          o = new pi(fi, t.shape, e.shape),
10862          a = new pi(di, t.shape, e.shape),
10863          s = [this.makeComplexComponentTensorInfo(t, n.complexTensors.real), this.makeComplexComponentTensorInfo(t, n.complexTensors.imag), this.makeComplexComponentTensorInfo(e, r.complexTensors.real), this.makeComplexComponentTensorInfo(e, r.complexTensors.imag)],
10864          u = this.compileAndRun(o, s),
10865          c = this.compileAndRun(a, s),
10866          l = this.complex(u, c);
10867      return u.dispose(), c.dispose(), l;
10868    }
10869
10870    if (this.shouldExecuteOnCPU([t, e])) return this.cpuBackend.multiply(t, e);
10871    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, gi, t.dtype);
10872    var h = new bi(gi, t.shape, e.shape);
10873    return this.compileAndRun(h, [t, e], t.dtype);
10874  }, o.prototype.batchNormalization = function (t, e, n, r, o, a) {
10875    var s = [t, e, n],
10876        u = null;
10877    null != a && (u = a.shape, s.push(a));
10878    var c = null;
10879
10880    if (null != o && (c = o.shape, s.push(o)), i().getBool("WEBGL_PACK_NORMALIZATION")) {
10881      var l = new hi(t.shape, e.shape, n.shape, u, c, r);
10882      return this.compileAndRun(l, s);
10883    }
10884
10885    var h = new li(t.shape, e.shape, n.shape, u, c, r);
10886    return this.compileAndRun(h, s);
10887  }, o.prototype.localResponseNormalization4D = function (t, e, n, r, o) {
10888    var a = i().getBool("WEBGL_PACK_NORMALIZATION") ? new ks(t.shape, e, n, r, o) : new Rs(t.shape, e, n, r, o);
10889    return this.compileAndRun(a, [t]);
10890  }, o.prototype.LRNGrad = function (t, e, n, r, o, a, i) {
10891    var s = new Is(e.shape, r, o, a, i);
10892    return this.compileAndRun(s, [e, n, t]);
10893  }, o.prototype.tile = function (t, e) {
10894    if ("string" === t.dtype) {
10895      var n = this.readSync(t.dataId).map(function (t) {
10896        return ot(t);
10897      });
10898      return Pa(er(t.shape, t.dtype, n), e);
10899    }
10900
10901    var r = new nu(t.shape, e);
10902    return this.compileAndRun(r, [t]);
10903  }, o.prototype.pad = function (t, e, n) {
10904    var r = i().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new Os(t.shape, e, n) : new _s(t.shape, e, n);
10905    return this.compileAndRun(r, [t]);
10906  }, o.prototype.transpose = function (t, e) {
10907    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.transpose(t, e);
10908    var n = i().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new ou(t.shape, e) : new ru(t.shape, e);
10909    return this.compileAndRun(n, [t]);
10910  }, o.prototype.gather = function (t, e, n) {
10911    if (this.shouldExecuteOnCPU([t, e])) return this.cpuBackend.gather(t, e, n);
10912    var r = new es(t.shape, e.size, n);
10913    return this.compileAndRun(r, [t, e]);
10914  }, o.prototype.batchToSpaceND = function (t, e, n) {
10915    C(t.rank <= 4, function () {
10916      return "batchToSpaceND for rank > 4 with a WebGL backend not implemented yet";
10917    });
10918    var r = e.reduce(function (t, e) {
10919      return t * e;
10920    }),
10921        o = xr(t.shape, e, r),
10922        a = br(o.length, e.length),
10923        i = wr(t.shape, e, r),
10924        s = Cr(n, e.length),
10925        u = Er(i, n, e.length);
10926    return t.reshape(o).transpose(a).reshape(i).slice(s, u);
10927  }, o.prototype.spaceToBatchND = function (t, e, n) {
10928    C(t.rank <= 4, function () {
10929      return "spaceToBatchND for rank > 4 with a WebGL backend not implemented yet";
10930    });
10931    var r = e.reduce(function (t, e) {
10932      return t * e;
10933    }),
10934        o = [[0, 0]];
10935    o.push.apply(o, n);
10936
10937    for (var a = 1 + e.length; a < t.shape.length; ++a) o.push([0, 0]);
10938
10939    var i = t.pad(o),
10940        s = xr(i.shape, e, r, !1),
10941        u = br(s.length, e.length, !1),
10942        c = wr(i.shape, e, r, !1);
10943    return i.reshape(s).transpose(u).reshape(c);
10944  }, o.prototype.reduce = function (t, e, n) {
10945    var r = t.shape[0],
10946        o = t.shape[1],
10947        a = Po(o),
10948        i = new Ps({
10949      windowSize: a,
10950      inSize: o,
10951      batchSize: r
10952    }, e),
10953        s = this.compileAndRun(i, [t], n);
10954    return 1 === s.shape[1] ? s : this.reduce(s, e, n);
10955  }, o.prototype.argReduce = function (t, e, n) {
10956    void 0 === n && (n = null);
10957    var r = t.shape[0],
10958        o = t.shape[1];
10959    null != n && (r = n.shape[0], o = n.shape[1]);
10960    var a = Po(o),
10961        i = new za({
10962      windowSize: a,
10963      inSize: o,
10964      batchSize: r
10965    }, e, null == n),
10966        s = [t];
10967    null != n && s.push(n);
10968    var u = this.compileAndRun(i, s, "int32");
10969    return 1 === u.shape[1] ? u : this.argReduce(t, e, u);
10970  }, o.prototype.argReducePacked = function (t, e, n) {
10971    void 0 === n && (n = null);
10972    var r = null != n ? n.shape : t.shape,
10973        o = Po(r[r.length - 1]),
10974        a = new si(r, o, e, null == n),
10975        i = null == n ? [t] : [t, n],
10976        s = this.compileAndRun(a, i, "int32");
10977    return s.rank === t.rank ? this.argReducePacked(t, e, s) : s;
10978  }, o.prototype.sum = function (t, e) {
10979    Cn("sum", e, t.rank);
10980    var n = bn(t.shape, e),
10981        r = n[0],
10982        o = k(n[1]),
10983        a = t.as2D(-1, o),
10984        i = Dt(t.dtype);
10985    return this.reduce(a, "sum", i).reshape(r);
10986  }, o.prototype.prod = function (t, e) {
10987    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.prod(t, e);
10988    var n = bn(t.shape, e),
10989        r = n[0],
10990        o = k(n[1]),
10991        a = t.as2D(-1, o),
10992        i = Dt(t.dtype);
10993    return this.reduce(a, "prod", i).reshape(r);
10994  }, o.prototype.unsortedSegmentSum = function (t, e, n) {
10995    var r = 0,
10996        o = En([r], t.rank),
10997        a = t;
10998    null != o && (a = t.transpose(o), r = In(1, t.rank)[0]);
10999
11000    var i = function (t, e, n) {
11001      for (var r = [], o = t.length, a = 0; a < o; a++) a !== e ? r.push(t[a]) : r.push(n);
11002
11003      return r;
11004    }(a.shape, r, n),
11005        s = k([a.shape[r]]),
11006        u = a.as2D(-1, s),
11007        c = Dt(t.dtype),
11008        l = this.segOpCompute(u, "unsortedSegmentSum", e, c, n).reshape(i);
11009
11010    return null != o && (l = l.transpose(Rn(o))), l;
11011  }, o.prototype.segOpCompute = function (t, e, n, r, o) {
11012    var a = t.shape[0],
11013        i = t.shape[1],
11014        s = function (t, e) {
11015      var n,
11016          r = !1;
11017
11018      for (t <= Bo ? (n = t, r = !0) : n = Y(t, Math.floor(Math.sqrt(t))); !r;) n > e || n === t ? r = !0 : n = Y(t, n + 1);
11019
11020      return n;
11021    }(i, o),
11022        u = new js({
11023      windowSize: s,
11024      inSize: i,
11025      batchSize: a,
11026      numSegments: o
11027    }, e),
11028        c = this.compileAndRun(u, [t, n], r);
11029
11030    return c.shape[1] === o ? c : (n = Kn(0, o).tile([i / s]), this.segOpCompute(c, e, n, r, o));
11031  }, o.prototype.argMinMaxReduce = function (t, e, n) {
11032    var r = [e];
11033
11034    if (Cn("arg" + n.charAt(0).toUpperCase() + n.slice(1), r, t.rank), !i().getBool("WEBGL_PACK_REDUCE") || t.rank <= 2) {
11035      var o = bn(t.shape, r),
11036          a = o[0],
11037          s = k(o[1]),
11038          u = t.as2D(-1, s);
11039      return this.argReduce(u, n).reshape(a);
11040    }
11041
11042    return this.argReducePacked(t, n);
11043  }, o.prototype.argMin = function (t, e) {
11044    return this.argMinMaxReduce(t, e, "min");
11045  }, o.prototype.argMax = function (t, e) {
11046    return this.argMinMaxReduce(t, e, "max");
11047  }, o.prototype.cumsum = function (t, e, n, r) {
11048    if (e !== t.rank - 1) throw new Error("WebGL cumsum shader expects an inner-most axis=" + (t.rank - 1) + " but got axis=" + e);
11049    var o = new Vi(t.shape, n, r);
11050    return this.compileAndRun(o, [t]);
11051  }, o.prototype.equal = function (t, e) {
11052    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, "\n  return vec4(equal(a, b));\n", "bool");
11053    var n = new bi("return float(a == b);", t.shape, e.shape);
11054    return this.compileAndRun(n, [t, e], "bool");
11055  }, o.prototype.notEqual = function (t, e) {
11056    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, "\n  return vec4(notEqual(a, b));\n", "bool");
11057    var n = new bi("return float(a != b);", t.shape, e.shape);
11058    return this.compileAndRun(n, [t, e], "bool");
11059  }, o.prototype.less = function (t, e) {
11060    if (this.shouldExecuteOnCPU([t, e])) return this.cpuBackend.less(t, e);
11061    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, "\n  return vec4(lessThan(a, b));\n", "bool");
11062    var n = new bi("return float(a < b);", t.shape, e.shape);
11063    return this.compileAndRun(n, [t, e], "bool");
11064  }, o.prototype.lessEqual = function (t, e) {
11065    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, "\n  return vec4(lessThanEqual(a, b));\n", "bool");
11066    var n = new bi("return float(a <= b);", t.shape, e.shape);
11067    return this.compileAndRun(n, [t, e], "bool");
11068  }, o.prototype.greater = function (t, e) {
11069    if (this.shouldExecuteOnCPU([t, e])) return this.cpuBackend.greater(t, e);
11070    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, "\n  return vec4(greaterThan(a, b));\n", "bool");
11071    var n = new bi("return float(a > b);", t.shape, e.shape);
11072    return this.compileAndRun(n, [t, e], "bool");
11073  }, o.prototype.greaterEqual = function (t, e) {
11074    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, "\n  return vec4(greaterThanEqual(a, b));\n", "bool");
11075    var n = new bi("return float(a >= b);", t.shape, e.shape);
11076    return this.compileAndRun(n, [t, e], "bool");
11077  }, o.prototype.logicalNot = function (t) {
11078    var e = new su(t.shape, "return float(!(x >= 1.0));");
11079    return this.compileAndRun(e, [t]);
11080  }, o.prototype.logicalAnd = function (t, e) {
11081    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, "\n  return vec4(\n    vec4(greaterThanEqual(a, vec4(1.0))) *\n    vec4(greaterThanEqual(b, vec4(1.0))));\n", "bool");
11082    var n = new bi("return float(a >= 1.0 && b >= 1.0);", t.shape, e.shape);
11083    return this.compileAndRun(n, [t, e], "bool");
11084  }, o.prototype.logicalOr = function (t, e) {
11085    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, "\n  return min(\n    vec4(greaterThanEqual(a, vec4(1.0))) +\n    vec4(greaterThanEqual(b, vec4(1.0))),\n    vec4(1.0));\n", "bool");
11086    var n = new bi("return float(a >= 1.0 || b >= 1.0);", t.shape, e.shape);
11087    return this.compileAndRun(n, [t, e], "bool");
11088  }, o.prototype.select = function (t, e, n) {
11089    var r = new Xs(t.rank, e.shape, e.rank);
11090    return this.compileAndRun(r, [t, e, n], Tt(e.dtype, n.dtype));
11091  }, o.prototype.where = function (t) {
11092    dn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");
11093    var e = t.dataSync();
11094    return Wa(t.shape, e);
11095  }, o.prototype.topk = function (t, e, n) {
11096    return La(t.dataSync(), t.shape, t.dtype, e);
11097  }, o.prototype.min = function (t, e) {
11098    Cn("min", e, t.rank);
11099    var n = bn(t.shape, e),
11100        r = n[0],
11101        o = k(n[1]),
11102        a = t.as2D(-1, o);
11103    return this.reduce(a, "min", a.dtype).reshape(r);
11104  }, o.prototype.minimum = function (t, e) {
11105    if (this.shouldExecuteOnCPU([t, e])) return this.cpuBackend.minimum(t, e);
11106    var n = i().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ei("\n  vec4 result = vec4(min(a, b));\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n", t.shape, e.shape) : new bi("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return min(a, b);\n", t.shape, e.shape);
11107    return this.compileAndRun(n, [t, e]);
11108  }, o.prototype.mod = function (t, e) {
11109    var n = i().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ei("\n  vec4 result = mod(a, b);\n  vec4 isNaN = vec4(equal(b, vec4(0.0)));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n", t.shape, e.shape) : new bi("if (b == 0.0) return NAN;\n  return mod(a, b);", t.shape, e.shape);
11110    return this.compileAndRun(n, [t, e]);
11111  }, o.prototype.max = function (t, e) {
11112    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.max(t, e);
11113    Cn("max", e, t.rank);
11114    var n = bn(t.shape, e),
11115        r = n[0],
11116        o = k(n[1]),
11117        a = t.as2D(-1, o);
11118    return this.reduce(a, "max", a.dtype).reshape(r);
11119  }, o.prototype.maximum = function (t, e) {
11120    if (this.shouldExecuteOnCPU([t, e])) return this.cpuBackend.maximum(t, e);
11121    var n = i().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ei("\n  vec4 result = vec4(max(a, b));\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n", t.shape, e.shape) : new bi("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return max(a, b);\n", t.shape, e.shape);
11122    return this.compileAndRun(n,
11122 [t, e]);
11123  }, o.prototype.all = function (t, e) {
11124    Cn("all", e, t.rank);
11125    var n = bn(t.shape, e),
11126        r = n[0],
11127        o = k(n[1]),
11128        a = t.as2D(-1, o);
11129    return this.reduce(a, "all", a.dtype).reshape(r);
11130  }, o.prototype.any = function (t, e) {
11131    Cn("any", e, t.rank);
11132    var n = bn(t.shape, e),
11133        r = n[0],
11134        o = k(n[1]),
11135        a = t.as2D(-1, o);
11136    return this.reduce(a, "any", a.dtype).reshape(r);
11137  }, o.prototype.floorDiv = function (t, e) {
11138    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, "\n  ivec4 ia = round(a);\n  ivec4 ib = round(b);\n  bvec4 cond = notEqual(ib, ivec4(0));\n  ivec4 result = ivec4(0);\n  vec4 s = sign(a) * sign(b);\n\n  // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n  if (cond[0]) {\n    result[0] = idiv(ia[0], ib[0], s[0]);\n  }\n  if (cond[1]) {\n    result[1] = idiv(ia[1], ib[1], s[1]);\n  }\n  if (cond[2]) {\n    result[2] = idiv(ia[2], ib[2], s[2]);\n  }\n  if (cond[3]) {\n    result[3] = idiv(ia[3], ib[3], s[3]);\n  }\n  return vec4(result);\n", "int32");
11139    var n = new bi("\n  float s = sign(a) * sign(b);\n  int ia = round(a);\n  int ib = round(b);\n  if (ib != 0) {\n    // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n    return float(idiv(ia, ib, s));\n  } else {\n    return NAN;\n  }\n", t.shape, e.shape);
11140    return this.compileAndRun(n, [t, e], "int32");
11141  }, o.prototype.add = function (t, e) {
11142    if ("complex64" === t.dtype && "complex64" === e.dtype) return this.complexSeparableBinaryOp(t, e, vi);
11143    if (this.shouldExecuteOnCPU([t, e])) return this.cpuBackend.add(t, e);
11144    var n = Tt(t.dtype, e.dtype);
11145    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, vi, n);
11146    var r = new bi(vi, t.shape, e.shape);
11147    return this.compileAndRun(r, [t, e], n);
11148  }, o.prototype.packedUnaryOp = function (t, e, n) {
11149    var r = new _u(t.shape, e);
11150    return this.compileAndRun(r, [t], n);
11151  }, o.prototype.packedBinaryOp = function (t, e, n, r, o) {
11152    void 0 === o && (o = !1);
11153    var a = new Ei(n, t.shape, e.shape, o);
11154    return this.compileAndRun(a, [t, e], r);
11155  }, o.prototype.complexSeparableBinaryOp = function (t, e, n) {
11156    var r = this,
11157        o = this.texData.get(t.dataId),
11158        a = this.texData.get(e.dataId),
11159        i = [[o.complexTensors.real, a.complexTensors.real], [o.complexTensors.imag, a.complexTensors.imag]].map(function (o) {
11160      var a = o[0],
11161          i = o[1],
11162          s = r.makeComplexComponentTensorInfo(t, a),
11163          u = r.makeComplexComponentTensorInfo(e, i),
11164          c = new bi(n, t.shape, e.shape);
11165      return r.compileAndRun(c, [s, u], Tt(a.dtype, i.dtype));
11166    }),
11167        s = i[0],
11168        u = i[1],
11169        c = this.complex(s, u);
11170    return s.dispose(), u.dispose(), c;
11171  }, o.prototype.makeComplexComponentTensorInfo = function (t, e) {
11172    return {
11173      dataId: e.dataId,
11174      dtype: e.dtype,
11175      shape: t.shape
11176    };
11177  }, o.prototype.addN = function (t) {
11178    if (1 === t.length) return t[0];
11179
11180    if (t.length > i().get("WEBGL_MAX_TEXTURES_IN_SHADER")) {
11181      var e = Math.floor(t.length / 2),
11182          n = this.addN(t.slice(0, e)),
11183          r = this.addN(t.slice(e));
11184      return this.addN([n, r]);
11185    }
11186
11187    var o = t.map(function (t) {
11188      return t.dtype;
11189    }).reduce(function (t, e) {
11190      return Tt(t, e);
11191    }),
11192        a = t.map(function (t) {
11193      return t.shape;
11194    }),
11195        s = i().getBool("WEBGL_PACK") ? new Va(t[0].shape, a) : new Ua(t[0].shape, a);
11196    return this.compileAndRun(s, t, o);
11197  }, o.prototype.subtract = function (t, e) {
11198    if ("complex64" === t.dtype && "complex64" === e.dtype) return this.complexSeparableBinaryOp(t, e, mi);
11199    if (this.shouldExecuteOnCPU([t, e])) return this.cpuBackend.subtract(t, e);
11200    var n = Tt(t.dtype, e.dtype);
11201    if (i().getBool("WEBGL_PACK_BINARY_OPERATIONS")) return this.packedBinaryOp(t, e, mi, t.dtype);
11202    var r = new bi(mi, t.shape, e.shape);
11203    return this.compileAndRun(r, [t, e], n);
11204  }, o.prototype.pow = function (t, e) {
11205    var n = i().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ei("\n  // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n  vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n  vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n  vec4 result = multiplier * pow(abs(a), b);\n\n  // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n  bvec4 isExpZero = equal(b, vec4(0.0));\n  result.r = isExpZero.r ? 1.0 : result.r;\n  result.g = isExpZero.g ? 1.0 : result.g;\n  result.b = isExpZero.b ? 1.0 : result.b;\n  result.a = isExpZero.a ? 1.0 : result.a;\n\n  vec4 isNaN = vec4(lessThan(a, vec4(0.0))) * vec4(lessThan(floor(b), b));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n", t.shape, e.shape) : new bi("\nif(a < 0.0 && floor(b) < b){\n  return NAN;\n}\nif (b == 0.0) {\n  return 1.0;\n}\nreturn (round(mod(b, 2.0)) != 1) ?\n    pow(abs(a), b) : sign(a) * pow(abs(a), b);\n", t.shape, e.shape),
11206        r = Tt(t.dtype, e.dtype);
11207    return this.compileAndRun(n, [t, e], r);
11208  }, o.prototype.ceil = function (t) {
11209    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.ceil(t);
11210    if (i().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(t, mu, t.dtype);
11211    var e = new su(t.shape, mu);
11212    return this.compileAndRun(e, [t]);
11213  }, o.prototype.floor = function (t) {
11214    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.floor(t);
11215    if (i().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(t, gu, t.dtype);
11216    var e = new su(t.shape, gu);
11217    return this.compileAndRun(e, [t]);
11218  }, o.prototype.sign = function (t) {
11219    var e = new su(t.shape, "\n  if (isnan(x)) { return 0.0; }\n  return sign(x);\n");
11220    return this.compileAndRun(e, [t]);
11221  }, o.prototype.isNaN = function (t) {
11222    var e = new su(t.shape, "return float(isnan(x));");
11223    return this.compileAndRun(e, [t], "bool");
11224  }, o.prototype.isInf = function (t) {
11225    var e = new su(t.shape, "return float(isinf(x));");
11226    return this.compileAndRun(e, [t], "bool");
11227  }, o.prototype.isFinite = function (t) {
11228    var e = new su(t.shape, "return float(!isnan(x) && !isinf(x));");
11229    return this.compileAndRun(e, [t], "bool");
11230  }, o.prototype.round = function (t) {
11231    var e = new su(t.shape, "\n  // OpenGL ES does not support round function.\n  // The algorithm is based on banker's rounding.\n  float base = floor(x);\n  if ((x - base) < 0.5) {\n    return floor(x);\n  } else if ((x - base) > 0.5) {\n    return ceil(x);\n  } else {\n    if (mod(base, 2.0) == 0.0) {\n      return base;\n    } else {\n      return base + 1.0;\n    }\n  }\n");
11232    return this.compileAndRun(e, [t]);
11233  }, o.prototype.exp = function (t) {
11234    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.exp(t);
11235    if (i().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(t, yu, t.dtype);
11236    var e = new su(t.shape, yu);
11237    return this.compileAndRun(e, [t]);
11238  }, o.prototype.expm1 = function (t) {
11239    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.expm1(t);
11240    if (i().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(t, xu, t.dtype);
11241    var e = new su(t.shape, xu);
11242    return this.compileAndRun(e, [t]);
11243  }, o.prototype.softmax = function (t, e) {
11244    var n = O([e], t.shape),
11245        r = this.max(t, n),
11246        o = wn(r.shape, n),
11247        a = this.subtract(t, r.reshape(o)),
11248        i = this.exp(a),
11249        s = this.sum(i, n).reshape(o);
11250    return _o(i, s);
11251  }, o.prototype.log = function (t) {
11252    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.log(t);
11253    if (i().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(t, "\n  vec4 result = log(x);\n  vec4 isNaN = vec4(lessThan(x, vec4(0.0)));\n  result.r = isNaN.r == 1.0 ? NAN : result.r;\n  result.g = isNaN.g == 1.0 ? NAN : result.g;\n  result.b = isNaN.b == 1.0 ? NAN : result.b;\n  result.a = isNaN.a == 1.0 ? NAN : result.a;\n\n  return result;\n", t.dtype);
11254    var e = new su(t.shape, "if (x < 0.0) return NAN;\n  return log(x);");
11255    return this.compileAndRun(e, [t]);
11256  }, o.prototype.log1p = function (t) {
11257    var e = new su(t.shape, "return log(1.0 + x);");
11258    return this.compileAndRun(e, [t]);
11259  }, o.prototype.sqrt = function (t) {
11260    var e = new su(t.shape, "return sqrt(x);");
11261    return this.compileAndRun(e, [t]);
11262  }, o.prototype.rsqrt = function (t) {
11263    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.rsqrt(t);
11264    var e = new su(t.shape, "return inversesqrt(x);");
11265    return this.compileAndRun(e, [t]);
11266  }, o.prototype.reciprocal = function (t) {
11267    var e = new su(t.shape, "return 1.0 / x;");
11268    return this.compileAndRun(e, [t]);
11269  }, o.prototype.relu = function (t) {
11270    var e;
11271    return e = i().getBool("WEBGL_PACK") ? new _u(t.shape, Du) : new su(t.shape, hu), this.compileAndRun(e, [t]);
11272  }, o.prototype.relu6 = function (t) {
11273    var e;
11274    return e = i().getBool("WEBGL_PACK") ? new _u(t.shape, Nu) : new su(t.shape, fu), this.compileAndRun(e, [t]);
11275  }, o.prototype.prelu = function (t, e) {
11276    var n = i().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ei(Ci, t.shape, e.shape) : new bi(xi, t.shape, e.shape);
11277    return this.compileAndRun(n, [t, e]);
11278  }, o.prototype.elu = function (t) {
11279    if (i().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(t, Fu, t.dtype);
11280    var e = new su(t.shape, du);
11281    return this.compileAndRun(e, [t]);
11282  }, o.prototype.eluDer = function (t, e) {
11283    var n = i().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ei("\n  vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));
11283\n  return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n", t.shape, e.shape) : new bi("return (b >= 1.0) ? a : a * (b + 1.0);", t.shape, e.shape);
11284    return this.compileAndRun(n, [t, e]);
11285  }, o.prototype.selu = function (t) {
11286    var e = new su(t.shape, pu);
11287    return this.compileAndRun(e, [t]);
11288  }, o.prototype.int = function (t) {
11289    var e = new su(t.shape, "return float(int(x));");
11290    return this.compileAndRun(e, [t], "int32");
11291  }, o.prototype.clip = function (t, e, n) {
11292    var r,
11293        o = (r = i().getBool("WEBGL_PACK_CLIP") ? new Ii(t.shape) : new Ri(t.shape)).getCustomSetupFunc(e, n);
11294    return this.compileAndRun(r, [t], null, o);
11295  }, o.prototype.abs = function (t) {
11296    if (this.shouldExecuteOnCPU([t])) return this.cpuBackend.abs(t);
11297    if (i().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(t, lu, t.dtype);
11298    var e = new su(t.shape, lu);
11299    return this.compileAndRun(e, [t]);
11300  }, o.prototype.complexAbs = function (t) {
11301    var e = this.texData.get(t.dataId),
11302        n = new ki(t.shape),
11303        r = [this.makeComplexComponentTensorInfo(t, e.complexTensors.real), this.makeComplexComponentTensorInfo(t, e.complexTensors.imag)];
11304    return this.compileAndRun(n, r);
11305  }, o.prototype.sigmoid = function (t) {
11306    var e = new su(t.shape, "return 1.0 / (1.0 + exp(-1.0 * x));");
11307    return this.compileAndRun(e, [t]);
11308  }, o.prototype.softplus = function (t) {
11309    var e = new su(t.shape, "\n  float epsilon = 1.1920928955078125e-7;\n  float threshold = log(epsilon) + 2.0;\n\n  bool too_large = x > -threshold;\n  bool too_small = x < threshold;\n\n  float result;\n  float exp_x = exp(x);\n\n  if (too_large){\n    result = x;\n  }\n  else if (too_small){\n    result = exp_x;\n  }\n  else{\n    result = log(exp_x + 1.0);\n  }\n  return result;\n");
11310    return this.compileAndRun(e, [t]);
11311  }, o.prototype.sin = function (t) {
11312    var e = new su(t.shape, bu);
11313    return this.compileAndRun(e, [t]);
11314  }, o.prototype.cos = function (t) {
11315    var e = new su(t.shape, wu);
11316    return this.compileAndRun(e, [t]);
11317  }, o.prototype.tan = function (t) {
11318    var e = new su(t.shape, "return tan(x);");
11319    return this.compileAndRun(e, [t]);
11320  }, o.prototype.asin = function (t) {
11321    var e = new su(t.shape, Cu);
11322    return this.compileAndRun(e, [t]);
11323  }, o.prototype.acos = function (t) {
11324    var e = new su(t.shape, Eu);
11325    return this.compileAndRun(e, [t]);
11326  }, o.prototype.atan = function (t) {
11327    var e = new su(t.shape, Ru);
11328    return this.compileAndRun(e, [t]);
11329  }, o.prototype.atan2 = function (t, e) {
11330    var n = i().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ei("\n  vec4 result = atan(a, b);\n  vec4 isNaN = min(vec4(isnan(a)) + vec4(isnan(b)), vec4(1.0));\n  \n  result.r = isNaN.r > 0. ? NAN : result.r;\n  result.g = isNaN.g > 0. ? NAN : result.g;\n  result.b = isNaN.b > 0. ? NAN : result.b;\n  result.a = isNaN.a > 0. ? NAN : result.a;\n\n  return result;\n", t.shape, e.shape) : new bi("\n  if (isnan(a)) return a;\n  if (isnan(b)) return b;\n\n  return atan(a, b);\n", t.shape, e.shape);
11331    return this.compileAndRun(n, [t, e]);
11332  }, o.prototype.sinh = function (t) {
11333    var e = new su(t.shape, "\n  float e2x = exp(x);\n  return (e2x - 1.0 / e2x) / 2.0;\n");
11334    return this.compileAndRun(e, [t]);
11335  }, o.prototype.cosh = function (t) {
11336    var e = new su(t.shape, "\n  float e2x = exp(-x);\n  return (e2x + 1.0 / e2x) / 2.0;\n");
11337    return this.compileAndRun(e, [t]);
11338  }, o.prototype.tanh = function (t) {
11339    var e = new su(t.shape, "\n  float e2x = exp(-2.0 * abs(x));\n  return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n");
11340    return this.compileAndRun(e, [t]);
11341  }, o.prototype.asinh = function (t) {
11342    var e = new su(t.shape, Iu);
11343    return this.compileAndRun(e, [t]);
11344  }, o.prototype.acosh = function (t) {
11345    var e = new su(t.shape, ku);
11346    return this.compileAndRun(e, [t]);
11347  }, o.prototype.atanh = function (t) {
11348    var e = new su(t.shape, Su);
11349    return this.compileAndRun(e, [t]);
11350  }, o.prototype.erf = function (t) {
11351    var e = new su(t.shape, '\n  // Error function is calculated approximately with elementary function.\n  // See "Handbook of Mathematical Functions with Formulas,\n  // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n  float p = 0.3275911;\n  float a1 = 0.254829592;\n  float a2 = -0.284496736;\n  float a3 = 1.421413741;\n  float a4 = -1.453152027;\n  float a5 = 1.061405429;\n\n  float sign = sign(x);\n  x = abs(x);\n  float t = 1.0 / (1.0 + p * x);
11351\n  return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n');
11352    return this.compileAndRun(e, [t]);
11353  }, o.prototype.step = function (t, e) {
11354    var n = new su(t.shape, function (t) {
11355      return void 0 === t && (t = 0), uu + "\n    return x > 0.0 ? 1.0 : float(" + t + ");\n  ";
11356    }(e));
11357    return this.compileAndRun(n, [t]);
11358  }, o.prototype.conv2dByMatMul = function (t, e, n, r, o, a) {
11359    var s = t.shape,
11360        u = this.texData.get(t.dataId),
11361        c = n.inChannels,
11362        l = s[0] * s[1] * s[2],
11363        h = n.outChannels,
11364        f = "channelsLast" === n.dataFormat,
11365        d = (1 === l || 1 === h) && c > 1e3,
11366        p = s[2] % 2 != 0 && !!u.isPacked;
11367
11368    if (d || !i().getBool("WEBGL_LAZILY_UNPACK") || !i().getBool("WEBGL_PACK_BINARY_OPERATIONS") || !p) {
11369      var v = f ? s[0] * s[1] * s[2] : s[0] * s[2] * s[3],
11370          m = this.reshape(t, [1, v, n.inChannels]),
11371          g = this.reshape(e, [1, n.inChannels, n.outChannels]);
11372      return this.reshape(this.fusedBatchMatMul({
11373        a: m,
11374        b: g,
11375        transposeA: !1,
11376        transposeB: !1,
11377        bias: r,
11378        activation: o,
11379        preluActivationWeights: a
11380      }), n.outShape);
11381    }
11382
11383    var y = f ? s[0] * s[1] * (s[2] + 1) : s[0] * s[2] * (s[3] + 1),
11384        x = {
11385      dataId: t.dataId,
11386      shape: [1, y, n.inChannels],
11387      dtype: t.dtype
11388    },
11389        b = u.shape;
11390    u.shape = u.shape.slice(), u.shape[u.shape.length - 2]++, C(_e(u.shape, x.shape), function () {
11391      return "packed reshape " + u.shape + " to " + x.shape + " isn't free";
11392    });
11393    var w = this.reshape(e, [1, n.inChannels, n.outChannels]),
11394        E = this.fusedBatchMatMul({
11395      a: x,
11396      b: w,
11397      transposeA: !1,
11398      transposeB: !1,
11399      bias: r,
11400      activation: o,
11401      preluActivationWeights: a
11402    }),
11403        R = this.texData.get(E.dataId);
11404    return C(R.isPacked, function () {
11405      return "batchMatMul result is expected to be packed";
11406    }), u.shape = b, R.shape = n.outShape, Lt.makeTensorFromDataId(E.dataId, n.outShape, E.dtype);
11407  }, o.prototype.conv2dWithIm2Row = function (t, e, n, r, o, a) {
11408    var i = n.filterWidth,
11409        s = n.filterHeight,
11410        u = n.inChannels,
11411        c = n.outWidth,
11412        l = n.outHeight,
11413        h = "channelsLast" === n.dataFormat,
11414        f = i * s * u,
11415        d = l * c,
11416        p = [f, d],
11417        v = t.squeeze([0]),
11418        m = e.reshape([1, f, -1]),
11419        g = new Es(p, v.shape, n),
11420        y = this.compileAndRun(g, [v]).reshape([1, p[0], p[1]]),
11421        x = null != r,
11422        b = null != a,
11423        w = o ? Bu(o, !0) : null,
11424        C = new Ts(y.shape, [1, d, n.outChannels], !0, !1, x, w, b),
11425        E = [y, m];
11426    r && E.push(r), b && E.push(a);
11427    var R = this.compileAndRun(C, E);
11428    return h ? R.reshape([1, l, c, n.outChannels]) : R.reshape([1, n.outChannels, l, c]);
11429  }, o.prototype.fusedConv2d = function (t) {
11430    var e = t.input,
11431        n = t.filter,
11432        r = t.convInfo,
11433        o = t.bias,
11434        a = t.activation,
11435        s = t.preluActivationWeights;
11436    if (1 === r.filterHeight && 1 === r.filterWidth && 1 === r.dilationHeight && 1 === r.dilationWidth && 1 === r.strideHeight && 1 === r.strideWidth && ("SAME" === r.padInfo.type || "VALID" === r.padInfo.type)) return this.conv2dByMatMul(e, n, r, o, a, s);
11437    if (i().getBool("WEBGL_CONV_IM2COL") && 1 === e.shape[0]) return this.conv2dWithIm2Row(e, n, r, o, a, s);
11438    var u = null != o,
11439        c = null != s,
11440        l = a ? Bu(a, !1) : null,
11441        h = new Bi(r, u, l, c),
11442        f = [e, n];
11443    return o && f.push(o), s && f.push(s), this.compileAndRun(h, f);
11444  }, o.prototype.conv2d = function (t, e, n) {
11445    if (1 === n.filterHeight && 1 === n.filterWidth && 1 === n.dilationHeight && 1 === n.dilationWidth && 1 === n.strideHeight && 1 === n.strideWidth && ("SAME" === n.padInfo.type || "VALID" === n.padInfo.type)) return this.conv2dByMatMul(t, e, n);
11446    if (i().getBool("WEBGL_CONV_IM2COL") && 1 === t.shape[0]) return this.conv2dWithIm2Row(t, e, n);
11447    var r = new Bi(n);
11448    return this.compileAndRun(r, [t, e]);
11449  }
11449, o.prototype.conv2dDerInput = function (t, e, n) {
11450    var r = new Ni(n);
11451    return this.compileAndRun(r, [t, e]);
11452  }, o.prototype.conv2dDerFilter = function (t, e, n) {
11453    var r = new Di(n);
11454    return this.compileAndRun(r, [t, e]);
11455  }, o.prototype.fusedDepthwiseConv2D = function (t) {
11456    var e,
11457        n = t.input,
11458        r = t.filter,
11459        o = t.convInfo,
11460        a = t.bias,
11461        s = t.activation,
11462        u = t.preluActivationWeights,
11463        c = i().getBool("WEBGL_PACK_DEPTHWISECONV") && o.strideWidth <= 2 && o.outChannels / o.inChannels == 1,
11464        l = s ? Bu(s, c) : null,
11465        h = [n, r],
11466        f = null != a,
11467        d = null != u;
11468    return f && h.push(a), d && h.push(u), c ? (e = new Wi(o, f, l, d), this.compileAndRun(e, h)) : (e = new Li(o, f, l, d), this.compileAndRun(e, h));
11469  }, o.prototype.depthwiseConv2D = function (t, e, n) {
11470    var r;
11471    return i().getBool("WEBGL_PACK_DEPTHWISECONV") && n.strideWidth <= 2 && n.outChannels / n.inChannels == 1 ? (r = new Wi(n), this.compileAndRun(r, [t, e])) : (r = new Li(n), this.compileAndRun(r, [t, e]));
11472  }, o.prototype.depthwiseConv2DDerInput = function (t, e, n) {
11473    var r = new Mi(n);
11474    return this.compileAndRun(r, [t, e]);
11475  }, o.prototype.depthwiseConv2DDerFilter = function (t, e, n) {
11476    var r = new Oi(n);
11477    return this.compileAndRun(r, [t, e]);
11478  }, o.prototype.conv3d = function (t, e, n) {
11479    var r = new Pi(n);
11480    return this.compileAndRun(r, [t, e]);
11481  }, o.prototype.conv3dDerInput = function (t, e, n) {
11482    var r = new _i(n);
11483    return this.compileAndRun(r, [t, e]);
11484  }, o.prototype.conv3dDerFilter = function (t, e, n) {
11485    var r = new Fi(n);
11486    return this.compileAndRun(r, [t, e]);
11487  }, o.prototype.maxPool = function (t, e) {
11488    var n = new Ms(e, "max", !1);
11489    return this.compileAndRun(n, [t]);
11490  }, o.prototype.avgPool = function (t, e) {
11491    var n = new Ms(e, "avg", !1);
11492    return this.compileAndRun(n, [t], "float32");
11493  }, o.prototype.maxPoolBackprop = function (t, e, n, r) {
11494    var o = new Ms(r, "max", !0),
11495        a = this.compileAndRun(o, [e]),
11496        i = new Ss(r),
11497        s = this.compileAndRun(i, [t, a], e.dtype);
11498    return a.dispose(), s;
11499  }, o.prototype.avgPoolBackprop = function (t, e, n) {
11500    var r = new ui(n);
11501    return this.compileAndRun(r, [t], e.dtype);
11502  }, o.prototype.cast = function (t, e) {
11503    return ba(t, e, this);
11504  }, o.prototype.unstack = function (t, e) {
11505    for (var n = t.shape[e], r = new Array(t.rank - 1), o = 0, a = 0; a < t.rank; a++) a !== e && (r[o++] = t.shape[a]);
11506
11507    var i = new Array(t.rank).fill(0),
11508        s = t.shape.slice();
11509    s[e] = 1;
11510    var u = new Array(n);
11511
11512    for (a = 0; a < u.length; a++) i[e] = a, u[a] = this.slice(t, i, s).reshape(r);
11513
11514    return u;
11515  }, o.prototype.avgPool3d = function (t, e) {
11516    var n = new Bs(e, "avg", !1);
11517    return this.compileAndRun(n, [t], "float32");
11518  }, o.prototype.avgPool3dBackprop = function (t, e, n) {
11519    var r = new ci(n);
11520    return this.compileAndRun(r, [t], e.dtype);
11521  }, o.prototype.maxPool3d = function (t, e) {
11522    var n = new Bs(e, "max", !1);
11523    return this.compileAndRun(n, [t], "float32");
11524  }, o.prototype.maxPool3dBackprop = function (t, e, n, r) {
11525    var o = new Bs(r, "max", !0),
11526        a = this.compileAndRun(o, [e]),
11527        i = new As(r),
11528        s = this.compileAndRun(i, [t, a], e.dtype);
11529    return a.dispose(), s;
11530  }, o.prototype.reshape = function (t, e) {
11531    var n = this.texData.get(t.dataId);
11532
11533    if (n.isPacked && !_e(t.shape, e) && (null === n.texture || !_e(n.shape, e))) {
11534      var r = this.packedReshape(t, e);
11535      return Lt.makeTensorFromDataId(r.dataId, r.shape, r.dtype);
11536    }
11537
11538    return wa(t, e);
11539  }, o.prototype.resizeBilinear = function (t, e, n, r) {
11540    var o = i().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new Vs(t.shape, e, n, r) : new Us(t.shape, e, n, r);
11541    return this.compileAndRun(o, [t], "float32");
11542  }, o.prototype.resizeBilinearBackprop = function (t, e, n) {
11543    var r = new Ws(t, e, n);
11544    return this.compileAndRun(r, [t]);
11545  }, o.prototype.resizeNearestNeighbor = function (t, e, n, r) {
11546    var o = new Gs(t.shape, e, n, r);
11547    return this.compileAndRun(o, [t]);
11548  }, o.prototype.resizeNearestNeighborBackprop = function (t, e, n) {
11549    var r = new zs(t, e, n);
11550    return this.compileAndRun(r, [t]);
11551  }, o.prototype.multinomial = function (t, e, n, r) {
11552    var o = e ? t : ra(t),
11553        a = o.shape[0],
11554        i = o.shape[1],
11555        s = new Ds(a, i, n),
11556        u = s.getCustomSetupFunc(r);
11557    return this.compileAndRun(s, [o], "int32", u);
11558  }, o.prototype.oneHot = function (t, e, n, r) {
11559    var o = new Ns(t.size, e, n, r);
11560    return this.compileAndRun(o, [t]);
11561  }, o.prototype.diag = function (t) {
11562    var e = new Ki(t.size);
11563    return this.compileAndRun(e, [t]);
11564  }, o.prototype.nonMaxSuppression = function (t, e, n, r, o) {
11565    return dn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"), Da(t.dataSync(), e.dataSync(), n, r, o);
11566  }, o.prototype.cropAndResize = function (t, e, n, r, o, a) {
11567    var i = new Ui(t.shape, e.shape, r, o, a);
11568    return this.compileAndRun(i, [t, e, n], "float32");
11569  }, o.prototype.depthToSpace = function (t, e, n) {
11570    C(e > 1, function () {
11571      return "blockSize should be > 1 for depthToSpace, but was: " + e;
11572    });
11573    var r = t.shape[0],
11574        o = "NHWC" === n ? t.shape[1] : t.shape[2],
11575        a = "NHWC" === n ? t.shape[2] : t.shape[3],
11576        i = "NHWC" === n ? t.shape[3] : t.shape[1],
11577        s = o * e,
11578        u = a * e,
11579        c = i / (e * e),
11580        l = new qi("NHWC" === n ? [r, s, u, c] : [r, c, s, u], e, n);
11581    return this.compileAndRun(l, [t]);
11582  }, o.prototype.split = function (t, e, n) {
11583    return Ba(t, e, n);
11584  }, o.prototype.scatterND = function (t, e, n) {
11585    var r = Uo(0, t, n),
11586        o = r.sliceRank,
11587        a = r.numUpdates,
11588        i = r.sliceSize,
11589        s = r.strides,
11590        u = r.outputSize,
11591        c = [u / i, i],
11592        l = t.reshape([a, o]),
11593        h = e.reshape([a, i]);
11594    if (0 === u) return wa(Fn([]), n);
11595    var f = On(0),
11596        d = new Ks(a, o, l.rank, h.rank, s, c);
11597    return this.compileAndRun(d, [h, l, f]).reshape(n);
11598  }, o.prototype.sparseToDense = function (t, e, n, r) {
11599    var o = Uo(0, t, n),
11600        a = o.sliceRank,
11601        i = o.numUpdates,
11602        s = o.strides,
11603        u = o.outputSize,
11604        c = new Ks(i, a, t.rank, e.rank, s, [u, 1], !1);
11605    return this.compileAndRun(c, [e, t, r]).reshape(n);
11606  }, o.prototype.fft = function (t) {
11607    return this.fftImpl(t, !1);
11608  }, o.prototype.ifft = function (t) {
11609    return this.fftImpl(t, !0);
11610  }, o.prototype.fftImpl = function (t, e) {
11611    var n = this.texData.get(t.dataId),
11612        r = new Zi(Qi, t.shape, e),
11613        o = new Zi(Ji, t.shape, e),
11614        a = [this.makeComplexComponentTensorInfo(t, n.complexTensors.real), this.makeComplexComponentTensorInfo(t, n.complexTensors.imag)],
11615        i = this.compileAndRun(r, a),
11616        s = this.compileAndRun(o, a),
11617        u = this.complex(i, s).as2D(t.shape[0], t.shape[1]);
11618    return i.dispose(), s.dispose(), u;
11619  }, o.prototype.gatherND = function (t, e) {
11620    var n = e.shape,
11621        r = n[n.length - 1],
11622        o = Oo(t, e),
11623        a = o[0],
11624        i = o[1],
11625        s = o[2],
11626        u = o[3],
11627        c = e.reshape([i, r]),
11628        l = t.reshape([t.size / s, s]),
11629        h = new ns(r, u, [i, s]);
11630    return this.compileAndRun(h, [l, c]).reshape(a);
11631  }, o.prototype.fill = function (t, e, n) {
11632    if ("string" === (n = n || j(e))) {
11633      var r = P(n, k(t));
11634      return r.fill(e), Lt.makeTensor(r, t, n, this);
11635    }
11636
11637    var o = new ts(t, e),
11638        a = o.getCustomSetupFunc(e);
11639    return this.compileAndRun(o, [], n, a);
11640  }, o.prototype.onesLike = function (t) {
11641    if ("string" === t.dtype) throw new Error("onesLike is not supported under string dtype");
11642    return this.fill(t.shape, 1, t.dtype);
11643  }, o.prototype.zerosLike = function (t) {
11644    return this.fill(t.shape, "string" === t.dtype ? "" : 0, t.dtype);
11645  }, o.prototype.linspace = function (t, e, n) {
11646    return Ca(t, e, n);
11647  }, o.prototype.makeTensorInfo = function (t, e) {
11648    var n = this.write(null, t, e);
11649    return this.texData.get(n).usage = null, {
11650      dataId: n,
11651      shape: t,
11652      dtype: e
11653    };
11654  }, o.prototype.makeOutput = function (t, e) {
11655    var n = this.makeTensorInfo(t, e).dataId;
11656    return Lt.makeTensorFromDataId(n, t, e, this);
11657  }, o.prototype.unpackTensor = function (t) {
11658    var e = new Ou(t.shape);
11659    return this.runWebGLProgram(e, [t], t.dtype);
11660  }, o.prototype.packTensor = function (t) {
11661    var e = new Fs(t.shape);
11662    return this.runWebGLProgram(e, [t], t.dtype, null, !0);
11663  }, o.prototype.packedReshape = function (t, e) {
11664    var n = [Ae(t.shape)].concat(Te(t.shape)),
11665        r = {
11666      dtype: t.dtype,
11667      shape: n,
11668      dataId: t.dataId
11669    },
11670        o = [Ae(e)].concat(Te(e)),
11671        a = new Ls(o, n),
11672        i = this.runWebGLProgram(a, [r], t.dtype, null, !0);
11673    return {
11674      dataId: i.dataId,
11675      shape: e,
11676      dtype: i.dtype
11677    };
11678  }, o.prototype.decode = function (t) {
11679    var e,
11680        n = this.texData.get(t),
11681        r = n.isPacked,
11682        o = n.shape,
11683        a = n.dtype,
11684        i = De(o);
11685    e = r ? new Hi(i) : new Gi(i);
11686    return {
11687      dtype: a,
11688      shape: o,
11689      dataId: this.runWebGLProgram(e, [{
11690        shape: i,
11691        dtype: a,
11692        dataId: t
11693      }], a, null, !0).dataId
11694    };
11695  }, o.prototype.runWebGLProgram = function (t, e, n, r, o) {
11696    var a = this;
11697    void 0 === o && (o = !1);
11698    var s = this.makeTensorInfo(t.outputShape, n),
11699        u = this.texData.get(s.dataId);
11700
11701    if (t.packedOutput && (u.isPacked = !0), t.outPackingScheme === Vt.DENSE) {
11702      var c = Yt(t.outputShape);
11703      u.texShape = c.map(function (t) {
11704        return 2 * t;
11705      });
11706    }
11707
11708    if (null != t.outTexUsage && (u.usage = t.outTexUsage), 0 === k(s.shape)) return u.values = B(s.dtype, 0), s;
11709    var l = [],
11710        h = e.map(function (e) {
11711      if ("complex64" === e.dtype) throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");
11712      var n = a.texData.get(e.dataId);
11713
11714      if (null == n.texture) {
11715        if (!t.packedInputs && k(e.shape) <= i().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM")) return {
11716          shape: e.shape,
11717          texData: null,
11718          isUniform: !0,
11719          uniformValues: n.values
11720        };
11721        t.packedInputs && (n.isPacked = !0, n.shape = e.shape);
11722      } else if (!!n.isPacked != !!t.packedInputs) e = n.isPacked ? a.unpackTensor(e) : a.packTensor(e), l.push(e), n = a.texData.get(e.dataId);else if (n.isPacked && !_e(n.shape, e.shape)) {
11723        var r = e,
11724            o = e.shape;
11725        e.shape = n.shape, e = a.packedReshape(e, o), l.push(e), n = a.texData.get(e.dataId), r.shape = o;
11726      }
11727
11728      return a.uploadToGPU(e.dataId), {
11729        shape: e.shape,
11730        texData: n,
11731        isUniform: !1
11732      };
11733    });
11734    this.uploadToGPU(s.dataId);
11735
11736    var f,
11737        d = {
11738      shape: s.shape,
11739      texData: u,
11740      isUniform: !1
11741    },
11742        p = function (t, e, n) {
11743      var r = "";
11744      e.concat(n).forEach(function (t) {
11745        var e = null != t.texData && null != t.texData.slice && t.texData.slice.flatOffset > 0,
11746            n = t.isUniform ? "uniform" : t.texData.texShape;
11747        r += t.shape + "_" + n + "_" + e;
11748      });
11749      var o = t.userCode,
11750          a = t.constructor.name;
11751      return a += "_" + r + "_" + o;
11752    }(t, h, d),
11753        v = this.getAndSaveBinary(p, function () {
11754      return function (t, e, n, r) {
11755        var o = e.userCode,
11756            a = n.map(function (t, n) {
11757          var r = {
11758            logicalShape: t.shape,
11759            texShape: t.isUniform ? null : t.texData.texShape,
11760            isUniform: t.isUniform,
11761            isPacked: !t.isUniform && t.texData.isPacked,
11762            flatOffset: null
11763          };
11764          return null != t.texData && null != t.texData.slice && t.texData.slice.flatOffset > 0 && (r.flatOffset = t.texData.slice.flatOffset), {
11765            name: e.variableNames[n],
11766            shapeInfo: r
11767          };
11768        }),
11769            s = a.map(function (t) {
11770          return t.shapeInfo;
11771        }),
11772            u = {
11773          logicalShape: r.shape,
11774          texShape: r.texData.texShape,
11775          isUniform: !1,
11776          isPacked: r.texData.isPacked,
11777          flatOffset: null
11778        },
11779            c = Ya(a, u, o, e.packedInputs),
11780            l = t.createProgram(c),
11781            h = null,
11782            f = t.getUniformLocation(l, "NAN", !1);
11783        1 === i().getNumber("WEBGL_VERSION") && (h = t.getUniformLocation(l, "INFINITY", !1));
11784
11785        for (var d = {}, p = 0; p < e.variableNames.length; p++) {
11786          var v = e.variableNames[p];
11787          d[v] = t.getUniformLocation(l, v, !1), d["offset" + v] = t.getUniformLocation(l, "offset" + v, !1);
11788        }
11789
11790        return {
11791          program: e,
11792          source: c,
11793          webGLProgram: l,
11794          uniformLocations: d,
11795          inShapeInfos: s,
11796          outShapeInfo: u,
11797          infLoc: h,
11798          nanLoc: f
11799        };
11800      }(a.gpgpu, t, h, d);
11801    }),
11802        m = null != this.activeTimers;
11803
11804    if (m && (f = this.startTimer()), function (t, e, n, r, o) {
11805      Cs(e.inShapeInfos, n), Cs([e.outShapeInfo], [r]);
11806      var a = r.texData.texture,
11807          s = r.texData.texShape;
11808      r.texData.isPacked ? t.setOutputPackedMatrixTexture(a, s[0], s[1]) : t.setOutputMatrixTexture(a, s[0], s[1]), t.setProgram(e.webGLProgram), 1 === i().getNumber("WEBGL_VERSION") && null !== e.infLoc && t.gl.uniform1f(e.infLoc, 1 / 0), null !== e.nanLoc && t.gl.uniform1f(e.nanLoc, NaN), n.forEach(function (n, r) {
11809        var o = e.program.variableNames[r],
11810            a = e.uniformLocations[o],
11811            i = e.uniformLocations["offset" + o];
11812        if (null != a) if (n.isUniform) {
11813          if (k(n.shape) < 2) t.gl.uniform1f(a, n.uniformValues[0]);else {
11814            var s = n.uniformValues;
11815            s instanceof Float32Array || (s = new Float32Array(s)), t.gl.uniform1fv(a, s);
11816          }
11817        } else null != n.texData.slice && null != i && t.gl.uniform1i(i, n.texData.slice.flatOffset), t.setInputMatrixTexture(n.texData.texture, a, r);
11818      }), null != o && o(t, e.webGLProgram), t.executeProgram();
11819    }(this.gpgpu, v, h, d, r), l.forEach(function (t) {
11820      return a.disposeData(t.dataId);
11821    }), m && (f = this.endTimer(f), this.activeTimers.push({
11822      name: t.constructor.name,
11823      query: this.getQueryTime(f)
11824    })), !i().getBool("WEBGL_LAZILY_UNPACK") && u.isPacked && !1 === o) {
11825      var g = this.unpackTensor(s);
11826      return this.disposeData(s.dataId), g;
11827    }
11828
11829    return s;
11830  }, o.prototype.compileAndRun = function (t, e, n, r, o) {
11831    void 0 === o && (o = !1), n = n || e[0].dtype;
11832    var a = this.runWebGLProgram(t, e, n, r, o);
11833    return Lt.makeTensorFromDataId(a.dataId, a.shape, a.dtype);
11834  }, o.prototype.getAndSaveBinary = function (t, e) {
11835    return t in this.binaryCache || (this.binaryCache[t] = e()), this.binaryCache[t];
11836  }, o.prototype.getTextureManager = function () {
11837    return this.textureManager;
11838  }, o.prototype.dispose = function () {
11839    var t = this;
11840
11841    if (!this.disposed) {
11842      if (!i().getBool("IS_TEST")) Object.keys(this.binaryCache).forEach(function (e) {
11843        t.gpgpu.deleteProgram(t.binaryCache[e].webGLProgram), delete t.binaryCache[e];
11844      });
11845      this.textureManager.dispose(), null != this.canvas && "undefined" != typeof HTMLCanvasElement && this.canvas instanceof HTMLCanvasElement ? this.canvas.remove() : this.canvas = null, this.gpgpuCreatedLocally && (this.gpgpu.program = null, this.gpgpu.dispose()), this.disposed = !0;
11846    }
11847  }, o.prototype.floatPrecision = function () {
11848    var t = this;
11849    return null == this.floatPrecisionValue && (this.floatPrecisionValue = Ze(function () {
11850      if (!i().get("WEBGL_RENDER_FLOAT32_ENABLED")) {
11851        var e = i().getBool("DEBUG");
11852        i().set("DEBUG", !1);
11853        var n = t.abs(On(1e-8)).dataSync()[0];
11854        if (i().set("DEBUG", e), n > 0) return 32;
11855      }
11856
11857      return 16;
11858    })), this.floatPrecisionValue;
11859  }, o.prototype.epsilon = function () {
11860    return 32 === this.floatPrecision() ? 1e-7 : 1e-4;
11861  }, o.prototype.uploadToGPU = function (t) {
11862    var e,
11863        n = this.texData.get(t),
11864        r = n.shape,
11865        o = n.dtype,
11866        a = n.values,
11867        i = n.texture,
11868        s = n.usage,
11869        u = n.isPacked;
11870
11871    if (null == i) {
11872      var c,
11873          l = null != this.activeTimers;
11874      l && (c = et());
11875      var h = n.texShape;
11876
11877      if (null == h && (h = Ne(r, u), n.texShape = h), null != a) {
11878        var f = De(r),
11879            d = void 0,
11880            p = h[1],
11881            v = h[0],
11882            m = a instanceof Uint8Array;
11883        u ? (p = (e = $t(h[0], h[1]))[0], v = e[1], d = new $i(f, [v, p], m)) : d = new Yi(f, [v, p], m);
11884        var g = this.makeTensorInfo([v, p], o);
11885        this.texData.get(g.dataId).usage = m ? zt.PIXELS : zt.UPLOAD, this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(g.dataId), p, v, a);
11886        var y = this.runWebGLProgram(d, [g], o, null, !0),
11887            x = this.texData.get(y.dataId);
11888        n.texture = x.texture, n.texShape = x.texShape, n.isPacked = x.isPacked, n.usage = x.usage, this.disposeData(g.dataId), this.texData.delete(y.dataId), n.values = null, l && (this.uploadWaitMs += et() - c);
11889      } else {
11890        var b = this.acquireTexture(h, s, o, u);
11891        n.texture = b;
11892      }
11893    }
11894  }, o.prototype.convertAndCacheOnCPU = function (t, e) {
11895    var n = this.texData.get(t),
11896        r = n.dtype;
11897    return this.releaseGPUData(t), null != e && (n.values = function (t, e) {
11898      if ("float32" === e || "complex64" === e) return t;
11899
11900      if ("int32" === e || "bool" === e) {
11901        for (var n = "int32" === e ? new Int32Array(t.length) : new Uint8Array(t.length), r = 0; r < n.length; ++r) n[r] = Math.round(t[r]);
11902
11903        return n;
11904      }
11905
11906      throw new Error("Unknown dtype " + e);
11907    }(e, r)), n.values;
11908  }, o.prototype.acquireTexture = function (t, e, n, r) {
11909    if (this.numBytesInGPU += this.computeBytes(t, n), !this.warnedAboutMemory && this.numBytesInGPU > 1024 * this.numMBBeforeWarning * 1024) {
11910      var o = (this.numBytesInGPU / 1024 / 1024).toFixed(2);
11911      this.warnedAboutMemory = !0, console.warn("High memory usage in GPU: " + o + " MB, most likely due to a memory leak");
11912    }
11913
11914    return this.textureManager.acquireTexture(t, e, r);
11915  }, o.prototype.computeBytes = function (t, e) {
11916    return t[0] * t[1] * z(e);
11917  }, o;
11918}(ia);
11919
11920Wt() && Lt.registerBackend("webgl", function () {
11921  return new Lu();
11922}, 2);
11923"undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self && self;
11924
11925function Wu(t, e) {
11926  return t(e = {
11927    exports: {}
11928  }, e.exports), e.exports;
11929}
11930
11931var Uu = Wu(function (t) {
11932  !function (t, e, n) {
11933    function r(t) {
11934      var e,
11935          n = this,
11936          r = (e = 4022871197, function (t) {
11937        t = t.toString();
11938
11939        for (var n = 0; n < t.length; n++) {
11940          var r = .02519603282416938 * (e += t.charCodeAt(n));
11941          r -= e = r >>> 0, e = (r *= e) >>> 0, e += 4294967296 * (r -= e);
11942        }
11943
11944        return 2.3283064365386963e-10 * (e >>> 0);
11945      });
11946      n.next = function () {
11947        var t = 2091639 * n.s0 + 2.3283064365386963e-10 * n.c;
11948        return n.s0 = n.s1, n.s1 = n.s2, n.s2 = t - (n.c = 0 | t);
11949      }, 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;
11950    }
11951
11952    function o(t, e) {
11953      return e.c = t.c, e.s0 = t.s0, e.s1 = t.s1, e.s2 = t.s2, e;
11954    }
11955
11956    function a(t, e) {
11957      var n = new r(t),
11958          a = e && e.state,
11959          i = n.next;
11960      return i.int32 = function () {
11961        return 4294967296 * n.next() | 0;
11962      }, i.double = function () {
11963        return i() + 11102230246251565e-32 * (2097152 * i() | 0);
11964      }, i.quick = i, a && ("object" == typeof a && o(a, n), i.state = function () {
11965        return o(n, {});
11966      }), i;
11967    }
11968
11969    e && e.exports ? e.exports = a : n && n.amd ? n(function () {
11970      return a;
11971    }) : this.alea = a;
11972  }(0, t, !1);
11973}),
11974    Vu = Wu(function (t) {
11975  !function (t, e, n) {
11976    function r(t) {
11977      var e = this,
11978          n = "";
11979      e.x = 0, e.y = 0, e.z = 0, e.w = 0, e.next = function () {
11980        var t = e.x ^ e.x << 11;
11981        return e.x = e.y, e.y = e.z, e.z = e.w, e.w ^= e.w >>> 19 ^ t ^ t >>> 8;
11982      }, t === (0 | t) ? e.x = t : n += t;
11983
11984      for (var r = 0; r < n.length + 64; r++) e.x ^= 0 | n.charCodeAt(r), e.next();
11985    }
11986
11987    function o(t, e) {
11988      return e.x = t.x, e.y = t.y, e.z = t.z, e.w = t.w, e;
11989    }
11990
11991    function a(t, e) {
11992      var n = new r(t),
11993          a = e && e.state,
11994          i = function () {
11995        return (n.next() >>> 0) / 4294967296;
11996      };
11997
11998      return i.double = function () {
11999        do {
12000          var t = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21);
12001        } while (0 === t);
12002
12003        return t;
12004      }, i.int32 = n.next, i.quick = i, a && ("object" == typeof a && o(a, n), i.state = function () {
12005        return o(n, {});
12006      }), i;
12007    }
12008
12009    e && e.exports ? e.exports = a : n && n.amd ? n(function () {
12010      return a;
12011    }) : this.xor128 = a;
12012  }(0, t, !1);
12013}),
12014    zu = Wu(function (t) {
12015  !function (t, e, n) {
12016    function r(t) {
12017      var e = this,
12018          n = "";
12019      e.next = function () {
12020        var t = e.x ^ e.x >>> 2;
12021        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;
12022      }, e.x = 0, e.y = 0, e.z = 0, e.w = 0, e.v = 0, t === (0 | t) ? e.x = t : n += t;
12023
12024      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();
12025    }
12026
12027    function o(t, e) {
12028      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;
12029    }
12030
12031    function a(t, e) {
12032      var n = new r(t),
12033          a = e && e.state,
12034          i = function () {
12035        return (n.next() >>> 0) / 4294967296;
12036      };
12037
12038      return i.double = function () {
12039        do {
12040          var t = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21);
12041        } while (0 === t);
12042
12043        return t;
12044      }, i.int32 = n.next, i.quick = i, a && ("object" == typeof a && o(a, n), i.state = function () {
12045        return o(n, {});
12046      }), i;
12047    }
12048
12049    e && e.exports ? e.exports = a : n && n.amd ? n(function () {
12050      return a;
12051    }) : this.xorwow = a;
12052  }(0, t, !1);
12053}),
12054    Gu = Wu(function (t) {
12055  !function (t, e, n) {
12056    function r(t) {
12057      var e = this;
12058      e.next = function () {
12059        var t,
12060            n,
12061            r = e.x,
12062            o = e.i;
12063        return t = r[o], n = (t ^= t >>> 7) ^ t << 24, n ^= (t = r[o + 1 & 7]) ^ t >>> 10, n ^= (t = r[o + 3 & 7]) ^ t >>> 3, n ^= (t = r[o + 4 & 7]) ^ t << 7, t = r[o + 7 & 7], n ^= (t ^= t << 13) ^ t << 9, r[o] = n, e.i = o + 1 & 7, n;
12064      }, function (t, e) {
12065        var n,
12066            r = [];
12067        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;
12068
12069        for (; r.length < 8;) r.push(0);
12070
12071        for (n = 0; n < 8 && 0 === r[n]; ++n);
12072
12073        for (8 == n ? r[7] = -1 : r[n], t.x = r, t.i = 0, n = 256; n > 0; --n) t.next();
12074      }(e, t);
12075    }
12076
12077    function o(t, e) {
12078      return e.x = t.x.slice(), e.i = t.i, e;
12079    }
12080
12081    function a(t, e) {
12082      null == t && (t = +new Date());
12083
12084      var n = new r(t),
12085          a = e && e.state,
12086          i = function () {
12087        return (n.next() >>> 0) / 4294967296;
12088      };
12089
12090      return i.double = function () {
12091        do {
12092          var t = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21);
12093        } while (0 === t);
12094
12095        return t;
12096      }, i.int32 = n.next, i.quick = i, a && (a.x && o(a, n), i.state = function () {
12097        return o(n, {});
12098      }), i;
12099    }
12100
12101    e && e.exports ? e.exports = a : n && n.amd ? n(function () {
12102      return a;
12103    }) : this.xorshift7 = a;
12104  }(0, t, !1);
12105}),
12106    Hu = Wu(function (t) {
12107  !function (t, e, n) {
12108    function r(t) {
12109      var e = this;
12110      e.next = function () {
12111        var t,
12112            n,
12113            r = e.w,
12114            o = e.X,
12115            a = e.i;
12116        return e.w = r = r + 1640531527 | 0, n = o[a + 34 & 127], t = o[a = a + 1 & 127], n ^= n << 13, t ^= t << 17, n ^= n >>> 15, t ^= t >>> 12, n = o[a] = n ^ t, e.i = a, n + (r ^ r >>> 16) | 0;
12117      }, function (t, e) {
12118        var n,
12119            r,
12120            o,
12121            a,
12122            i,
12123            s = [],
12124            u = 128;
12125
12126        for (e === (0 | e) ? (r = e, e = null) : (e += "\0", r = 0, u = Math.max(u, e.length)), o = 0, a = -32; a < u; ++a) e && (r ^= e.charCodeAt((a + 32) % e.length)), 0 === a && (i = r), r ^= r << 10, r ^= r >>> 15, r ^= r << 4, r ^= r >>> 13, a >= 0 && (i = i + 1640531527 | 0, o = 0 == (n = s[127 & a] ^= r + i) ? o + 1 : 0);
12127
12128        for (o >= 128 && (s[127 & (e && e.length || 0)] = -1), o = 127, a = 512; a > 0; --a) r = s[o + 34 & 127], n = s[o = o + 1 & 127], r ^= r << 13, n ^= n << 17, r ^= r >>> 15, n ^= n >>> 12, s[o] = r ^ n;
12129
12130        t.w = i, t.X = s, t.i = o;
12131      }(e, t);
12132    }
12133
12134    function o(t, e) {
12135      return e.i = t.i, e.w = t.w, e.X = t.X.slice(), e;
12136    }
12137
12138    function a(t, e) {
12139      null == t && (t = +new Date());
12140
12141      var n = new r(t),
12142          a = e && e.state,
12143          i = function () {
12144        return (n.next() >>> 0) / 4294967296;
12145      };
12146
12147      return i.double = function () {
12148        do {
12149          var t = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21);
12150        } while (0 === t);
12151
12152        return t;
12153      }, i.int32 = n.next, i.quick = i, a && (a.X && o(a, n), i.state = function () {
12154        return o(n, {});
12155      }), i;
12156    }
12157
12158    e && e.exports ? e.exports = a : n && n.amd ? n(function () {
12159      return a;
12160    }) : this.xor4096 = a;
12161  }(0, t, !1);
12162}),
12163    qu = Wu(function (t) {
12164  !function (t, e, n) {
12165    function r(t) {
12166      var e = this,
12167          n = "";
12168      e.next = function () {
12169        var t = e.b,
12170            n = e.c,
12171            r = e.d,
12172            o = e.a;
12173        return t = t << 25 ^ t >>> 7 ^ n, n = n - r | 0, r = r << 24 ^ r >>> 8 ^ o, o = o - t | 0, e.b = t = t << 20 ^ t >>> 12 ^ n, e.c = n = n - r | 0, e.d = r << 16 ^ n >>> 16 ^ o, e.a = o - t | 0;
12174      }
12174, 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;
12175
12176      for (var r = 0; r < n.length + 20; r++) e.b ^= 0 | n.charCodeAt(r), e.next();
12177    }
12178
12179    function o(t, e) {
12180      return e.a = t.a, e.b = t.b, e.c = t.c, e.d = t.d, e;
12181    }
12182
12183    function a(t, e) {
12184      var n = new r(t),
12185          a = e && e.state,
12186          i = function () {
12187        return (n.next() >>> 0) / 4294967296;
12188      };
12189
12190      return i.double = function () {
12191        do {
12192          var t = ((n.next() >>> 11) + (n.next() >>> 0) / 4294967296) / (1 << 21);
12193        } while (0 === t);
12194
12195        return t;
12196      }, i.int32 = n.next, i.quick = i, a && ("object" == typeof a && o(a, n), i.state = function () {
12197        return o(n, {});
12198      }), i;
12199    }
12200
12201    e && e.exports ? e.exports = a : n && n.amd ? n(function () {
12202      return a;
12203    }) : this.tychei = a;
12204  }(0, t, !1);
12205}),
12206    Ku = Wu(function (t) {
12207  !function (e, n) {
12208    var r,
12209        o = this,
12210        a = 256,
12211        i = 6,
12212        s = "random",
12213        u = n.pow(a, i),
12214        c = n.pow(2, 52),
12215        l = 2 * c,
12216        h = a - 1;
12217
12218    function f(t, h, f) {
12219      var g = [],
12220          y = v(function t(e, n) {
12221        var r,
12222            o = [],
12223            a = typeof e;
12224        if (n && "object" == a) for (r in e) try {
12225          o.push(t(e[r], n - 1));
12226        } catch (t) {}
12227        return o.length ? o : "string" == a ? e : e + "\0";
12228      }((h = 1 == h ? {
12229        entropy: !0
12230      } : h || {}).entropy ? [t, m(e)] : null == t ? function () {
12231        try {
12232          var t;
12233          return r && (t = r.randomBytes) ? t = t(a) : (t = new Uint8Array(a), (o.crypto || o.msCrypto).getRandomValues(t)), m(t);
12234        } catch (t) {
12235          var n = o.navigator,
12236              i = n && n.plugins;
12237          return [+new Date(), o, i, o.screen, m(e)];
12238        }
12239      }() : t, 3), g),
12240          x = new d(g),
12241          b = function () {
12242        for (var t = x.g(i), e = u, n = 0; t < c;) t = (t + n) * a, e *= a, n = x.g(1);
12243
12244        for (; t >= l;) t /= 2, e /= 2, n >>>= 1;
12245
12246        return (t + n) / e;
12247      };
12248
12249      return b.int32 = function () {
12250        return 0 | x.g(4);
12251      }, b.quick = function () {
12252        return x.g(4) / 4294967296;
12253      }, b.double = b, v(m(x.S), e), (h.pass || f || function (t, e, r, o) {
12254        return o && (o.S && p(o, x), t.state = function () {
12255          return p(x, {});
12256        }), r ? (n[s] = t, e) : t;
12257      })(b, y, "global" in h ? h.global : this == n, h.state);
12258    }
12259
12260    function d(t) {
12261      var e,
12262          n = t.length,
12263          r = this,
12264          o = 0,
12265          i = r.i = r.j = 0,
12266          s = r.S = [];
12267
12268      for (n || (t = [n++]); o < a;) s[o] = o++;
12269
12270      for (o = 0; o < a; o++) s[o] = s[i = h & i + t[o % n] + (e = s[o])], s[i] = e;
12271
12272      (r.g = function (t) {
12273        for (var e, n = 0, o = r.i, i = r.j, s = r.S; t--;) e = s[o = h & o + 1], n = n * a + s[h & (s[o] = s[i = h & i + e]) + (s[i] = e)];
12274
12275        return r.i = o, r.j = i, n;
12276      })(a);
12277    }
12278
12279    function p(t, e) {
12280      return e.i = t.i, e.j = t.j, e.S = t.S.slice(), e;
12281    }
12282
12283    function v(t, e) {
12284      for (var n, r = t + "", o = 0; o < r.length;) e[h & o] = h & (n ^= 19 * e[h & o]) + r.charCodeAt(o++);
12285
12286      return m(e);
12287    }
12288
12289    function m(t) {
12290      return String.fromCharCode.apply(0, t);
12291    }
12292
12293    if (n["seed" + s] = f, v(n.random(), e), t.exports) {
12294      t.exports = f;
12295
12296      try {
12297        r = require("crypto");
12298      } catch (t) {}
12299    }
12300  }([], Math);
12301});
12302Ku.alea = Uu, Ku.xor128 = Vu, Ku.xorwow = zu, Ku.xorshift7 = Gu, Ku.xor4096 = Hu, Ku.tychei = qu;
12303var ju = Ku.alea;
12304var Xu = An({
12305  broadcastTo_: function (t, e) {
12306    var n = mn(t, "broadcastTo", "x"),
12307        r = n.shape;
12308    if (e.some(function (t) {
12309      return !(t > 0) || t % 1 != 0;
12310    })) throw new Error("broadcastTo(): Invalid broadcast shape [" + e + "].");
12311    if (e.length < n.rank) throw new Error("broadcastTo(): shape.length=" + e.length + " < input.rank=" + n.rank + ".");
12312
12313    if (e.length > n.rank) {
12314      for (var o = n.shape.slice(); o.length < e.length;) o.unshift(1);
12315
12316      n = n.reshape(o);
12317    }
12318
12319    for (var a = n.shape, i = Array.from(e), s = e.length - 1; s >= 0; s--) if (a[s] === e[s]) i[s] = 1;else if (1 !== n.shape[s]) throw new Error("broadcastTo(): [" + r + "] cannot be broadcast to [" + e + "].");
12320
12321    var u = i.map(function (t, e) {
12322      return t > 1 ? e : -1;
12323    }).filter(function (t) {
12324      return t >= 0;
12325    });
12326    if (0 === u.length) return n.clone();
12327    var c = {
12328      x: n
12329    },
12330        l = {
12331      shape: e,
12332      inputShape: a
12333    };
12334    return Lt.runKernelFunc(function (t) {
12335      return t.tile(n, i);
12336    }, c, function (t) {
12337      return {
12338        x: function () {
12339          return t.sum(u, !0);
12340        }
12341      };
12342    }, kr, l);
12343  }
12344});
12345exports.broadcastTo = Xu;
12346var Yu = An({
12347  clone_: function (t) {
12348    var e = mn(t, "x", "clone", null);
12349    return Lt.runKernelFunc(function () {
12350      return Lt.makeTensorFromDataId(e.dataId, e.shape, e.dtype);
12351    }, {
12352      x: e
12353    }, null, Ar);
12354  }
12355});
12356exports.clone = Yu;
12357
12358var $u = An({
12359  logicalAnd_: function (t, e) {
12360    var n = mn(t, "a", "logicalAnd", "bool"),
12361        r = mn(e, "b", "logicalAnd", "bool");
12362    return Fr(n.shape, r.shape), Lt.runKernelFunc(function (t) {
12363      return t.logicalAnd(n, r);
12364    }, {
12365      a: n,
12366      b: r
12367    }, null, "LogicalAnd");
12368  }
12369}),
12370    Qu = An({
12371  logicalNot_: function (t) {
12372    var e = mn(t, "x", "logicalNot", "bool");
12373    return Lt.runKernelFunc(function (t) {
12374      return t.logicalNot(e);
12375    }, {
12376      $x: e
12377    });
12378  }
12379}),
12380    Ju = An({
12381  logicalOr_: function (t, e) {
12382    var n = mn(t, "a", "logicalOr", "bool"),
12383        r = mn(e, "b", "logicalOr", "bool");
12384    return Fr(n.shape, r.shape), Lt.runKernelFunc(function (t) {
12385      return t.logicalOr(n, r);
12386    }, {
12387      $a: n,
12388      $b: r
12389    });
12390  }
12391}),
12392    Zu = An({
12393  logicalXor_: function (t, e) {
12394    var n = mn(t, "a", "logicalXor", "bool"),
12395        r = mn(e, "b", "logicalXor", "bool");
12396    return Fr(n.shape, r.shape), Ju(t, e).logicalAnd($u(t, e).logicalNot());
12397  }
12398}),
12399    tc = An({
12400  where_: function (t, e, n) {
12401    var r = mn(e, "a", "where"),
12402        o = mn(n, "b", "where"),
12403        a = mn(t, "condition", "where", "bool");
12404    return E(r.shape, o.shape, "Error in where: "), 1 === a.rank ? C(a.shape[0] === r.shape[0], function () {
12405      return "The first dimension of `a` must match the size of `condition`.";
12406    }) : E(a.shape, o.shape, "Error in where: "), Lt.runKernelFunc(function (t, e) {
12407      var n = t.select(a, r, o);
12408      return e([a]), n;
12409    }, {
12410      $condition: a,
12411      $a: r,
12412      $b: o
12413    }, function (t, e) {
12414      var n = e[0];
12415      return {
12416        $condition: function () {
12417          return Xn(n).toFloat();
12418        },
12419        $a: function () {
12420          return t.mul(n.cast(t.dtype));
12421        },
12422        $b: function () {
12423          return t.mul(n.logicalNot().cast(t.dtype));
12424        }
12425      };
12426    });
12427  }
12428}),
12429    ec = function (t) {
12430  return n(this, void 0, void 0, function () {
12431    var e, n, o;
12432    return r(this, function (r) {
12433      switch (r.label) {
12434        case 0:
12435          return [4, (e = mn(t, "condition", "whereAsync", "bool")).data()];
12436
12437        case 1:
12438          return n = r.sent(), o = Wa(e.shape, n), t !== e && e.dispose(), [2, o];
12439      }
12440    });
12441  });
12442};
12443
12444exports.whereAsync = ec;
12445exports.where = tc;
12446exports.logicalXor = Zu;
12447exports.logicalOr = Ju;
12448exports.logicalNot = Qu;
12449exports.logicalAnd = $u;
12450var nc = An({
12451  divNoNan_: function (t, e) {
12452    var n,
12453        r = mn(t, "a", "div"),
12454        o = mn(e, "b", "div");
12455    r = (n = Nt(r, o))[0], o = n[1];
12456
12457    var a = _o(r, o),
12458        i = Xn(a),
12459        s = o.equal(i);
12460
12461    return tc(s, i, a);
12462  }
12463});
12464exports.divNoNan = nc;
12465var rc = An({
12466  tile_: function (t, e) {
12467    var n = mn(t, "x", "tile", null);
12468    C(n.rank === e.length, function () {
12469      return "Error in transpose: rank of input " + n.rank + " must match length of reps " + e + ".";
12470    });
12471    var r = [n],
12472        o = {
12473      x: n
12474    },
12475        a = {
12476      reps: e
12477    };
12478    return Lt.runKernelFunc(function (t, r) {
12479      var o = t.tile(n, e);
12480      return r([n]), o;
12481    }, o, null, Tr, a, r);
12482  }
12483});
12484exports.tile = rc;
12485var oc = An({
12486  eye_: function (t, e, n, r) {
12487    void 0 === r && (r = "float32"), null == e && (e = t);
12488
12489    for (var o = er([t, e], r), a = t <= e ? t : e, i = 0; i < a; ++i) o.set(1, i, i);
12490
12491    var s = o.toTensor().as2D(t, e);
12492    if (null == n) return s;
12493    if (1 === n.length) return rc(sr(s, 0), [n[0], 1, 1]);
12494    if (2 === n.length) return rc(sr(sr(s, 0), 0), [n[0], n[1], 1, 1]);
12495    if (3 === n.length) return rc(sr(sr(sr(s, 0), 0), 0), [n[0], n[1], n[2], 1, 1]);
12496    throw new Error("eye() currently supports only 1D and 2D batchShapes, but received " + n.length + "D.");
12497  }
12498});
12499exports.eye = oc;
12500var ac = An({
12501  multinomial_: function (t, e, n, r) {
12502    void 0 === r && (r = !1);
12503    var o = mn(t, "logits", "multinomial"),
12504        a = o.size,
12505        i = o.rank;
12506    if (a < 2) throw new Error("Error in multinomial: you need at least 2 outcomes, but got " + a + ".");
12507    if (i > 2) throw new Error("Rank of probabilities must be 1 or 2, but is " + i);
12508    n = n || Math.random();
12509    var s = 1 === i ? o.as2D(1, -1) : o,
12510        u = Lt.runKernelFunc(function (t) {
12511      return t.multinomial(s, r, e, n);
12512    }, {
12513      logits2D: s
12514    });
12515    return 1 === i ? u.as1D() : u;
12516  }
12517});
12518exports.multinomial = ac;
12519var ic = An({
12520  oneHot_: function (t, e, n, r) {
12521    if (void 0 === n && (n = 1), void 0 === r && (r = 0), e < 2) throw new Error("Error in oneHot: depth must be >=2, but it is " + e);
12522    var o = mn(t, "indices", "oneHot", "int32"),
12523        a = o.shape.concat([e]),
12524        i = {
12525      indices: o = o.flatten()
12526    },
12527        s = {
12528      depth: e,
12529      onValue: n,
12530      offValue: r
12531    };
12532    return Lt.runKernelFunc(function (t, a) {
12533      return a([o]), t.oneHot(o, e, n, r);
12534    }, i, null, Sr, s).reshape(a);
12535  }
12536});
12537exports.oneHot = ic;
12538var sc = An({
12539  rand_: function (t, e, n) {
12540    var r = k(t),
12541        o = null;
12542    if (null == n || "float32" === n) o = new Float32Array(r);else if ("int32" === n) o = new Int32Array(r);else {
12543      if ("bool" !== n) throw new Error("Unknown data type " + n);
12544      o = new Uint8Array(r);
12545    }
12546
12547    for (var a = 0; a < r; a++) o[a] = e();
12548
12549    return Lt.makeTensor(o, t, n);
12550  }
12551}),
12552    uc = .001,
12553    cc = .1;
12554exports.rand = sc;
12555
12556function lc() {
12557  return 32 === Lt.backend.floatPrecision() ? uc : cc;
12558}
12559
12560function hc(t, e, n) {
12561  var r = !0;
12562
12563  if ((V(t) || V(e)) && (r = !1), V(t) && V(e) && (r = !0), r) {
12564    var o = t.constructor.name,
12565        a = e.constructor.name;
12566    if (o !== a) throw new Error("Arrays are of different type. Actual: " + o + ". Expected: " + a);
12567  }
12568
12569  if (Array.isArray(t) && Array.isArray(e)) {
12570    var i = pn(t),
12571        s = pn(e);
12572    if (!S(i, s)) throw new Error("Arrays have different shapes. Actual: [" + i + "]. Expected: [" + s + "]");
12573  }
12574
12575  var u = V(t) ? t : I(t),
12576      c = V(e) ? e : I(e);
12577  if (u.length !== c.length) throw new Error("Arrays have different lengths actual: " + u.length + " vs expected: " + c.length + ".\nActual:   " + u + ".\nExpected: " + c + ".");
12578
12579  for (var l = 0; l < c.length; ++l) {
12580    var h = u[l],
12581        f = c[l];
12582    if (!n(h, f)) throw new Error("Arrays differ: actual[" + l + "] = " + h + ", expected[" + l + "] = " + f + ".\nActual:   " + u + ".\nExpected: " + c + ".");
12583  }
12584}
12585
12586function fc(t, e, n) {
12587  return !isFinite(t) && !isFinite(e) || !(isNaN(t) || isNaN(e) || Math.abs(t - e) > n);
12588}
12589
12590var dc = Object.freeze({
12591  TEST_EPSILON_FLOAT16: cc,
12592  expectArraysClose: function (t, e, n) {
12593    return null == n && (n = lc()), hc(t, e, function (t, e) {
12594      return fc(t, e, n);
12595    });
12596  },
12597  testEpsilon: lc,
12598  expectPromiseToFail: function (t, e) {
12599    t().then(function () {
12600      return e.fail();
12601    }, function () {
12602      return e();
12603    });
12604  },
12605  expectArraysEqual: function (t, e) {
12606    var n = "string" == typeof e || "number" == typeof e || "boolean" == typeof e ? [e] : e;
12607    return H(t) || H(t[0]) || H(e) || H(e[0]) ? hc(t, n, function (t, e) {
12608      return t == e;
12609    }) : hc(t, e, function (t, e) {
12610      return fc(t, e, 0);
12611    });
12612  },
12613  expectNumbersClose: function (t, e, n) {
12614    if (null == n && (n = lc()), !fc(t, e, n)) throw new Error("Numbers differ: actual === " + t + ", expected === " + e);
12615  },
12616  expectValuesInRange: function (t, e, n) {
12617    for (var r = 0; r < t.length; r++) if (t[r] < e || t[r] > n) throw new Error("Value out of range:" + t[r] + " low: " + e + ", high: " + n);
12618  },
12619  expectArrayBuffersEqual: function (t, e) {
12620    expect(new Float32Array(t)).toEqual(new Float32Array(e));
12621  }
12622}),
12623    pc = function () {
12624  function t(t, e, n, r, o) {
12625    this.mean = t, this.stdDev = e, this.dtype = n, this.nextVal = NaN, this.truncated = r, this.truncated && (this.upper = this.mean + 2 * this.stdDev, this.lower = this.mean - 2 * this.stdDev);
12626    var a = o || Math.random();
12627    this.random = ju(a.toString());
12628  }
12629
12630  return t.prototype.nextValue = function () {
12631    if (!isNaN(this.nextVal)) {
12632      var t = this.nextVal;
12633      return this.nextVal = NaN, t;
12634    }
12635
12636    for (var e, n, r = !1; !r;) {
12637      var o = void 0,
12638          a = void 0,
12639          i = void 0;
12640
12641      do {
12642        i = (o = 2 * this.random() - 1) * o + (a = 2 * this.random() - 1) * a;
12643      } while (i >= 1 || 0 === i);
12644
12645      var s = Math.sqrt(-2 * Math.log(i) / i);
12646      e = this.mean + this.stdDev * o * s, n = this.mean + this.stdDev * a * s, this.truncated && !this.isValidTruncated(e) || (r = !0);
12647    }
12648
12649    return this.truncated && !this.isValidTruncated(n) || (this.nextVal = this.convertValue(n)), this.convertValue(e);
12650  }, t.prototype.convertValue = function (t) {
12651    return null == this.dtype || "float32" === this.dtype ? t : Math.round(t);
12652  }, t.prototype.isValidTruncated = function (t) {
12653    return t <= this.upper && t >= this.lower;
12654  }, t;
12655}(),
12656    vc = function () {
12657  function t(t, e, n, r) {
12658    this.alpha = t, this.beta = 1 / e, this.dtype = n;
12659    var o = r || Math.random();
12660    this.randu = ju(o.toString()), this.randn = new pc(0, 1, n, !1, this.randu()), this.d = t < 1 ? t + 2 / 3 : t - 1 / 3, this.c = 1 / Math.sqrt(9 * this.d);
12661  }
12662
12663  return t.prototype.nextValue = function () {
12664    for (var t, e, n, r, o, a;;) {
12665      do {
12666        r = this.randn.nextValue(), a = 1 + this.c * r;
12667      } while (a <= 0);
12668
12669      if (a *= a * a, e = 1 - .331 * (t = r * r) * t, n = .5 * t + this.d * (1 - a + Math.log(a)), (o = this.randu()) < e || Math.log(o) < n) break;
12670    }
12671
12672    return a = 1 / this.beta * this.d * a, this.alpha < 1 && (a *= Math.pow(this.randu(), 1 / this.alpha)), this.convertValue(a);
12673  }, t.prototype.convertValue = function (t) {
12674    return "float32" === this.dtype ? t : Math.round(t);
12675  }, t;
12676}(),
12677    mc = function () {
12678  function t(t, e, n, r) {
12679    var o = this;
12680    if (void 0 === t && (t = 0), void 0 === e && (e = 1), this.canReturnFloat = function () {
12681      return null == o.dtype || "float32" === o.dtype;
12682    }, this.min = t, this.range = e - t, this.dtype = n, null == r && (r = Math.random()), "number" == typeof r && (r = r.toString()), !this.canReturnFloat() && this.range <= 1) throw new Error("The difference between " + t + " - " + e + " <= 1 and dtype is not float");
12683    this.random = ju(r);
12684  }
12685
12686  return t.prototype.convertValue = function (t) {
12687    return this.canReturnFloat() ? t : Math.round(t);
12688  }, t.prototype.nextValue = function () {
12689    return this.convertValue(this.min + this.range * this.random());
12690  }, t;
12691}();
12692
12693exports.test_util = dc;
12694var gc = An({
12695  randomGamma_: function (t, e, n, r, o) {
12696    if (void 0 === n && (n = 1), void 0 === r && (r = "float32"), null == n && (n = 1), null == r && (r = "float32"), "float32" !== r && "int32" !== r) throw new Error("Unsupported data type " + r);
12697
12698    for (var a = new vc(e, n, r, o), i = er(t, r), s = 0; s < i.values.length; s++) i.values[s] = a.nextValue();
12699
12700    return i.toTensor();
12701  }
12702});
12703exports.randomGamma = gc;
12704var yc = An({
12705  randomNormal_: function (t, e, n, r, o) {
12706    if (void 0 === e && (e = 0), void 0 === n && (n = 1), null != r && "bool" === r) throw new Error("Unsupported data type " + r);
12707
12708    for (var a = new pc(e, n, r, !1, o), i = er(t, r), s = 0; s < i.values.length; s++) i.values[s] = a.nextValue();
12709
12710    return i.toTensor();
12711  }
12712});
12713exports.randomNormal = yc;
12714var xc = An({
12715  randomUniform_: function (t, e, n, r, o) {
12716    void 0 === e && (e = 0), void 0 === n && (n = 1), void 0 === r && (r = "float32");
12717
12718    for (var a = er(t, r), i = new mc(e, n, null, o), s = 0; s < a.values.length; s++) a.values[s] = i.nextValue();
12719
12720    return a.toTensor();
12721  }
12722});
12723exports.randomUniform = xc;
12724var bc = An({
12725  square_: function (t) {
12726    var e = mn(t, "x", "square"),
12727        n = [e];
12728    return Lt.runKernelFunc(function (t, n) {
12729      return n([e]), t.square(e);
12730    }, {
12731      x: e
12732    }, null, "Square", {}, n, []);
12733  }
12734});
12735exports.square = bc;
12736var wc = An({
12737  squaredDifference_: function (t, e) {
12738    var n,
12739        r = mn(t, "a", "squaredDifference"),
12740        o = mn(e, "b", "squaredDifference");
12741    n = Nt(r, o), r = n[0], o = n[1], Fr(r.shape, o.shape);
12742    var a = {
12743      a: r,
12744      b: o
12745    },
12746        i = [r, o];
12747    return Lt.runKernelFunc(function (t, e) {
12748      var n = t.squaredDifference(r, o);
12749      return e([r, o]), n;
12750    }, a, function (t, e) {
12751      var n = e[0],
12752          r = e[1],
12753          o = On(2);
12754      return {
12755        a: function () {
12756          return t.mul(n.sub(r).mul(o));
12757        },
12758        b: function () {
12759          return t.mul(r.sub(n).mul(o));
12760        }
12761      };
12762    }, Ir, {}, i, []);
12763  }
12764});
12765exports.squaredDifference = wc;
12766var Cc = An({
12767  truncatedNormal_: function (t, e, n, r, o) {
12768    if (void 0 === e && (e = 0), void 0 === n && (n = 1), null != r && "bool" === r) throw new Error("Unsupported data type $ { dtype }");
12769
12770    for (var a = new pc(e, n, r, !0, o), i = er(t, r), s = 0; s < i.values.length; s++) i.values[s] = a.nextValue();
12771
12772    return i.toTensor();
12773  }
12774});
12775exports.truncatedNormal = Cc;
12776
12777function Ec(t, e, n, r, o, a) {
12778  var i,
12779      s,
12780      u = mn(t, "x", "batchNorm"),
12781      c = mn(e, "mean", "batchNorm"),
12782      l = mn(n, "variance", "batchNorm");
12783  return null != o && (i = mn(o, "scale", "batchNorm")), null != r && (s = mn(r, "offset", "batchNorm")), C(2 === u.rank, function () {
12784    return "Error in batchNorm3D: x must be rank 3 but got rank " + u.rank + ".";
12785  }), C(2 === c.rank || 1 === c.rank, function () {
12786    return "Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank " + c.rank + ".";
12787  }), C(2 === l.rank || 1 === l.rank, function () {
12788    return "Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank " + l.rank + ".";
12789  }), null != i && C(2 === i.rank || 1 === i.rank, function () {
12790    return "Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank " + i.rank + ".";
12791  }), null != s && C(2 === s.rank || 1 === s.rank, function () {
12792    return "Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank " + s.rank + ".";
12793  }), kc(u, c, l, s, i, a);
12794}
12795
12796function Rc(t, e, n, r, o, a) {
12797  var i,
12798      s,
12799      u = mn(t, "x", "batchNorm"),
12800      c = mn(e, "mean", "batchNorm"),
12801      l = mn(n, "variance", "batchNorm");
12802  return null != o && (i = mn(o, "scale", "batchNorm")), null != r && (s = mn(r, "offset", "batchNorm")), C(3 === u.rank, function () {
12803    return "Error in batchNorm3D: x must be rank 3 but got rank " + u.rank + ".";
12804  }), C(3 === c.rank || 1 === c.rank, function () {
12805    return "Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank " + c.rank + ".";
12806  }), C(3 === l.rank || 1 === l.rank, function () {
12807    return "Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank " + l.rank + ".";
12808  }), null != i && C(3 === i.rank || 1 === i.rank, function () {
12809    return "Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank " + i.rank + ".";
12810  }), null != s && C(3 === s.rank || 1 === s.rank, function () {
12811    return "Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank " + s.rank + ".";
12812  }), kc(u, c, l, s, i, a);
12813}
12814
12815function Ic(t, e, n, r, o, a) {
12816  var i,
12817      s,
12818      u = mn(t, "x", "batchNorm"),
12819      c = mn(e, "mean", "batchNorm"),
12820      l = mn(n, "variance", "batchNorm");
12821  return null != o && (i = mn(o, "scale", "batchNorm")), null != r && (s = mn(r, "offset", "batchNorm")), C(4 === u.rank, function () {
12822    return "Error in batchNorm4D: x must be rank 4 but got rank " + u.rank + ".";
12823  }), C(4 === c.rank || 1 === c.rank, function () {
12824    return "Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank " + c.rank + ".";
12825  }), C(4 === l.rank || 1 === l.rank, function () {
12826    return "Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank " + l.rank + ".";
12827  }), null != i && C(4 === i.rank || 1 === i.rank, function () {
12828    return "Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank " + i.rank + ".";
12829  }), null != s && C(4 === s.rank || 1 === s.rank, function () {
12830    return "Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank " + s.rank + ".";
12831  }), kc(u, c, l, s, i, a);
12832}
12833
12834function kc(t, e, n, r, o, a) {
12835  null == a && (a = .001);
12836  var i,
12837      s,
12838      u,
12839      c = mn(t, "x", "batchNorm"),
12840      l = mn(e, "mean", "batchNorm"),
12841      h = mn(n, "variance", "batchNorm");
12842  null != o && (i = mn(o, "scale", "batchNorm")), null != r && (s = mn(r, "offset", "batchNorm")), C(l.rank === h.rank, function () {
12843    return "Batch normalization gradient requires mean and variance to have equal ranks.";
12844  }), C(null == s || l.rank === s.rank, function () {
12845    return "Batch normalization gradient requires mean and offset to have equal ranks.";
12846  }), C(null == i || l.rank === i.rank, function () {
12847    return "Batch normalization gradient requires mean and scale to have equal ranks.";
12848  }), u = 0 === c.rank || 1 === c.rank ? c.as4D(1, 1, 1, c.size) : 2 === c.rank ? c.as4D(1, 1, c.shape[0], c.shape[1]) : 3 === c.rank ? c.as4D(1, c.shape[0], c.shape[1], c.shape[2]) : c;
12849  var f = [c, l, h, i];
12850  return Lt.runKernelFunc(function (t, e) {
12851    var n = t.batchNormalization(u, Sc(l), Sc(h), a, Sc(i), Sc(s));
12852    return e([c, l, h, i]), n;
12853  }, {
12854    x: c,
12855    mean: l,
12856    variance: h,
12857    scale: i,
12858    offset: s
12859  }, function (t, e) {
12860    var n = e,
12861        r = n[0],
12862        o = n[1],
12863        i = n[2],
12864        s = n[3],
12865        c = null == s ? On(1) : s,
12866        l = Nr(o.shape, u.shape),
12867        h = [];
12868
12869    if (1 === o.rank) {
12870      for (var f = 0; f < u.shape.length - 1; ++f) h.push(u.shape[f]);
12871
12872      h.push(1);
12873    }
12874
12875    var d = r.sub(o),
12876        p = t.mul(c),
12877        v = to(i.add(On(a))),
12878        m = v.mul(v).mul(v).mul(On(-.5));
12879    return {
12880      x: function () {
12881        return 1 === o.rank ? t.mul(rc(v.as4D(1, 1, 1, o.shape[0]), h)).mul(c).reshape(r.shape) : t.mul(v).mul(c).reshape(r.shape);
12882      },
12883      mean: function () {
12884        var t = v.mul(On(-1)).mul(p);
12885        return 1 === o.rank && (t = t.sum(l)), t.reshape(o.shape);
12886      },
12887      variance: function () {
12888        var t = m.mul(d).mul(p);
12889        return 1 === o.rank && (t = t.sum(l)), t.reshape(o.shape);
12890      },
12891      scale: function () {
12892        var e = d.mul(v),
12893            n = t.mul(e);
12894        return 1 === o.rank && (n = n.sum(l)), n.reshape(o.shape);
12895      },
12896      offset: function () {
12897        var e = t;
12898        return 1 === o.rank && (e = e.sum(l)), e.reshape(o.shape);
12899      }
12900    };
12901  }, "BatchNormalization", {
12902    varianceEpsilon: a
12903  }, f).reshape(c.shape);
12904}
12905
12906function Sc(t) {
12907  return null == t ? null : 0 === t.rank ? t.as1D() : 1 === t.rank ? t : 2 === t.rank ? t.as4D(1, 1, t.shape[0], t.shape[1]) : 3 === t.rank ? t.as4D(1, t.shape[0], t.shape[1], t.shape[2]) : t;
12908}
12909
12910function Ac() {
12911  Xe("tf.batchNormalization() is going away. Use tf.batchNorm() instead, and note the positional argument change of scale, offset, and varianceEpsilon");
12912}
12913
12914var Tc = An({
12915  batchNormalization2d_: function (t, e, n, r, o, a) {
12916    return void 0 === r && (r = .001), Ac(), Ec(t, e, n, a, o, r);
12917  }
12918}),
12919    Dc = An({
12920  batchNormalization3d_: function (t, e, n, r, o, a) {
12921    return void 0 === r && (r = .001), Ac(), Rc(t, e, n, a, o, r);
12922  }
12923}),
12924    Nc = An({
12925  batchNormalization4d_: function (t, e, n, r, o, a) {
12926    return void 0 === r && (r = .001), Ac(), Ic(t, e, n, a, o, r);
12927  }
12928}),
12929    Fc = An({
12930  batchNormalization_: function (t, e, n, r, o, a) {
12931    return void 0 === r && (r = .001), Ac(), kc(t, e, n, a, o, r);
12932  }
12933}),
12934    _c = An({
12935  batchNorm_: kc
12936}),
12937    Oc = An({
12938  batchNorm2d_: Ec
12939}),
12940    Mc = An({
12941  batchNorm3d_: Rc
12942}
12942),
12943    Bc = An({
12944  batchNorm4d_: Ic
12945});
12946
12947exports.batchNorm4d = Bc;
12948exports.batchNorm3d = Mc;
12949exports.batchNorm2d = Oc;
12950exports.batchNorm = _c;
12951exports.batchNormalization = Fc;
12952exports.batchNormalization4d = Nc;
12953exports.batchNormalization3d = Dc;
12954exports.batchNormalization2d = Tc;
12955var Pc = An({
12956  equal_: function (t, e) {
12957    var n,
12958        r = mn(t, "a", "equal"),
12959        o = mn(e, "b", "equal");
12960    return n = Nt(r, o), r = n[0], o = n[1], Fr(r.shape, o.shape), Lt.runKernelFunc(function (t) {
12961      return t.equal(r, o);
12962    }, {
12963      $a: r,
12964      $b: o
12965    });
12966  }
12967}),
12968    Lc = An({
12969  equalStrict_: function (t, e) {
12970    var n = mn(t, "a", "equalStrict"),
12971        r = mn(e, "b", "equalStrict");
12972    return E(n.shape, r.shape, "Error in equalStrict: "), n.equal(r);
12973  }
12974}),
12975    Wc = An({
12976  greater_: function (t, e) {
12977    var n,
12978        r = mn(t, "a", "greater"),
12979        o = mn(e, "b", "greater");
12980    return n = Nt(r, o), r = n[0], o = n[1], Fr(r.shape, o.shape), Lt.runKernelFunc(function (t) {
12981      return t.greater(r, o);
12982    }, {
12983      a: r,
12984      b: o
12985    }, null, "Greater");
12986  }
12987}),
12988    Uc = An({
12989  greaterEqual_: function (t, e) {
12990    var n,
12991        r = mn(t, "a", "greaterEqual"),
12992        o = mn(e, "b", "greaterEqual");
12993    return n = Nt(r, o), r = n[0], o = n[1], Fr(r.shape, o.shape), Lt.runKernelFunc(function (t, e) {
12994      var n = t.greaterEqual(r, o);
12995      return e([r, o]), n;
12996    }, {
12997      a: r,
12998      b: o
12999    }, function (t, e) {
13000      var n = e[0],
13001          r = e[1];
13002      return {
13003        a: function () {
13004          return Xn(n);
13005        },
13006        b: function () {
13007          return Xn(r);
13008        }
13009      };
13010    }, "GreaterEqual");
13011  }
13012}),
13013    Vc = An({
13014  greaterEqualStrict_: function (t, e) {
13015    var n = mn(t, "a", "greaterEqualStrict"),
13016        r = mn(e, "b", "greaterEqualStrict");
13017    return E(n.shape, r.shape, "Error in greaterEqualStrict: "), n.greaterEqual(r);
13018  }
13019}),
13020    zc = An({
13021  greaterStrict_: function (t, e) {
13022    var n = mn(t, "a", "greaterStrict"),
13023        r = mn(e, "b", "greaterStrict");
13024    return E(n.shape, r.shape, "Error in greaterStrict: "), n.greater(r);
13025  }
13026}),
13027    Gc = An({
13028  less_: function (t, e) {
13029    var n,
13030        r = mn(t, "a", "less"),
13031        o = mn(e, "b", "less");
13032    return n = Nt(r, o), r = n[0], o = n[1], Fr(r.shape, o.shape), Lt.runKernelFunc(function (t) {
13033      return t.less(r, o);
13034    }, {
13035      a: r,
13036      b: o
13037    }, null, "Less");
13038  }
13039}),
13040    Hc = An({
13041  lessEqual_: function (t, e) {
13042    var n,
13043        r = mn(t, "a", "lessEqual"),
13044        o = mn(e, "b", "lessEqual");
13045    return n = Nt(r, o), r = n[0], o = n[1], Fr(r.shape, o.shape), Lt.runKernelFunc(function (t, e) {
13046      var n = t.lessEqual(r, o);
13047      return e([r, o]), n;
13048    }, {
13049      a: r,
13050      b: o
13051    }, null, "LessEqual");
13052  }
13053}),
13054    qc = An({
13055  lessEqualStrict_: function (t, e) {
13056    var n = mn(t, "a", "lessEqualStrict"),
13057        r = mn(e, "b", "lessEqualStrict");
13058    return E(n.shape, r.shape, "Error in lessEqualStrict: "), n.lessEqual(r);
13059  }
13060}),
13061    Kc = An({
13062  lessStrict_: function (t, e) {
13063    var n = mn(t, "a", "lessStrict"),
13064        r = mn(e, "b", "lessStrict");
13065    return E(n.shape, r.shape, "Error in lessStrict: "), n.less(r);
13066  }
13067}),
13068    jc = An({
13069  notEqual_: function (t, e) {
13070    var n,
13071        r = mn(t, "a", "notEqual"),
13072        o = mn(e, "b", "notEqual");
13073    return n = Nt(r, o), r = n[0], o = n[1], Fr(r.shape, o.shape), Lt.runKernelFunc(function (t) {
13074      return t.notEqual(r, o);
13075    }, {
13076      a: r,
13077      b: o
13078    }, null, "NotEqual");
13079  }
13080}),
13081    Xc = An({
13082  notEqualStrict_: function (t, e) {
13083    var n = mn(t, "a", "notEqualStrict"),
13084        r = mn(e, "b", "notEqualStrict");
13085    return E(n.shape, r.shape, "Error in notEqualStrict: "), n.notEqual(r);
13086  }
13087});
13088exports.notEqualStrict = Xc;
13089exports.notEqual = jc;
13090exports.lessStrict = Kc;
13091exports.lessEqualStrict = qc;
13092exports.lessEqual = Hc;
13093exports.less = Gc;
13094exports.greaterStrict = zc;
13095exports.greaterEqualStrict = Vc;
13096exports.greaterEqual = Uc;
13097exports.greater = Wc;
13098exports.equalStrict = Lc;
13099exports.equal = Pc;
13100
13101function Yc(t, e) {
13102  for (var n = [], r = t; r < e; ++r) n.push(r);
13103
13104  return n;
13105}
13106
13107function $c(t) {
13108  for (var e = [], n = 0; n < t.length; ++n) for (var r = 0; r < t[n].length; ++r) e.push(t[n][r]);
13109
13110  return e;
13111}
13112
13113var Qc = An({
13114  gather_: function (t, e, n) {
13115    void 0 === n && (n = 0);
13116    var r = mn(t, "x", "gather"),
13117        o = mn(e, "indices", "gather", "int32");
13118    n = O(n, r.shape)[0];
13119
13120    var a = function (t, e, n) {
13121      for (var r = t.shape[n], o = [], a = 1, i = 1, s = 0; s < n; s++) o.push(t.shape[s]), a *= t.shape[s];
13122
13123      for (s = 0; s < e.rank; s++) o.push(e.shape[s]);
13124
13125      for (s = n + 1; s < t.rank; s++) o.push(t.shape[s]), i *= t.shape[s];
13126
13127      return {
13128        batchSize: a,
13129        sliceSize: i,
13130        dimSize: r,
13131        outputShape: o
13132      };
13133    }(r, o, n);
13134
13135    return Lt.runKernelFunc(function (t, e) {
13136      var a = t.gather(r, o.flatten(), n);
13137      return e([o]), a;
13138    }, {
13139      x: r,
13140      indices: o
13141    }, function (t, e) {
13142      var o = e[0];
13143      return {
13144        x: function () {
13145          var e = r.shape,
13146              a = o.size,
13147              i = e.slice(0, n),
13148              s = i.length,
13149              u = e.slice(n, e.length).slice(1),
13150              c = u.length,
13151              l = Yc(0, s),
13152              h = Yc(s + 1, s + 1 + c),
13153              f = $c([i, [a], u]),
13154              d = t.reshape(f),
13155              p = o.reshape([a]),
13156              v = $c([[s], l, h]),
13157              m = d.transpose(v),
13158              g = Jc(m, p, r.shape[n]),
13159              y = Rn(v);
13160          return g = g.transpose(y);
13161        },
13162        indices: function () {
13163          return o;
13164        }
13165      };
13166    }, "Gather", {
13167      axis: n
13168    }).reshape(a.outputShape);
13169  }
13170}),
13171    Jc = An({
13172  unsortedSegmentSum_: function (t, e, n) {
13173    var r = mn(t, "x", "unsortedSegmentSum"),
13174        o = mn(e, "segmentIds", "unsortedSegmentSum", "int32");
13175    return C(A(n), function () {
13176      return "numSegments must be of dtype int";
13177    }), Lt.runKernelFunc(function (t, e) {
13178      var a = t.unsortedSegmentSum(r, o, n);
13179      return e([o]), a;
13180    }, {
13181      $x: r
13182    }, function (t, e) {
13183      var n = e[0];
13184      return {
13185        $x: function () {
13186          return function (t, e) {
13187            for (var n = bo(e, Xn(e)), r = Qc(t, n), o = Uc(e, On(0, "int32")), a = r.rank - o.rank, i = 0; i < a; ++i) o = sr(o, i + 1);
13188
13189            o = $u(o, zn(r.shape, "bool"));
13190            var s = Xn(r);
13191            return tc(o, r, s);
13192          }(t, n);
13193        }
13194      };
13195    });
13196  }
13197});
13198exports.unsortedSegmentSum = Jc;
13199exports.gather = Qc;
13200
13201var Zc = function (t, e, o) {
13202  return n(this, void 0, void 0, function () {
13203    var n, a, i, s, u, c, l, h, f, d, p, v, m;
13204    return r(this, function (r) {
13205      switch (r.label) {
13206        case 0:
13207          for (n = mn(t, "tensor", "boolMask"), a = mn(e, "mask", "boolMask", "bool"), i = null == o ? 0 : o, s = a.rank, u = n.shape, C(s > 0, function () {
13208            return "mask cannot be scalar";
13209          }), E(u.slice(i, i + s), a.shape, "mask's shape must match the first K dimensions of tensor's shape,"), c = 1, l = i; l < i + s; l++) c *= u[l];
13210
13211          return h = u.slice(0, i).concat([c], u.slice(i + s)), f = n.reshape(h), d = a.reshape([-1]), [4, ec(d)];
13212
13213        case 1:
13214          return p = r.sent(), v = p.squeeze([1]), m = Qc(f, v, i), t !== n && n.dispose(), e !== a && a.dispose(), v.dispose(), f.dispose(), d.dispose(), p.dispose(), [2, m];
13215      }
13216    });
13217  });
13218};
13219
13220exports.booleanMaskAsync = Zc;
13221
13222function tl(t, e, n, r, o, a, i) {
13223  void 0 === a && (a = "NHWC"), C(t.length === e.rank, function () {
13224    return "Length of inShape (" + t.length + ") and rank of dy (" + e.rank + ") must match";
13225  });
13226  var s = t,
13227      u = e,
13228      c = !1;
13229  3 === e.rank && (c = !0, u = e.as4D(1, e.shape[0], e.shape[1], e.shape[2]), s = [1, t[0], t[1], t[2]]), C(4 === s.length, function () {
13230    return "Error in conv2dDerInput: inShape must be length 4, but got length " + s.length + ".";
13231  }), C(4 === u.rank, function () {
13232    return "Error in conv2dDerInput: dy must be rank 4, but got rank " + u.rank;
13233  }), C(4 === n.rank, function () {
13234    return "Error in conv2dDerInput: filter must be rank 4, but got rank " + n.rank;
13235  });
13236  var l = "NHWC" === a ? s[3] : s[1],
13237      h = "NHWC" === a ? u.shape[3] : u.shape[1];
13238  C(l === n.shape[2], function () {
13239    return "Error in conv2dDerInput: depth of input (" + l + ") must match input depth for filter " + n.shape[2] + ".";
13240  }), C(h === n.shape[3], function () {
13241    return "Error in conv2dDerInput: depth of output (" + h + ") must match output depth for filter " + n.shape[3] + ".";
13242  }), null != i && C(A(o), function () {
13243    return "Error in conv2dDerInput: pad must be an integer when using, dimRoundingMode " + i + " but got pad " + o + ".";
13244  });
13245  var f = xa(a),
13246      d = la(s, n.shape, r, 1, o, i, !1, f),
13247      p = Lt.runKernelFunc(function (t, e) {
13248    var r = t.conv2dDerInput(u, n, d);
13249    return e([n, u]), r;
13250  }, {
13251    dy4D: u,
13252    filter: n
13253  }, function (t, e) {
13254    var n = e[0],
13255        s = e[1];
13256    return {
13257      dy4D: function () {
13258        return ol(t, n, r, o, a, 1, i);
13259      },
13260      filter: function () {
13261        return il(t, s, n.shape, r, o, a, i);
13262      }
13263    };
13264  });
13265  return c ? p.as3D(p.shape[1], p.shape[2], p.shape[3]) : p;
13266}
13267
13268function el(t) {
13269  var e = function (t) {
13270    return "number" == typeof t ? [t, t, t] : 2 === t.length ? [t[0], t[1], 1] : t;
13271  }(t),
13272      n = e[0],
13273      r = e[1],
13274      o = e[2];
13275
13276  return 1 === n && 1 === r && 1 === o;
13277}
13278
13279function nl(t, e, n, r, o) {
13280  C(t.length === e.rank, function () {
13281    return "Length of inShape (" + t.length + ") and rank of dy (" + e.rank + ") must match";
13282  });
13283  var a = t,
13284      i = e,
13285      s = !1;
13286  4 === e.rank && (s = !0, i = e.as5D(1, e.shape[0], e.shape[1], e.shape[2], e.shape[3]), a = [1, t[0], t[1], t[2], t[3]]);
13287  var u = a[4],
13288      c = i.shape[4];
13289  C(5 === a.length, function () {
13290    return "Error in conv3dDerInput: inShape must be length 5, but got length " + a.length + ".";
13291  }), C(5 === i.rank, function () {
13292    return "Error in conv3dDerInput: dy must be rank 5, but got rank " + i.rank;
13293  }), C(5 === n.rank, function () {
13294    return "Error in conv3dDerInput: filter must be rank 5, but got rank " + n.rank;
13295  }), C(u === n.shape[3], function () {
13296    return "Error in conv3dDerInput: depth of input (" + u + ") must match input depth for filter " + n.shape[3] + ".";
13297  }), C(c === n.shape[4], function () {
13298    return "Error in conv3dDerInput: depth of output (" + c + ") must match output depth for filter " + n.shape[4] + ".";
13299  });
13300  var l = ha(a, n.shape, r, 1, o),
13301      h = Lt.runKernelFunc(function (t) {
13302    return t.conv3dDerInput(i, n, l);
13303  }, {
13304    dy5D: i
13305  });
13306  return s ? h.as4D(h.shape[1], h.shape[2], h.shape[3], h.shape[4]) : h;
13307}
13308
13309var rl = An({
13310  conv1d_: function (t, e, n, r, o, a, i) {
13311    void 0 === o && (o = "NWC"), void 0 === a && (a = 1);
13312    var s = mn(t, "x", "conv1d"),
13313        u = mn(e, "filter", "conv1d"),
13314        c = s,
13315        l = !1;
13316    2 === s.rank && (l = !0, c = s.as3D(1, s.shape[0], s.shape[1])), C(3 === c.rank, function () {
13317      return "Error in conv1d: input must be rank 3, but got rank " + c.rank + ".";
13318    }), C(3 === u.rank, function () {
13319      return "Error in conv1d: filter must be rank 3, but got rank " + u.rank + ".";
13320    }), null != i && C(A(r), function () {
13321      return "Error in conv1d: pad must be an integer when using, dimRoundingMode " + i + " but got pad " + r + ".";
13322    }), C(c.shape[2] === u.shape[1], function () {
13323      return "Error in conv1d: depth of input (" + c.shape[2] + ") must match input depth for filter " + u.shape[1] + ".";
13324    }), C(ya(n, a), function () {
13325      return "Error in conv1D: Either stride or dilation must be 1. Got stride " + n + " and dilation '" + a + "'";
13326    }), C("NWC" === o, function () {
13327      return "Error in conv1d: got dataFormat of " + o + " but only NWC is currently supported.";
13328    });
13329    var h = u.as4D(1, u.shape[0], u.shape[1], u.shape[2]),
13330        f = c.as4D(c.shape[0], 1, c.shape[1], c.shape[2]),
13331        d = ol(f, h, [1, n], r, "NHWC", [1, a], i);
13332    return l ? d.as2D(d.shape[2], d.shape[3]) : d.as3D(d.shape[0], d.shape[2], d.shape[3]);
13333  }
13334}),
13335    ol = An({
13336  conv2d_: function (t, e, n, r, o, a, i) {
13337    void 0 === o && (o = "NHWC"), void 0 === a && (a = [1, 1]);
13338    var s = mn(t, "x", "conv2d"),
13339        u = mn(e, "filter", "conv2d"),
13340        c = s,
13341        l = !1;
13342    3 === s.rank && (l = !0, c = s.as4D(1, s.shape[0], s.shape[1], s.shape[2])), C(4 === c.rank, function () {
13343      return "Error in conv2d: input must be rank 4, but got rank " + c.rank + ".";
13344    }), C(4 === u.rank, function () {
13345      return "Error in conv2d: filter must be rank 4, but got rank " + u.rank + ".";
13346    }), null != i && C(A(r), function () {
13347      return "Error in conv2d: pad must be an integer when using, dimRoundingMode " + i + " but got pad " + r + ".";
13348    });
13349    var h = "NHWC" === o ? c.shape[3] : c.shape[1];
13350    C(h === u.shape[2], function () {
13351      return "Error in conv2d: depth of input (" + h + ") must match input depth for filter " + u.shape[2] + ".";
13352    }), C(ya(n, a), function () {
13353      return "Error in conv2D: Either strides or dilations must be 1. Got strides " + n + " and dilations '" + a + "'";
13354    });
13355    var f = xa(o),
13356        d = la(c.shape, u.shape, n, a, r, i, !1, f),
13357        p = [u, c],
13358        v = Lt.runKernelFunc(function (t, e) {
13359      var n = t.conv2d(c, u, d);
13360      return e([u, c]), n;
13361    }, {
13362      x: c,
13363      filter: u
13364    }, function (t, e) {
13365      var i = e,
13366          s = i[0],
13367          u = i[1];
13368      return C(ga(a), function () {
13369        return "Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '" + a + "'";
13370      }), {
13371        x: function () {
13372          return sl(u.shape, t, s, n, r, o);
13373        },
13374        filter: function () {
13375          return il(u, t, s.shape, n, r, o);
13376        }
13377      };
13378    }, "Conv2D", d, p);
13379    return l ? v.as3D(v.shape[1], v.shape[2], v.shape[3]) : v;
13380  }
13381}),
13382    al = An({
13383  conv3d_: function (t, e, n, r, o, a) {
13384    void 0 === o && (o = "NDHWC"), void 0 === a && (a = [1, 1, 1]);
13385    var i = mn(t, "x", "conv3d"),
13386        s = mn(e, "filter", "conv3d"),
13387        u = i,
13388        c = !1;
13389    4 === i.rank && (c = !0, u = i.as5D(1, i.shape[0], i.shape[1], i.shape[2], i.shape[3])), C(5 === u.rank, function () {
13390      return "Error in conv3d: input must be rank 5, but got rank " + u.rank + ".";
13391    }), C(5 === s.rank, function () {
13392      return "Error in conv3d: filter must be rank 5, but got rank " + s.rank + ".";
13393    }), C(u.shape[4] === s.shape[3], function () {
13394      return "Error in conv3d: depth of input (" + u.shape[4] + ") must match input depth for filter " + s.shape[3] + ".";
13395    }), C(function (t, e) {
13396      return el(t) || el(e);
13397    }(n, a), function () {
13398      return "Error in conv3D: Either strides or dilations must be 1. Got strides " + n + " and dilations '" + a + "'";
13399    }), C("NDHWC" === o, function () {
13400      return "Error in conv3d: got dataFormat of " + o + " but only NDHWC is currently supported.";
13401    });
13402    var l = ha(u.shape, s.shape, n, a, r),
13403        h = Lt.runKernelFunc(function (t, e) {
13404      var n = t.conv3d(u, s, l);
13405      return e([u, s]), n;
13406    }, {
13407      x: u,
13408      $filter: s
13409    }, function (t, e) {
13410      C(el(a), function () {
13411        return "Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '" + a + "'";
13412      });
13413      var o = e[0],
13414          i = e[1];
13415      return {
13416        x: function () {
13417          return nl(o.shape, t, i, n, r);
13418        },
13419        $filter: function () {
13420          return function (t, e, n, r, o) {
13421            var a = t;
13422            4 === t.rank && (a = t.as5D(1, t.shape[0], t.shape[1], t.shape[2], t.shape[3]));
13423            var i = e;
13424            4 === i.rank && (i = e.as5D(1, e.shape[0], e.shape[1], e.shape[2], e.shape[3]));
13425            C(5 === a.rank, function () {
13426              return "Error in conv3dDerFilter: input must be rank 5, but got shape " + a.shape + ".";
13427            }), C(5 === i.rank, function () {
13428              return "Error in conv3dDerFilter: dy must be rank 5, but got shape " + i.shape + ".";
13429            }), C(5 === n.length, function () {
13430              return "Error in conv3dDerFilter: filterShape must be length 5, but got " + n + ".";
13431            }), C(a.shape[4] === n[3], function () {
13432              return "Error in conv3dDerFilter: depth of input " + a.shape[4] + ") must match input depth in filter (" + n[3] + ".";
13433            }), C(i.shape[4] === n[4], function () {
13434              return "Error in conv3dDerFilter: depth of dy (" + i.shape[4] + ") must match output depth for filter (" + n[4] + ").";
13435            });
13436            var s = ha(a.shape, n, r, 1, o);
13437            return Lt.runKernelFunc(function (t) {
13438              return t.conv3dDerFilter(a, i, s);
13439            }, {
13440              x5D: a,
13441              dy5D: i
13442            });
13443          }(o, t, i.shape, n, r);
13444        }
13445      };
13446    });
13447    return c ? h.as4D(h.shape[1], h.shape[2], h.shape[3], h.shape[4]) : h;
13448  }
13449}),
13450    il = An({
13451  conv2dDerFilter_: function (t, e, n, r, o, a, i) {
13452    void 0 === a && (a = "NHWC");
13453    var s = t;
13454    3 === t.rank && (s = t.as4D(1, t.shape[0], t.shape[1], t.shape[2]));
13455    var u = e;
13456    3 === u.rank && (u = e.as4D(1, e.shape[0], e.shape[1], e.shape[2])), C(4 === s.rank, function () {
13457      return "Error in conv2dDerFilter: input must be rank 4, but got shape " + s.shape + ".";
13458    }), C(4 === u.rank, function () {
13459      return "Error in conv2dDerFilter: dy must be rank 4, but got shape " + u.shape + ".";
13460    }), C(4 === n.length, function () {
13461      return "Error in conv2dDerFilter: filterShape must be length 4, but got " + n + ".";
13462    });
13463    var c = "NHWC" === a ? s.shape[3] : s.shape[1],
13464        l = "NHWC" === a ? u.shape[3] : u.shape[1];
13465    C(c === n[2], function () {
13466      return "Error in conv2dDerFilter: depth of input " + c + ") must match input depth in filter (" + n[2] + ".";
13467    }), C(l === n[3], function () {
13468      return "Error in conv2dDerFilter: depth of dy (" + l + ") must match output depth for filter (" + n[3] + ").";
13469    }), null != i && C(A(o), function () {
13470      return "Error in conv2dDerFilter: pad must be an integer when using, dimRoundingMode " + i + " but got pad " + o + ".";
13471    });
13472    var h = xa(a),
13473        f = la(s.shape, n, r, 1, o, i, !1, h);
13474    return Lt.runKernelFunc(function (t) {
13475      return t.conv2dDerFilter(s, u, f);
13476    }, {
13477      x4D: s,
13478      dy4D: u
13479    });
13480  }
13481}),
13482    sl = An({
13483  conv2dDerInput_: tl
13484}),
13485    ul = An({
13486  depthwiseConv2d_: function (t, e, n, r, o, a, i) {
13487    void 0 === o && (o = "NHWC"), void 0 === a && (a = [1, 1]);
13488    var s = mn(t, "x", "depthwiseConv2d"),
13489        u = mn(e, "filter", "depthwiseConv2d"),
13490        c = s,
13491        l = !1;
13492    3 === s.rank && (l = !0, c = s.as4D(1, s.shape[0], s.shape[1], s.shape[2])), C(4 === c.rank, function () {
13493      return "Error in depthwiseConv2d: input must be rank 4, but got rank " + c.rank + ".";
13494    }), C(4 === u.rank, function () {
13495      return "Error in depthwiseConv2d: filter must be rank 4, but got rank " + u.rank + ".";
13496    }), C(c.shape[3] === u.shape[2], function () {
13497      return "Error in depthwiseConv2d: number of input channels (" + c.shape[3] + ") must match the inChannels dimension in filter " + u.shape[2] + ".";
13498    }), null == a && (a = [1, 1]), C(ya(n, a), function () {
13499      return "Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides " + n + " and dilations '" + a + "'";
13500    }), null != i && C(A(r), function () {
13501      return "Error in depthwiseConv2d: pad must be an integer when using, dimRoundingMode " + i + " but got pad " + r + ".";
13502    });
13503    var h = la(c.shape, u.shape, n, a, r, i, !0),
13504        f = [c, u],
13505        d = Lt.runKernelFunc(function (t, e) {
13506      var n = t.depthwiseConv2D(c, u, h);
13507      return e([c, u]), n;
13508    }, {
13509      x: c,
13510      filter: u
13511    }, function (t, e) {
13512      C(ga(a), function () {
13513        return "Error in gradient of depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '" + a + "'";
13514      });
13515      var n = e[0],
13516          r = e[1];
13517      return {
13518        x: function () {
13519          return cl(n.shape, t, r, h);
13520        },
13521        filter: function () {
13522          return ll(n, t, r.shape, h);
13523        }
13524      };
13525    }, "DepthwiseConv2dNative", h, f);
13526    return l ? d.as3D(d.shape[1], d.shape[2], d.shape[3]) : d;
13527  }
13528}),
13529    cl = An({
13530  depthwiseConv2dDerInput_: function (t, e, n, r) {
13531    var o = e,
13532        a = !1;
13533    3 === e.rank && (a = !0, o = e.as4D(1, e.shape[0], e.shape[1], e.shape[2]));
13534    var i = Lt.runKernelFunc(function (t) {
13535      return t.depthwiseConv2DDerInput(o, n, r);
13536    }, {
13537      dy4D: o
13538    });
13539    return a ? i.as3D(i.shape[1], i.shape[2], i.shape[3]) : i;
13540  }
13541}),
13542    ll = An({
13543  depthwiseConv2dDerFilter_: function (t, e, n, r) {
13544    var o = t;
13545    3 === t.rank && (o = t.as4D(1, t.shape[0], t.shape[1], t.shape[2]));
13546    var a = e;
13547    return 3 === a.rank && (a = e.as4D(1, e.shape[0], e.shape[1], e.shape[2])), Lt.runKernelFunc(function (t) {
13548      return t.depthwiseConv2DDerFilter(o, a, r);
13549    }, {
13550      x4D: o,
13551      dy4D: a
13552    });
13553  }
13554}),
13555    hl = An({
13556  separableConv2d_: function (t, e, n, r, o, a, i) {
13557    void 0 === a && (a = [1, 1]), void 0 === i && (i = "NHWC");
13558    var s = mn(t, "x", "separableConv2d"),
13559        u = mn(e, "depthwiseFilter", "separableConv2d"),
13560        c = mn(n, "pointwiseFilter", "separableConv2d"),
13561        l = s,
13562        h = !1;
13563    if (3 === s.rank && (h = !0, l = s.as4D(1, s.shape[0], s.shape[1], s.shape[2])), "NCHW" === i) throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");
13564    C(4 === l.rank, function () {
13565      return "Error in separableConv2d: input must be rank 4, but got rank " + l.rank + ".";
13566    }), C(4 === u.rank, function () {
13567      return "Error in separableConv2d: depthwise filter must be rank 4, but got rank " + u.rank + ".";
13568    }), C(4 === c.rank, function () {
13569      return "Error in separableConv2d: pointwise filter must be rank 4, but got rank " + u.rank + ".";
13570    }), C(1 === c.shape[0], function () {
13571      return "Error in separableConv2d: the first dimension of pointwise filter  must be 1, but got " + c.shape[0] + ".";
13572    }), C(1 === c.shape[1], function () {
13573      return "Error in separableConv2d: the second dimension of pointwise filter must be 1, but got " + c.shape[1] + ".";
13574    });
13575    var f = u.shape[2],
13576        d = u.shape[3];
13577    C(c.shape[2] === f * d, function () {
13578      return "Error in separableConv2d: the third dimension of pointwise filter must be " + f * d + ", but got " + c.shape[2] + ".";
13579    });
13580    var p = ul(l, u, r, o, i, a),
13581        v = ol(p, c, 1, "valid", i);
13582    return h ? v.as3D(v.shape[1], v.shape[2], v.shape[3]) : v;
13583  }
13584}),
13585    fl = An({
13586  conv2dTranspose_: function (t, e, n, r, o, a) {
13587    return tl(n, mn(t, "x", "conv2dTranspose"), mn(e, "filter", "conv2dTranspose"), r, o, "NHWC", a);
13588  }
13589}),
13590    dl = An({
13591  conv3dTranspose_: function (t, e, n, r, o) {
13592    return nl(n, mn(t, "x", "conv3dTranspose"), mn(e, "filter", "conv3dTranspose"), r, o);
13593  }
13594});
13595exports.conv3dTranspose = dl;
13596exports.conv2dTranspose = fl;
13597exports.separableConv2d = hl;
13598exports.depthwiseConv2d = ul;
13599exports.conv3d = al;
13600exports.conv2d = ol;
13601exports.conv1d = rl;
13602var pl = An({
13603  matMul_: function (t, e, n, r) {
13604    var o;
13605    void 0 === n && (n = !1), void 0 === r && (r = !1);
13606    var a = mn(t, "a", "matMul"),
13607        i = mn(e, "b", "matMul");
13608    o = Nt(a, i), a = o[0], i = o[1];
13609    var s = n ? a.shape[a.rank - 2] : a.shape[a.rank - 1],
13610        u = r ? i.shape[i.rank - 1] : i.shape[i.rank - 2],
13611        c = n ? a.shape[a.rank - 1] : a.shape[a.rank - 2],
13612        l = r ? i.shape[i.rank - 2] : i.shape[i.rank - 1],
13613        h = a.shape.slice(0, -2),
13614        f = i.shape.slice(0, -2),
13615        d = k(h),
13616        p = k(f);
13617    C(a.rank >= 2 && i.rank >= 2 && a.rank === i.rank, function () {
13618      return "Error in matMul: inputs must have the same rank of at least 2, got ranks " + a.rank + " and " + i.rank + ".";
13619    }), C(S(h, f), function () {
13620      return "Error in matMul: outer dimensions (" + h + ") and (" + f + ") of Tensors with shapes " + a.shape + " and " + i.shape + " must match.";
13621    }), C(s === u, function () {
13622      return "Error in matMul: inner shapes (" + s + ") and (" + u + ") of Tensors with shapes " + a.shape + " and " + i.shape + " and transposeA=" + n + " and transposeB=" + r + " must match.";
13623    });
13624    var v = a.shape.slice(0, -2).concat([c, l]),
13625        m = n ? a.as3D(d, s, c) : a.as3D(d, c, s),
13626        g = r ? i.as3D(p, l, u) : i.as3D(p, u, l),
13627        y = {
13628      transposeA: n,
13629      transposeB: r
13630    };
13631    return Lt.runKernelFunc(function (t, e) {
13632      var o = t.batchMatMul(m, g, n, r);
13633      return e([m, g]), o;
13634    }, {
13635      a: m,
13636      b: g
13637    }, function (t, e) {
13638      var o = e,
13639          a = o[0],
13640          i = o[1];
13641      return n || r ? !n && r ? {
13642        a: function () {
13643          return t.matMul(i, !1, !1);
13644        },
13645        b: function () {
13646          return t.matMul(a, !0, !1);
13647        }
13648      } : n && !r ? {
13649        a: function () {
13650          return i.matMul(t, !1, !0);
13651        },
13652        b: function () {
13653          return a.matMul(t, !1, !1);
13654        }
13655      } : {
13656        a: function () {
13657          return i.matMul(t, !0, !0);
13658        },
13659        b: function () {
13660          return t.matMul(a, !0, !0);
13661        }
13662      } : {
13663        a: function () {
13664          return t.matMul(i, !1, !0);
13665        },
13666        b: function () {
13667          return a.matMul(t, !0, !1);
13668        }
13669      };
13670    }, "BatchMatMul", y).reshape(v);
13671  }
13672}),
13673    vl = An({
13674  dot_: function (t, e) {
13675    var n = mn(t, "t1", "dot"),
13676        r = mn(e, "t2", "dot");
13677    C(!(1 !== n.rank && 2 !== n.rank || 1 !== r.rank && 2 !== r.rank), function () {
13678      return "Error in dot: inputs must all be rank 1 or 2, but got ranks " + n.rank + " and " + r.rank + ".";
13679    });
13680    var o = 1 === n.rank ? n.size : n.shape[1],
13681        a = 1 === r.rank ? r.size : r.shape[0];
13682    return C(o === a, function () {
13683      return "Error in dot: inner dimensions of inputs must match, but got " + o + " and " + a + ".";
13684    }), 1 === n.rank && 1 === r.rank ? n.as2D(1, -1).matMul(r.as2D(-1, 1)).asScalar() : 1 === n.rank && 2 === r.rank ? n.as2D(1, -1).matMul(r.as2D(r.shape[0], r.shape[1])).as1D() : 2 === n.rank && 1 === r.rank ? n.matMul(r.as2D(-1, 1)).as1D() : n.matMul(r.as2D(r.shape[0], r.shape[1]));
13685  }
13686}),
13687    ml = An({
13688  outerProduct_: function (t, e) {
13689    var n = mn(t, "v1", "outerProduct"),
13690        r = mn(e, "v2", "outerProduct");
13691    return C(1 === n.rank && 1 === r.rank, function () {
13692      return "Error in outerProduct: inputs must be rank 1, but got ranks " + n.rank + " and " + r.rank + ".";
13693    }), n.as2D(-1, 1).matMul(r.as2D(1, -1));
13694  }
13695});
13696exports.outerProduct = ml;
13697exports.dot = vl;
13698exports.matMul = pl;
13699var gl = An({
13700  reverse_: function (t, e) {
13701    var n = mn(t, "x", "reverse");
13702    if (0 === n.rank) return n.clone();
13703    var r = O(e, n.shape);
13704    return Lt.runKernelFunc(function (t) {
13705      return t.reverse(n, r);
13706    }, {
13707      $x: n
13708    }, function (t) {
13709      return {
13710        $x: function () {
13711          return t.reverse(r);
13712        }
13713      };
13714    }).reshapeAs(n);
13715  }
13716}),
13717    yl = An({
13718  reverse1d_: function (t) {
13719    var e = mn(t, "x", "reverse");
13720    return C(1 === e.rank, function () {
13721      return "Error in reverse1D: x must be rank 1 but got rank " + e.rank + ".";
13722    }), gl(e, 0);
13723  }
13724}),
13725    xl = An({
13726  reverse2d_: function (t, e) {
13727    var n = mn(t, "x", "reverse");
13728    return C(2 === n.rank, function () {
13729      return "Error in reverse2D: x must be rank 2 but got rank " + n.rank + ".";
13730    }), gl(n, e);
13731  }
13732}),
13733    bl = An({
13734  reverse3d_: function (t, e) {
13735    var n = mn(t, "x", "reverse");
13736    return C(3 === n.rank, function () {
13737      return "Error in reverse3D: x must be rank 3 but got rank " + n.rank + ".";
13738    }), gl(n, e);
13739  }
13740}),
13741    wl = An({
13742  reverse4d_: function (t, e) {
13743    var n = mn(t, "x", "reverse");
13744    return C(4 === n.rank, function () {
13745      return "Error in reverse4D: x must be rank 4 but got rank " + n.rank + ".";
13746    }), gl(n, e);
13747  }
13748});
13749exports.reverse4d = wl;
13750exports.reverse3d = bl;
13751exports.reverse2d = xl;
13752exports.reverse1d = yl;
13753exports.reverse = gl;
13754
13755function Cl(t, e, n, r, o, a) {
13756  var i = mn(t, "x", "maxPool"),
13757      s = i,
13758      u = !1;
13759  3 === i.rank && (u = !0, s = i.as4D(1, i.shape[0], i.shape[1], i.shape[2])), null == r && (r = [1, 1]), C(4 === s.rank, function () {
13760    return "Error in maxPool: input must be rank 4 but got rank " + s.rank + ".";
13761  }), C(ya(n, r), function () {
13762    return "Error in maxPool: Either strides or dilations must be 1. Got strides " + n + " and dilations '" + r + "'";
13763  }), null != a && C(A(o), function () {
13764    return "Error in maxPool: pad must be an integer when using, dimRoundingMode " + a + " but got pad " + o + ".";
13765  });
13766  var c = ua(s.shape, e, n, r, o, a);
13767  if (1 === c.filterWidth && 1 === c.filterHeight && S(c.inShape, c.outShape)) return i.clone();
13768  var l = [s],
13769      h = Lt.runKernelFunc(function (t, e) {
13770    var n = t.maxPool(s, c);
13771    return e([s, n]), n;
13772  }, {
13773    x: s
13774  }, function (t, a) {
13775    var i = a[0],
13776        s = a[1];
13777    return {
13778      x: function () {
13779        return function (t, e, n, r, o, a, i, s) {
13780          var u = mn(t, "dy", "maxPoolBackprop"),
13781              c = mn(e, "input", "maxPoolBackprop"),
13782              l = mn(n, "output", "maxPoolBackprop");
13783          C(c.rank === u.rank, function () {
13784            return "Rank of input (" + c.rank + ") does not match rank of dy (" + u.rank + ")";
13785          }), null == a && (a = [1, 1]);
13786          C(ya(o, a), function () {
13787            return "Error in maxPoolBackProp: Either strides or dilations must be 1. Got strides " + o + " and dilations '" + a + "'";
13788          }), C(4 === u.rank, function () {
13789            return "Error in maxPoolBackprop: dy must be rank 4 but got rank " + u.rank + ".";
13790          }), C(4 === c.rank, function () {
13791            return "Error in maxPoolBackprop: input must be rank 4 but got rank " + c.rank + ".";
13792          }), null != s && C(A(i), function () {
13793            return "Error in maxPoolBackprop: pad must be an integer when using, dimRoundingMode " + s + " but got pad " + i + ".";
13794          });
13795          var h = ua(c.shape, r, o, a, i, s);
13796          return Lt.runKernelFunc(function (t) {
13797            return t.maxPoolBackprop(u, c, l, h);
13798          }, {
13799            $dy: u,
13800            $input: c
13801          });
13802        }(t, i, s, e, n, r, o);
13803      }
13804    };
13805  }, "MaxPool", c, l);
13806  return u ? h.as3D(h.shape[1], h.shape[2], h.shape[3]) : h;
13807}
13808
13809function El(t, e, n, r, o, a) {
13810  var i = mn(t, "x", "avgPool", "float32");
13811  null == r && (r = [1, 1]), C(ya(n, r), function () {
13812    return "Error in avgPool: Either strides or dilations must be 1. Got strides " + n + " and dilations '" + r + "'";
13813  });
13814  var s = i,
13815      u = !1;
13816  3 === i.rank && (u = !0, s = i.as4D(1, i.shape[0], i.shape[1], i.shape[2])), C(4 === s.rank, function () {
13817    return "Error in avgPool: x must be rank 4 but got rank " + s.rank + ".";
13818  }), null != a && C(A(o), function () {
13819    return "Error in avgPool: pad must be an integer when using, dimRoundingMode " + a + " but got pad " + o + ".";
13820  });
13821  var c = ua(s.shape, e, n, r, o, a);
13822  if (1 === c.filterWidth && 1 === c.filterHeight && S(c.inShape, c.outShape)) return i.clone();
13823  var l = Lt.runKernelFunc(function (t) {
13824    return t.avgPool(s, c);
13825  }, {
13826    x: s
13827  }, function (t) {
13828    return {
13829      x: function () {
13830        return function (t, e, n, r, o, a) {
13831          var i = mn(t, "dy", "avgPoolBackprop"),
13832              s = mn(e, "input", "avgPoolBackprop");
13833          C(s.rank === i.rank, function () {
13834            return "Rank of input (" + s.rank + ") does not match rank of dy (" + i.rank + ")";
13835          }), null == o && (o = [1, 1]);
13836          C(ya(r, o), function () {
13837            return "Error in avgPoolBackprop: Either strides or dilations must be 1. Got strides " + r + " and dilations '" + o + "'";
13838          });
13839          var u = s,
13840              c = i,
13841              l = !1;
13842          3 === s.rank && (l = !0, u = s.as4D(1, s.shape[0], s.shape[1], s.shape[2]), c = i.as4D(1, i.shape[0], i.shape[1], i.shape[2]));
13843          C(4 === c.rank, function () {
13844            return "Error in avgPoolBackprop: dy must be rank 4 but got rank " + c.rank + ".";
13845          }), C(4 === u.rank, function () {
13846            return "Error in avgPoolBackprop: input must be rank 4 but got rank " + u.rank + ".";
13847          });
13848          var h = ua(u.shape, n, r, o, a),
13849              f = Lt.runKernelFunc(function (t) {
13850            return t.avgPoolBackprop(c, u, h);
13851          }, {
13852            dy4D: c,
13853            input4D: u
13854          });
13855          if (l) return f.as3D(f.shape[1], f.shape[2], f.shape[3]);
13856          return f;
13857        }(t, s, e, n, r, o);
13858      }
13859    };
13860  }, "AvgPool", c);
13861  return l = l.cast(i.dtype), u ? l.as3D(l.shape[1], l.shape[2], l.shape[3]) : l;
13862}
13863
13864var Rl = An({
13865  maxPool_: function (t, e, n, r, o) {
13866    return Cl(t, e, n, 1, r, o);
13867  }
13868}),
13869    Il = An({
13870  avgPool_: function (t, e, n, r, o) {
13871    return El(t, e, n, 1, r, o);
13872  }
13873}),
13874    kl = An({
13875  pool_: function (t, e, n, r, o, a) {
13876    null == o && (o = [1, 1]), null == a && (a = 1), 0 === r && (r = "valid");
13877    var i = mn(t, "x", "maxPool"),
13878        s = i,
13879        u = !1;
13880    3 === i.rank && (u = !0, s = i.as4D(1, i.shape[0], i.shape[1], i.shape[2])), C(ya(a, o), function () {
13881      return "Error in pool: Either strides or dilations must be 1. Got strides " + a + " and dilations '" + o + "'";
13882    });
13883    var c,
13884        l = ua(s.shape, e, a, o, r),
13885        h = [l.dilationHeight, l.dilationWidth];
13886    c = "same" === r ? function (t, e) {
13887      var n = t.map(function (t, n) {
13888        return t + (t - 1) * (e[n] - 1);
13889      }).map(function (t) {
13890        return t - 1;
13891      }),
13892          r = n.map(function (t) {
13893        return Math.floor(t / 2);
13894      }),
13895          o = n.map(function (t, e) {
13896        return t - r[e];
13897      });
13898      return n.map(function (t, e) {
13899        return [r[e], o[e]];
13900      });
13901    }([l.filterHeight, l.filterWidth], h) : [[0, 0], [0, 0]];
13902
13903    var f = 1 === h[0] && 1 === h[1],
13904        d = function (t, e, n) {
13905      var r = n.map(function (t) {
13906        return t[0];
13907      }),
13908          o = n.map(function (t) {
13909        return t[1];
13910      }),
13911          a = t.concat(r, o),
13912          i = e.map(function (t, e) {
13913        return (t - a[e] % t) % t;
13914      }),
13915          s = o.map(function (t, e) {
13916        return t + i[e];
13917      }),
13918          u = e.map(function (t, e) {
13919        return [r[e], s[e]];
13920      }),
13921          c = e.map(function (t, e) {
13922        return [0, i[e]];
13923      });
13924      return [u, c];
13925    }([l.inHeight, l.inWidth], h, c),
13926        p = d[0],
13927        v = d[1],
13928        m = f ? r : "valid",
13929        g = f ? s : pr(s, h, p),
13930        y = ("avg" === n ? function () {
13931      return El(g, e, a, 1, m);
13932    } : function () {
13933      return Cl(g, e, a, 1, m);
13934    })(),
13935        x = f ? y : rr(y, h, v);
13936
13937    return u ? x.as3D(x.shape[1], x.shape[2], x.shape[3]) : x;
13938  }
13939}),
13940    Sl = An({
13941  maxPool3d_: function (t, e, n, r, o, a, i) {
13942    void 0 === a && (a = "NDHWC");
13943    var s = mn(t, "x", "maxPool3d"),
13944        u = s,
13945        c = !1;
13946    4 === s.rank && (c = !0, u = s.as5D(1, s.shape[0], s.shape[1], s.shape[2], s.shape[3])), null == i && (i = [1, 1, 1]), C(5 === u.rank, function () {
13947      return "Error in maxPool3d: x must be rank 5 but got rank " + u.rank + ".";
13948    }), C("NDHWC" === a, function () {
13949      return "Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of " + a;
13950    }), C(ya(n, i), function () {
13951      return "Error in maxPool3d: Either strides or dilations must be 1. Got strides " + n + " and dilations '" + i + "'";
13952    }), null != o && C(A(r), function () {
13953      return "Error in maxPool3d: pad must be an integer when using, dimRoundingMode " + o + " but got pad " + r + ".";
13954    });
13955    var l = ca(u.shape, e, n, i, r, o, a),
13956        h = Lt.runKernelFunc(function (t, e) {
13957      var n = t.maxPool3d(u, l);
13958      return e([u, n]), n;
13959    }, {
13960      x: u
13961    }, function (t, a) {
13962      var s = a[0],
13963          u = a[1];
13964      return {
13965        x: function () {
13966          return function (t, e, n, r, o, a, i, s) {
13967            var u = mn(t, "dy", "maxPool3dBackprop"),
13968                c = mn(e, "input", "maxPool3dBackprop"),
13969                l = mn(n, "output", "maxPool3dBackprop"),
13970                h = u,
13971                f = c,
13972                d = l,
13973                p = !1;
13974            4 === c.rank && (p = !0, h = u.as5D(1, u.shape[0], u.shape[1], u.shape[2], u.shape[3]), f = c.as5D(1, c.shape[0], c.shape[1], c.shape[2], c.shape[3]), d = l.as5D(1, l.shape[0], l.shape[1], l.shape[2], l.shape[3]));
13975            C(5 === h.rank, function () {
13976              return "Error in maxPool3dBackprop: dy must be rank 5 but got rank " + h.rank + ".";
13977            }), C(5 === f.rank, function () {
13978              return "Error in maxPool3dBackprop: input must be rank 5 but got rank " + f.rank + ".";
13979            }), C(5 === d.rank, function () {
13980              return "Error in maxPool3dBackprop: output must be rank 5 but got rank " + d.rank + ".";
13981            }), null == a && (a = [1, 1, 1]);
13982            C(ya(o, a), function () {
13983              return "Error in maxPool3dBackprop: Either strides or dilations must be 1. Got strides " + o + " and dilations '" + a + "'";
13984            }), null != s && C(A(i), function () {
13985              return "Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode " + s + " but got pad " + i + ".";
13986            });
13987            var v = ca(f.shape, r, o, a, i, s),
13988                m = Lt.runKernelFunc(function (t) {
13989              return t.maxPool3dBackprop(h, f, d, v);
13990            }, {
13991              dy5D: h,
13992              input5D: f
13993            });
13994            if (p) return m.as4D(m.shape[1], m.shape[2], m.shape[3], m.shape[4]);
13995            return m;
13996          }(t, s, u, e, n, i, r, o);
13997        }
13998      };
13999    });
14000    return c ? h.as4D(h.shape[1], h.shape[2], h.shape[3], h.shape[4]) : h;
14001  }
14002}),
14003    Al = An({
14004  avgPool3d_: function (t, e, n, r, o, a, i) {
14005    void 0 === a && (a = "NDHWC");
14006    var s = mn(t, "x", "avgPool3d", "float32"),
14007        u = s,
14008        c = !1;
14009    4 === s.rank && (c = !0, u = s.as5D(1, s.shape[0], s.shape[1], s.shape[2], s.shape[3])), null == i && (i = [1, 1, 1]), C(5 === u.rank, function () {
14010      return "Error in avgPool3d: x must be rank 5 but got rank " + u.rank + ".";
14011    }), C("NDHWC" === a, function () {
14012      return "Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of " + a;
14013    }), C(ya(n, i), function () {
14014      return "Error in avgPool3d: Either strides or dilations must be 1. Got strides " + n + " and dilations '" + i + "'";
14015    }), null != o && C(A(r), function () {
14016      return "Error in avgPool3d: pad must be an integer when using, dimRoundingMode " + o + " but got pad " + r + ".";
14017    });
14018    var l = ca(u.shape, e, n, i, r, o, a),
14019        h = Lt.runKernelFunc(function (t) {
14020      return t.avgPool3d(u, l);
14021    }, {
14022      x: u
14023    }, function (t) {
14024      return {
14025        x: function () {
14026          return function (t, e, n, r, o, a, i) {
14027            var s = mn(t, "dy", "avgPool3dBackprop"),
14028                u = mn(e, "input", "avgPool3dBackprop"),
14029                c = s,
14030                l = u,
14031                h = !1;
14032            4 === u.rank && (h = !0, c = s.as5D(1, s.shape[0], s.shape[1], s.shape[2], s.shape[3]), l = u.as5D(1, u.shape[0], u.shape[1], u.shape[2], u.shape[3]));
14033            C(5 === c.rank, function () {
14034              return "Error in avgPool3dBackprop: dy must be rank 5 but got rank " + c.rank + ".";
14035            }), C(5 === l.rank, function () {
14036              return "Error in avgPool3dBackprop: input must be rank 5 but got rank " + l.rank + ".";
14037            }), null == o && (o = [1, 1, 1]);
14038            C(ya(r, o), function () {
14039              return "Error in avgPool3dBackprop: Either strides or dilations must be 1. Got strides " + r + " and dilations '" + o + "'";
14040            }), null != i && C(A(a), function () {
14041              return "Error in maxPool3dBackprop: pad must be an integer when using, dimRoundingMode " + i + " but got pad " + a + ".";
14042            });
14043            var f = ca(l.shape, n, r, o, a, i),
14044                d = Lt.runKernelFunc(function (t) {
14045              return t.avgPool3dBackprop(c, l, f);
14046            }, {
14047              dy5D: c,
14048              input5D: l
14049            });
14050            if (h) return d.as4D(d.shape[1], d.shape[2], d.shape[3], d.shape[4]);
14051            return d;
14052          }(t, u, e, n, i, r, o);
14053        }
14054      };
14055    });
14056    return h = h.cast(u.dtype), c ? h.as4D(h.shape[1], h.shape[2], h.shape[3], h.shape[4]) : h;
14057  }
14058});
14059exports.avgPool3d = Al;
14060exports.maxPool3d = Sl;
14061exports.pool = kl;
14062exports.avgPool = Il;
14063exports.maxPool = Rl;
14064
14065var Tl = An({
14066  slice_: function (t, e, n) {
14067    var r,
14068        o,
14069        a = mn(t, "x", "slice");
14070    if (0 === a.rank) throw new Error("Slicing scalar is not possible");
14071    (r = "number" == typeof e ? [e].concat(new Array(a.rank - 1).fill(0)) : e.length < a.rank ? e.concat(new Array(a.rank - e.length).fill(0)) : e.slice()).forEach(function (t) {
14072      C(-1 !== t, function () {
14073        return "slice() does not support negative begin indexing.";
14074      });
14075    }), o = (o = null == n ? new Array(a.rank).fill(-1) : "number" == typeof n ? [n].concat(new Array(a.rank - 1).fill(-1)) : n.length < a.rank ? n.concat(new Array(a.rank - n.length).fill(-1)) : n).map(function (t, e) {
14076      return t >= 0 ? t : (C(-1 === t, function () {
14077        return "Negative size values should be exactly -1 but got " + t + " for the slice() size at index " + e + ".";
14078      }), a.shape[e] - r[e]);
14079    }), zo(a, r, o);
14080    var i = a.shape,
14081        s = {
14082      begin: r,
14083      size: o
14084    };
14085    return Lt.runKernelFunc(function (t) {
14086      return t.slice(a, r, o);
14087    }, {
14088      x: a
14089    }, function (t) {
14090      for (var e = [], n = 0; n < t.rank; n++) e.push([r[n], i[n] - r[n] - o[n]]);
14091
14092      return {
14093        x: function () {
14094          return t.pad(e);
14095        }
14096      };
14097    }, "Slice", s);
14098  }
14099}),
14100    Dl = An({
14101  slice1d_: function (t, e, n) {
14102    var r = mn(t, "x", "slice1d");
14103    return C(1 === r.rank, function () {
14104      return "slice1d expects a rank-1 tensor, but got a rank-" + r.rank + " tensor";
14105    }), Tl(r, [e], [n]);
14106  }
14107}),
14108    Nl = An({
14109  slice2d_: function (t, e, n) {
14110    var r = mn(t, "x", "slice2d");
14111    return C(2 === r.rank, function () {
14112      return "slice2d expects a rank-2 tensor, but got a rank-" + r.rank + " tensor";
14113    }), Tl(r, e, n);
14114  }
14115}),
14116    Fl = An({
14117  slice3d_: function (t, e, n) {
14118    var r = mn(t, "x", "slice3d");
14119    return C(3 === r.rank, function () {
14120      return "slice3d expects a rank-3 tensor, but got a rank-" + r.rank + " tensor";
14121    }), Tl(r, e, n);
14122  }
14123}),
14124    _l = An({
14125  slice4d_: function (t, e, n) {
14126    var r = mn(t, "x", "slice4d");
14127    return C(4 === r.rank, function () {
14128      return "slice4d expects a rank-4 tensor, but got a rank-" + r.rank + " tensor";
14129    }), Tl(r, e, n);
14130  }
14131});
14132
14133exports.slice4d = _l;
14134exports.slice3d = Fl;
14135exports.slice2d = Nl;
14136exports.slice1d = Dl;
14137exports.slice = Tl;
14138
14139function Ol(t, e, n, r, o) {
14140  return e.rank < n.rank && (e = e.reshape(wn(e.shape, r))), t.rank < n.rank && (t = t.reshape(wn(t.shape, r))), {
14141    x: function () {
14142      var r = t.mul(n.equal(e).cast(t.dtype));
14143      return null == o ? r : r.transpose(o);
14144    }
14145  };
14146}
14147
14148var Ml = An({
14149  all_: function (t, e, n) {
14150    void 0 === e && (e = null), void 0 === n && (n = !1);
14151    var r = mn(t, "x", "all", "bool"),
14152        o = O(e, r.shape),
14153        a = o,
14154        i = En(a, r.rank);
14155    null != i && (r = r.transpose(i), a = In(a.length, r.rank));
14156    var s = Lt.runKernelFunc(function (t) {
14157      return t.all(r, a);
14158    }, {
14159      $x: r
14160    });
14161
14162    if (n) {
14163      var u = wn(s.shape, o);
14164      return s.reshape(u);
14165    }
14166
14167    return s;
14168  }
14169}),
14170    Bl = An({
14171  any_: function (t, e, n) {
14172    void 0 === e && (e = null), void 0 === n && (n = !1);
14173    var r = mn(t, "x", "any", "bool"),
14174        o = O(e, r.shape),
14175        a = o,
14176        i = En(a, r.rank);
14177    null != i && (r = r.transpose(i), a = In(a.length, r.rank));
14178    var s = Lt.runKernelFunc(function (t) {
14179      return t.any(r, a);
14180    }, {
14181      $x: r
14182    });
14183
14184    if (n) {
14185      var u = wn(s.shape, o);
14186      return s.reshape(u);
14187    }
14188
14189    return s;
14190  }
14191}),
14192    Pl = An({
14193  argMax_: function (t, e) {
14194    void 0 === e && (e = 0);
14195    var n = mn(t, "x", "argMax");
14196    null == e && (e = 0);
14197    var r = O(e, n.shape),
14198        o = En(r, n.rank);
14199    null != o && (n = n.transpose(o), r = In(r.length, n.rank));
14200    var a = {
14201      axis: r[0]
14202    },
14203        i = [n];
14204    return Lt.runKernelFunc(function (t, e) {
14205      var o = t.argMax(n, r[0]);
14206      return e([n]), o;
14207    }, {
14208      x: n
14209    }, function (t, e) {
14210      var n = e[0];
14211      return {
14212        x: function () {
14213          return Xn(n);
14214        }
14215      };
14216    }, "ArgMax", a, i);
14217  }
14218}),
14219    Ll = An({
14220  argMin_: function (t, e) {
14221    void 0 === e && (e = 0);
14222    var n = mn(t, "x", "argMin");
14223    null == e && (e = 0);
14224    var r = O(e, n.shape),
14225        o = En(r, n.rank);
14226    return null != o && (n = n.transpose(o), r = In(r.length, n.rank)), Lt.runKernelFunc(function (t, e) {
14227      var o = t.argMin(n, r[0]);
14228      return e([n]), o;
14229    }, {
14230      $x: n
14231    }, function (t, e) {
14232      var n = e[0];
14233      return {
14234        $x: function () {
14235          return Xn(n);
14236        }
14237      };
14238    });
14239  }
14240}),
14241    Wl = An({
14242  logSumExp_: function (t, e, n) {
14243    void 0 === e && (e = null), void 0 === n && (n = !1);
14244    var r = mn(t, "x", "logSumExp"),
14245        o = O(e, r.shape),
14246        a = r.max(o, !0),
14247        i = r.sub(a).exp().sum(o).log(),
14248        s = a.reshape(i.shape).add(i);
14249
14250    if (n) {
14251      var u = wn(s.shape, o);
14252      return s.reshape(u);
14253    }
14254
14255    return s;
14256  }
14257}),
14258    Ul = An({
14259  max_: function (t, e, n) {
14260    void 0 === e && (e = null), void 0 === n && (n = !1);
14261    var r = mn(t, "x", "max"),
14262        o = r,
14263        a = O(e, r.shape),
14264        i = a,
14265        s = En(i, r.rank);
14266    null != s && (r = r.transpose(s), i = In(i.length, r.rank));
14267    var u = [r],
14268        c = Lt.runKernelFunc(function (t, e) {
14269      var n = t.max(r, i);
14270      return e([o, n]), n;
14271    }, {
14272      x: r
14273    }, function (t, e) {
14274      return Ol(t, e[1], e[0], a, s);
14275    }, "Max", {
14276      axes: i
14277    }, u, [!0]);
14278
14279    if (n) {
14280      var l = wn(c.shape, a);
14281      c = c.reshape(l);
14282    }
14283
14284    return c;
14285  }
14286}),
14287    Vl = An({
14288  mean_: function (t, e, n) {
14289    void 0 === e && (e = null), void 0 === n && (n = !1);
14290    var r = mn(t, "x", "mean"),
14291        o = O(e, r.shape),
14292        a = k(bn(r.shape, o)[1]);
14293    return ea(function (t) {
14294      var r = On(a);
14295      return {
14296        value: (r.dtype === t.dtype ? t : t.cast(r.dtype)).div(r).sum(e, n),
14297        gradFunc: function (e) {
14298          var n = t.shape.slice();
14299          return o.forEach(function (t) {
14300            n[t] = 1;
14301          }), e.reshape(n).mul(zn(t.shape, "float32")).div(a);
14302        }
14303      };
14304    })(r);
14305  }
14306}),
14307    zl = An({
14308  min_: function (t, e, n) {
14309    void 0 === e && (e = null), void 0 === n && (n = !1);
14310    var r = mn(t, "x", "min"),
14311        o = r,
14312        a = O(e, r.shape),
14313        i = a,
14314        s = En(i, r.rank);
14315    null != s && (r = r.transpose(s), i = In(i.length, r.rank));
14316    var u = [r],
14317        c = Lt.runKernelFunc(function (t, e) {
14318      var n = t.min(r, i);
14319      return e([o, n]), n;
14320    }, {
14321      x: r
14322    }, function (t, e) {
14323      return Ol(t, e[1], e[0], a, s);
14324    }, "Min", {
14325      axes: i
14326    }, u, [!0]);
14327
14328    if (n) {
14329      var l = wn(c.shape, a);
14330      c = c.reshape(l);
14331    }
14332
14333    return c;
14334  }
14335}),
14336    Gl = An({
14337  moments_: function (t, e, n) {
14338    void 0 === e && (e = null), void 0 === n && (n = !1);
14339    var r = O(e, (t = mn(t, "x", "moments")).shape),
14340        o = t.mean(r, n),
14341        a = o.shape;
14342    n || (a = wn(o.shape, r));
14343    var i = t.toFloat().sub(o.reshape(a)).square();
14344    return {
14345      mean: o,
14346      variance: i.mean(r, n)
14347    };
14348  }
14349}),
14350    Hl = An({
14351  sum_: function (t, e, n) {
14352    void 0 === e && (e = null), void 0 === n && (n = !1);
14353    var r = mn(t, "x", "sum");
14354    "bool" === r.dtype && (r = r.toInt());
14355    var o = O(e, r.shape);
14356    return ea(function (t) {
14357      var e = En(o, t.rank),
14358          r = o,
14359          a = t;
14360      null != e && (a = t.transpose(e), r = In(r.length, t.rank));
14361
14362      var i = function (e) {
14363        var n = t.shape.slice();
14364        return o.forEach(function (t) {
14365          n[t] = 1;
14366        }), e.reshape(n).mul(zn(t.shape, "float32"));
14367      },
14368          s = {
14369        axes: r
14370      },
14371          u = Lt.runKernelFunc(function (t) {
14372        return t.sum(a, r);
14373      }, {
14374        x: a
14375      }, function (t) {
14376        return {
14377          x: function () {
14378            return i(t);
14379          }
14380        };
14381      }, "Sum", s);
14382
14383      if (n) {
14384        var c = wn(u.shape, o);
14385        u = u.reshape(c);
14386      }
14387
14388      return {
14389        value: u,
14390        gradFunc: i
14391      };
14392    })(r);
14393  }
14394}),
14395    ql = An({
14396  prod_: function (t, e, n) {
14397    void 0 === e && (e = null), void 0 === n && (n = !1);
14398    var r = mn(t, "x", "prod");
14399    "bool" === r.dtype && (r = r.toInt());
14400    var o = O(e, r.shape),
14401        a = En(o, r.rank),
14402        i = o,
14403        s = r;
14404    null != a && (s = r.transpose(a), i = In(i.length, r.rank));
14405    var u = Lt.runKernelFunc(function (t) {
14406      return t.prod(s, i);
14407    }, {
14408      permutedX: s
14409    });
14410
14411    if (n) {
14412      var c = wn(u.shape, o);
14413      u = u.reshape(c);
14414    }
14415
14416    return u;
14417  }
14418});
14419exports.prod = ql;
14420exports.sum = Hl;
14421exports.moments = Gl;
14422exports.min = zl;
14423exports.mean = Vl;
14424exports.max = Ul;
14425exports.logSumExp = Wl;
14426exports.argMin = Ll;
14427exports.argMax = Pl;
14428exports.any = Bl;
14429exports.all = Ml;
14430var Kl = An({
14431  elu_: function (t) {
14432    var e = mn(t, "x", "elu");
14433    return Lt.runKernelFunc(function (t, n) {
14434      var r = t.elu(e);
14435      return n([r]), r;
14436    }, {
14437      $x: e
14438    }, function (t, e) {
14439      var n = e[0];
14440      return {
14441        $x: function () {
14442          return Lt.runKernelFunc(function (e) {
14443            return e.eluDer(t, n);
14444          }, {
14445            dy: t,
14446            y: n
14447          });
14448        }
14449      };
14450    });
14451  }
14452}),
14453    jl = An({
14454  leakyRelu_: function (t, e) {
14455    void 0 === e && (e = .2);
14456    var n = mn(t, "x", "leakyRelu");
14457    return bo(On(e).mul(n), n);
14458  }
14459}),
14460    Xl = An({
14461  prelu_: function (t, e) {
14462    var n = mn(t, "x", "prelu"),
14463        r = mn(e, "alpha", "prelu");
14464    return Lt.runKernelFunc(function (t, e) {
14465      var o = t.prelu(n, r);
14466      return e([n, r]), o;
14467    }, {
14468      x: n,
14469      alpha: r
14470    }, function (t, e) {
14471      var n = e[0],
14472          r = e[1],
14473          o = n.greater(0);
14474      return {
14475        x: function () {
14476          return tc(o, t, t.mul(r));
14477        },
14478        alpha: function () {
14479          var e = tc(o, Xn(t), t.mul(n)),
14480              a = Nr(r.shape, t.shape);
14481          return a.length > 0 && (e = e.sum(a)), e.reshape(r.shape);
14482        }
14483      };
14484    }, "Prelu");
14485  }
14486}),
14487    Yl = An({
14488  relu_: function (t) {
14489    var e = mn(t, "x", "relu");
14490    return "bool" === e.dtype ? e.toInt() : Lt.runKernelFunc(function (t, n) {
14491      var r = t.relu(e);
14492      return n([e]), r;
14493    }, {
14494      x: e
14495    }, function (t, e) {
14496      var n = e[0];
14497      return {
14498        x: function () {
14499          return t.mulStrict(n.step().toFloat());
14500        }
14501      };
14502    }, "Relu");
14503  }
14504}),
14505    $l = An({
14506  relu6_: function (t) {
14507    var e = mn(t, "x", "relu6");
14508    return "bool" === e.dtype ? e.toInt() : Lt.runKernelFunc(function (t, n) {
14509      var r = t.relu6(e);
14510      return n([e]), r;
14511    }, {
14512      x: e
14513    }, function (t, e) {
14514      var n = e[0],
14515          r = n.lessEqual(6).mul(n.step());
14516      return {
14517        x: function () {
14518          return t.mulStrict(r.toFloat());
14519        }
14520      };
14521    }, "Relu6");
14522  }
14523}),
14524    Ql = An({
14525  selu_: function (t) {
14526    var e = mn(t, "x", "selu");
14527    return Lt.runKernelFunc(function (t, n) {
14528      var r = t.selu(e);
14529      return n([e]), r;
14530    }, {
14531      $x: e
14532    }, function (t, e) {
14533      var n = e[0];
14534      return {
14535        $x: function () {
14536          var e = n.greater(On(0)),
14537              r = On(au),
14538              o = On(iu),
14539              a = t.mul(o),
14540              i = t.mul(r).mul(n.toFloat().exp());
14541          return tc(e, a, i);
14542        }
14543      };
14544    });
14545  }
14546});
14547exports.selu = Ql;
14548exports.relu6 = $l;
14549exports.relu = Yl;
14550exports.prelu = Xl;
14551exports.leakyRelu = jl;
14552exports.elu = Kl;
14553var Jl = An({
14554  transpose_: function (t, e) {
14555    var n = mn(t, "x", "transpose");
14556    if (null == e && (e = n.shape.map(function (t, e) {
14557      return e;
14558    }).reverse()), C(n.rank === e.length, function () {
14559      return "Error in transpose: rank of input " + n.rank + " must match length of perm " + e + ".";
14560    }), e.forEach(function (t) {
14561      C(t >= 0 && t < n.rank, function () {
14562        return "All entries in 'perm' must be between 0 and " + (n.rank - 1) + " but got " + e;
14563      });
14564    }), n.rank <= 1) return n.clone();
14565    var r = {
14566      perm: e
14567    };
14568    return Lt.runKernelFunc(function (t) {
14569      return t.transpose(n, e);
14570    }, {
14571      x: n
14572    }, function (t) {
14573      var n = Rn(e);
14574      return {
14575        x: function () {
14576          return t.transpose(n);
14577        }
14578      };
14579    }, "Transpose", r);
14580  }
14581});
14582exports.transpose = Jl;
14583var Zl = An({
14584  localResponseNormalization_: function (t, e, n, r, o) {
14585    void 0 === e && (e = 5), void 0 === n && (n = 1), void 0 === r && (r = 1), void 0 === o && (o = .5);
14586    var a = mn(t, "x", "localResponseNormalization");
14587    C(4 === a.rank || 3 === a.rank, function () {
14588      return "Error in localResponseNormalization: x must be rank 3 or 4 but got\n               rank " + a.rank + ".";
14589    }), C(A(e), function () {
14590      return "Error in localResponseNormalization: depthRadius must be an integer but got depthRadius " + e + ".";
14591    });
14592    var i = a,
14593        s = !1;
14594    3 === a.rank && (s = !0, i = a.as4D(1, a.shape[0], a.shape[1], a.shape[2]));
14595    var u = Lt.runKernelFunc(function (t, a) {
14596      var s = t.localResponseNormalization4D(i, e, n, r, o);
14597      return a([i, s]), s;
14598    }, {
14599      x4D: i
14600    }, function (t, a) {
14601      var i = a[0],
14602          s = a[1];
14603      return {
14604        x4D: function () {
14605          return Lt.runKernelFunc(function (a) {
14606            return a.LRNGrad(t, i, s, e, n, r, o);
14607          }, {});
14608        }
14609      };
14610    });
14611    return s ? u.as3D(u.shape[1], u.shape[2], u.shape[3]) : u;
14612  }
14613});
14614exports.localResponseNormalization = Zl;
14615var th = An({
14616  norm_: function (t, e, n, r) {
14617    void 0 === e && (e = "euclidean"), void 0 === n && (n = null), void 0 === r && (r = !1);
14618
14619    var o = function t(e, n, r) {
14620      void 0 === r && (r = null);
14621      if (0 === e.rank) return e.abs();
14622      if (1 !== e.rank && null === r) return t(e.reshape([-1]), n, r);
14623
14624      if (1 === e.rank || "number" == typeof r || Array.isArray(r) && 1 === r.length) {
14625        if (1 === n) return e.abs().sum(r);
14626        if (n === 1 / 0) return e.abs().max(r);
14627        if (n === -1 / 0) return e.abs().min(r);
14628        if ("euclidean" === n || 2 === n) return e.abs().pow(On(2, "int32")).sum(r).sqrt();
14629        throw new Error("Error in norm: invalid ord value: " + n);
14630      }
14631
14632      if (Array.isArray(r) && 2 === r.length) {
14633        if (1 === n) return e.abs().sum(r[0]).max(r[1] - 1);
14634        if (n === 1 / 0) return e.abs().sum(r[1]).max(r[0]);
14635        if (n === -1 / 0) return e.abs().sum(r[1]).min(r[0]);
14636        if ("fro" === n || "euclidean" === n) return e.square().sum(r).sqrt();
14637        throw new Error("Error in norm: invalid ord value: " + n);
14638      }
14639
14640      throw new Error("Error in norm: invalid axis: " + r);
14641    }(t = mn(t, "x", "norm"), e, n),
14642        a = o.shape;
14643
14644    if (r) {
14645      var i = O(n, t.shape);
14646      a = wn(o.shape, i);
14647    }
14648
14649    return o.reshape(a);
14650  }
14651});
14652exports.norm = th;
14653var eh = An({
14654  basicLSTMCell_: function (t, e, n, r, o, a) {
14655    var i = mn(t, "forgetBias", "basicLSTMCell"),
14656        s = mn(e, "lstmKernel", "basicLSTMCell"),
14657        u = mn(n, "lstmBias", "basicLSTMCell"),
14658        c = mn(r, "data", "basicLSTMCell"),
14659        l = mn(o, "c", "basicLSTMCell"),
14660        h = mn(a, "h", "basicLSTMCell"),
14661        f = c.concat(h, 1).matMul(s).add(u),
14662        d = f.shape[0],
14663        p = f.shape[1] / 4,
14664        v = [d, p],
14665        m = f.slice([0, 0], v),
14666        g = f.slice([0, p], v),
14667        y = f.slice([0, 2 * p], v),
14668        x = f.slice([0, 3 * p], v),
14669        b = m.sigmoid().mulStrict(g.tanh()).addStrict(l.mulStrict(i.add(y).sigmoid())),
14670        w = b.tanh().mulStrict(x.sigmoid());
14671    return [b, w];
14672  }
14673}),
14674    nh = An({
14675  multiRNNCell_: function (t, e, n, r) {
14676    for (var o = mn(e, "data", "multiRNNCell"), a = gn(n, "c", "multiRNNCell"), i = gn(r, "h", "multiRNNCell"), s = o, u = [], c = 0; c < t.length; c++) {
14677      var l = t[c](s, a[c], i[c]);
14678      u.push(l[0]), u.push(l[1]), s = l[1];
14679    }
14680
14681    var h = [],
14682        f = [];
14683
14684    for (c = 0; c < u.length; c += 2) h.push(u[c]), f.push(u[c + 1]);
14685
14686    return [h, f];
14687  }
14688});
14689exports.multiRNNCell = nh;
14690exports.basicLSTMCell = eh;
14691var rh = An({
14692  movingAverage_: function (t, e, n, r, o) {
14693    void 0 === o && (o = !0);
14694    var a = mn(t, "v", "movingAverage"),
14695        i = mn(e, "x", "movingAverage"),
14696        s = mn(n, "decay", "movingAverage");
14697    Ft(a, i), C(S(a.shape, i.shape), function () {
14698      return "Shape mismatch in v and x";
14699    });
14700    var u = On(1),
14701        c = u.sub(s),
14702        l = i.sub(a).mul(c);
14703
14704    if (o) {
14705      C(null != r, function () {
14706        return "When using zeroDebias: true, step is required.";
14707      });
14708      var h = mn(r, "step", "movingAverage");
14709      l = l.div(u.sub(Ao(s, h)));
14710    }
14711
14712    return a.add(l);
14713  }
14714});
14715exports.movingAverage = rh;
14716var oh = An({
14717  stridedSlice_: function (t, e, n, r, o, a, i, s, u) {
14718    if (void 0 === o && (o = 0), void 0 === a && (a = 0), void 0 === i && (i = 0), void 0 === s && (s = 0), void 0 === u && (u = 0), null == r && (r = new Array(e.length)), 0 !== i) throw new Error("ellipsis mask is not yet supported");
14719    var c = mn(t, "x", "stridedSlice"),
14720        l = Go(s),
14721        h = c.shape.slice();
14722    l.forEach(function (t) {
14723      e[t] = 0, n[t] = 1, h.splice(t, 0, 1);
14724    }), c = c.reshape(h);
14725
14726    for (var f = 0; f < c.rank; f++) e[f] = qo(o, e, r, c.shape, f), n[f] = Ko(a, n, r, c.shape, f), r[f] = r[f] || 1;
14727
14728    var d = Go(u);
14729    d.forEach(function (t) {
14730      n[t] = e[t] + 1, r[t] = 1;
14731    });
14732    var p = Ho(e, n, r),
14733        v = p.filter(function (t, e) {
14734      return -1 === d.indexOf(e);
14735    });
14736    return r.every(function (t) {
14737      return 1 === t;
14738    }) ? Tl(c, e, p).reshape(v) : Lt.runKernelFunc(function (t) {
14739      return t.stridedSlice(c, e, n, r);
14740    }, {
14741      $x: c
14742    }).reshape(v);
14743  }
14744});
14745exports.stridedSlice = oh;
14746var ah = An({
14747  topk_: function (t, e, n) {
14748    void 0 === e && (e = 1), void 0 === n && (n = !0);
14749    var r = mn(t, "x", "topk");
14750    if (0 === r.rank) throw new Error("topk() expects the input to be of rank 1 or higher");
14751    var o = r.shape[r.shape.length - 1];
14752    if (e > o) throw new Error("'k' passed to topk() must be <= the last dimension (" + o + ") but got " + e);
14753    var a = Lt.runKernelFunc(function (t) {
14754      return t.topk(r, e, n);
14755    }, {
14756      $x: r
14757    });
14758    return {
14759      values: a[0],
14760      indices: a[1]
14761    };
14762  }
14763});
14764exports.topk = ah;
14765var ih = An({
14766  scatterND_: function (t, e, n) {
14767    var r = mn(t, "indices", "scatterND", "int32"),
14768        o = mn(e, "updates", "scatterND");
14769    return Wo(o, r, n), Lt.runKernelFunc(function (t) {
14770      return t.scatterND(r, o, n);
14771    }, {
14772      indices: r,
14773      updates: o
14774    }, null, "ScatterNd", {
14775      shape: n
14776    });
14777  }
14778});
14779exports.scatterND = ih;
14780var sh = An({
14781  fft_: function (t) {
14782    C("complex64" === t.dtype, function () {
14783      return "The dtype for tf.spectral.fft() must be complex64 but got " + t.dtype + ".";
14784    });
14785    var e = t.shape[t.shape.length - 1],
14786        n = t.size / e,
14787        r = t.as2D(n, e);
14788    return Lt.runKernelFunc(function (t) {
14789      return t.fft(r);
14790    }, {
14791      input: t
14792    }).reshape(t.shape);
14793  }
14794}),
14795    uh = An({
14796  ifft_: function (t) {
14797    C("complex64" === t.dtype, function () {
14798      return "The dtype for tf.spectral.ifft() must be complex64 but got " + t.dtype + ".";
14799    });
14800    var e = t.shape[t.shape.length - 1],
14801        n = t.size / e,
14802        r = t.as2D(n, e);
14803    return Lt.runKernelFunc(function (t) {
14804      return t.ifft(r);
14805    }, {
14806      input: t
14807    }).reshape(t.shape);
14808  }
14809}),
14810    ch = An({
14811  rfft_: function (t, e) {
14812    C("float32" === t.dtype, function () {
14813      return "The dtype for rfft() must be real value but got " + t.dtype;
14814    });
14815    var n,
14816        r = t.shape[t.shape.length - 1],
14817        o = t.size / r;
14818
14819    if (null != e && e < r) {
14820      var a = t.shape.map(function (t) {
14821        return 0;
14822      }),
14823          i = t.shape.map(function (t) {
14824        return t;
14825      });
14826      i[t.shape.length - 1] = e, n = t.slice(a, i), r = e;
14827    } else if (null != e && e > r) {
14828      var s = t.shape.map(function (t) {
14829        return t;
14830      });
14831      s[t.shape.length - 1] = e - r, n = t.concat(Gn(s), t.shape.length - 1), r = e;
14832    } else n = t;
14833
14834    var u = n.zerosLike(),
14835        c = Tn(n, u).as2D(o, r),
14836        l = sh(c),
14837        h = Math.floor(r / 2) + 1,
14838        f = Dn(l),
14839        d = Nn(l),
14840        p = f.split([h, r - h], f.shape.length - 1),
14841        v = d.split([h, r - h], d.shape.length - 1),
14842        m = n.shape.slice();
14843    return m[n.shape.length - 1] = h, Tn(p[0], v[0]).reshape(m);
14844  }
14845}),
14846    lh = An({
14847  irfft_: function (t) {
14848    var e = t.shape[t.shape.length - 1],
14849        n = t.size / e;
14850
14851    if (e <= 2) {
14852      var r = t.as2D(n, e),
14853          o = uh(r);
14854      return Dn(o);
14855    }
14856
14857    var a = [n, 2 * (e - 1)],
14858        i = Dn(t).as2D(n, e),
14859        s = Nn(t).as2D(n, e),
14860        u = i.slice([0, 1], [n, e - 2]).reverse(1),
14861        c = s.slice([0, 1], [n, e - 2]).reverse(1).mul(On(-1)),
14862        l = i.concat(u, 1),
14863        h = s.concat(c, 1);
14864    return r = Tn(l, h).as2D(a[0], a[1]), o = uh(r), Dn(o);
14865  }
14866}),
14867    hh = Object.freeze({
14868  fft: sh,
14869  ifft: uh,
14870  rfft: ch,
14871  irfft: lh
14872});
14873exports.spectral = hh;
14874exports.irfft = lh;
14875exports.rfft = ch;
14876exports.ifft = uh;
14877exports.fft = sh;
14878var fh = An({
14879  sparseToDense_: function (t, e, n, r) {
14880    void 0 === r && (r = 0);
14881    var o = mn(t, "sparseIndices", "sparseToDense", "int32"),
14882        a = mn(e, "sparseValues", "sparseToDense"),
14883        i = mn(r, "defaultValue", "sparseToDense", a.dtype);
14884    return function (t, e, n, r) {
14885      if ("int32" !== t.dtype) throw new Error("tf.sparseToDense() expects the indices to be int32 type, but the dtype was " + t.dtype + ".");
14886      if (t.rank > 2) throw new Error("sparseIndices should be a scalar, vector, or matrix, but got shape " + t.shape + ".");
14887      var o = t.rank > 0 ? t.shape[0] : 1,
14888          a = t.rank > 1 ? t.shape[1] : 1;
14889      if (n.length !== a) throw new Error("outputShape has incorrect number of elements:, " + n.length + ", should be: " + a + ".");
14890      var i = e.size;
14891      if (0 !== e.rank && (1 !== e.rank || i !== o)) throw new Error("sparseValues has incorrect shape " + e.shape + ", should be [] or [" + o + "]");
14892      if (e.dtype !== r.dtype) throw new Error("sparseValues.dtype must match defaultValues.dtype");
14893    }(o, a, n, i), Lt.runKernelFunc(function (t) {
14894      return t.sparseToDense(o, a, n, i);
14895    }, {
14896      $sparseIndices: o,
14897      $sparseValues: a,
14898      $defaultValue: i
14899    });
14900  }
14901});
14902exports.sparseToDense = fh;
14903var dh = An({
14904  gatherND_: function (t, e) {
14905    var n = mn(e, "indices", "gatherND", "int32"),
14906        r = mn(t, "x", "gatherND");
14907    return Lt.runKernelFunc(function (t) {
14908      return t.gatherND(r, n);
14909    }, {
14910      x: r,
14911      indices: n
14912    }, null, "GatherNd");
14913  }
14914});
14915exports.gatherND = dh;
14916var ph = An({
14917  diag_: function (t) {
14918    var e = mn(t, "x", "diag").flatten(),
14919        n = t.shape.concat(t.shape);
14920    return Lt.runKernelFunc(function (t) {
14921      return t.diag(e);
14922    }, {
14923      $x: e
14924    }).reshape(n);
14925  }
14926});
14927exports.diag = ph;
14928var vh = An({
14929  dropout_: function (t, e, n, r) {
14930    var o = mn(t, "x", "dropout");
14931    if (C("float32" === o.dtype, function () {
14932      return "x has to be a floating point tensor since it's going to be scaled, but got a " + o.dtype + " tensor instead.";
14933    }), C(e >= 0 && e < 1, function () {
14934      return "rate must be a float in the range [0, 1), but got " + e + ".";
14935    }), 0 === e) return t instanceof wt ? o.clone() : o;
14936
14937    var a = function (t, e) {
14938      if (null == e) return t.shape.slice();
14939      if (S(t.shape, e)) return e;
14940
14941      if (t.shape.length === e.length) {
14942        for (var n = [], r = 0; r < t.shape.length; r++) null == e[r] && null != t.shape[r] ? n.push(t.shape[r]) : n.push(e[r]);
14943
14944        return n;
14945      }
14946
14947      return e;
14948    }(o, n),
14949        i = 1 - e,
14950        s = xc(a, 0, 1, "float32", r).add(i).floor().div(i);
14951
14952    return o.mul(s);
14953  }
14954});
14955exports.dropout = vh;
14956
14957function mh(t, e, n) {
14958  for (var r = 1 - t % 2, o = new Float32Array(t), a = 0; a < t; ++a) {
14959    var i = 2 * Math.PI * a / (t + r - 1);
14960    o[a] = e - n * Math.cos(i);
14961  }
14962
14963  return Mn(o, "float32");
14964}
14965
14966var gh = An({
14967  hannWindow_: function (t) {
14968    return mh(t, .5, .5);
14969  }
14970}),
14971    yh = An({
14972  hammingWindow_: function (t) {
14973    return mh(t, .54, .46);
14974  }
14975}),
14976    xh = An({
14977  frame_: function (t, e, n, r, o) {
14978    void 0 === r && (r = !1), void 0 === o && (o = 0);
14979
14980    for (var a = 0, i = []; a + e <= t.size;) i.push(Tl(t, a, e)), a += n;
14981
14982    if (r) for (; a < t.size;) {
14983      var s = a + e - t.size,
14984          u = Yn([Tl(t, a, e - s), Hn([s], o)]);
14985      i.push(u), a += n;
14986    }
14987    return 0 === i.length ? Bn([], [0, e]) : Yn(i).as2D(i.length, e);
14988  }
14989}),
14990    bh = An({
14991  stft_: function (t, e, n, r, o) {
14992    var a;
14993    void 0 === o && (o = gh), null == r && (a = e, r = Math.floor(Math.pow(2, Math.ceil(Math.log(a) / Math.log(2)))));
14994
14995    for (var i = xh(t, e, n), s = ko(i, o(e)), u = [], c = 0; c < i.shape[0]; c++) u.push(ch(s.slice([c, 0], [1, e]), r));
14996
14997    return Yn(u);
14998  }
14999}),
15000    wh = Object.freeze({
15001  hannWindow: gh,
15002  hammingWindow: yh,
15003  frame: xh,
15004  stft: bh
15005});
15006exports.signal = wh;
15007exports.stft = bh;
15008exports.frame = xh;
15009exports.hammingWindow = yh;
15010exports.hannWindow = gh;
15011
15012var Ch,
15013    Eh = function (t, e, o) {
15014  return void 0 === o && (o = 1), n(this, void 0, void 0, function () {
15015    var n, a, i, s, u, c, l, h, f, d, p, v, m, g;
15016    return r(this, function (r) {
15017      switch (r.label) {
15018        case 0:
15019          return n = mn(t, "predictions", "inTopK"), a = mn(e, "targets", "inTopK"), C(n.rank > 1, function () {
15020            return "inTopK() expects the predictions to be of rank 2 or higher, but got " + n.rank;
15021          }), C(n.rank - 1 === a.rank, function () {
15022            return "predictions rank should be 1 larger than targets rank, but got predictions rank " + n.rank + " and targets rank " + a.rank;
15023          }), E(n.shape.slice(0, n.shape.length - 1), a.shape, "predictions's shape should be align with the targets' shape, except the last dimension."), i = n.shape[n.shape.length - 1], C(o > 0 && o <= i, function () {
15024            return "'k' passed to inTopK() must be > 0 && <= the predictions last dimension (" + i + "), but got " + o;
15025          }), [4, n.data()];
15026
15027        case 1:
15028          return s = r.sent(), [4, a.data()];
15029
15030        case 2:
15031          for (u = r.sent(), c = [s.length / i, i], h = c[1], f = B("bool", l = c[0]), d = 0; d < l; d++) {
15032            for (p = d * h, v = s.subarray(p, p + h), m = [], g = 0; g < v.length; g++) m.push({
15033              value: v[g],
15034              index: g
15035            });
15036
15037            for (m.sort(function (t, e) {
15038              return e.value - t.value;
15039            }), f[d] = 0, g = 0; g < o; g++) if (m[g].index === u[d]) {
15040              f[d] = 1;
15041              break;
15042            }
15043          }
15044
15045          return t !== n && n.dispose(), e !== a && a.dispose(), [2, Fn(f, a.shape, "bool")];
15046      }
15047    });
15048  });
15049};
15050
15051exports.inTopKAsync = Eh;
15052exports.Reduction = Ch;
15053!function (t) {
15054  t[t.NONE = 0] = "NONE", t[t.MEAN = 1] = "MEAN", t[t.SUM = 2] = "SUM", t[t.SUM_BY_NONZERO_WEIGHTS = 3] = "SUM_BY_NONZERO_WEIGHTS";
15055}(Ch || (exports.Reduction = Ch = {}));
15056
15057var Rh = An({
15058  absoluteDifference_: function (t, e, n, r) {
15059    void 0 === r && (r = Ch.SUM_BY_NONZERO_WEIGHTS);
15060    var o = mn(t, "labels", "absoluteDifference"),
15061        a = mn(e, "predictions", "absoluteDifference"),
15062        i = null;
15063    null != n && (i = mn(n, "weights", "absoluteDifference")), E(o.shape, a.shape, "Error in absoluteDifference: ");
15064    var s = o.sub(a).abs();
15065    return Ih(s, i, r);
15066  }
15067}),
15068    Ih = An({
15069  computeWeightedLoss_: function (t, e, n) {
15070    void 0 === n && (n = Ch.SUM_BY_NONZERO_WEIGHTS);
15071    var r = mn(t, "losses", "computeWeightedLoss"),
15072        o = null;
15073    null != e && (o = mn(e, "weights", "computeWeightedLoss"));
15074    var a = null == o ? r : r.mul(o);
15075    if (n === Ch.NONE) return a;
15076    if (n === Ch.SUM) return a.sum();
15077
15078    if (n === Ch.MEAN) {
15079      if (null == o) return a.mean();
15080      var i = r.size / o.size,
15081          s = a.sum().div(o.sum());
15082      return i > 1 ? s.div(On(i)) : s;
15083    }
15084
15085    if (n === Ch.SUM_BY_NONZERO_WEIGHTS) {
15086      if (null == o) return a.sum().div(On(r.size));
15087      var u = o.mul(zn(r.shape)).notEqual(On(0)).sum().toFloat();
15088      return a.sum().div(u);
15089    }
15090
15091    throw Error("Unknown reduction: " + n);
15092  }
15093}),
15094    kh = An({
15095  cosineDistance_: function (t, e, n, r, o) {
15096    void 0 === o && (o = Ch.SUM_BY_NONZERO_WEIGHTS);
15097    var a = mn(t, "labels", "cosineDistance"),
15098        i = mn(e, "predictions", "cosineDistance"),
15099        s = null;
15100    null != r && (s = mn(r, "weights", "cosineDistance")), E(a.shape, i.shape, "Error in cosineDistance: ");
15101    var u = On(1).sub(a.mul(i).sum(n, !0));
15102    return Ih(u, s, o);
15103  }
15104}),
15105    Sh = An({
15106  hingeLoss_: function (t, e, n, r) {
15107    void 0 === r && (r = Ch.SUM_BY_NONZERO_WEIGHTS);
15108    var o = mn(t, "labels", "hingeLoss"),
15109        a = mn(e, "predictions", "hingeLoss"),
15110        i = null;
15111    null != n && (i = mn(n, "weights", "hingeLoss")), E(o.shape, a.shape, "Error in hingeLoss: ");
15112    var s = On(1);
15113    o = On(2).mul(o).sub(s);
15114    var u = s.sub(o.mul(a)).relu();
15115    return Ih(u, i, r);
15116  }
15117}),
15118    Ah = An({
15119  huberLoss_: function (t, e, n, r, o) {
15120    void 0 === r && (r = 1), void 0 === o && (o = Ch.SUM_BY_NONZERO_WEIGHTS);
15121    var a = mn(t, "labels", "huberLoss"),
15122        i = mn(e, "predictions", "huberLoss"),
15123        s = null;
15124    null != n && (s = mn(n, "weights", "huberLoss")), E(a.shape, i.shape, "Error in huberLoss: ");
15125    var u = On(r),
15126        c = i.sub(a).abs(),
15127        l = Co(c, u),
15128        h = c.sub(l),
15129        f = On(.5).mul(l.square()).add(u.mul(h));
15130    return Ih(f, s, o);
15131  }
15132}),
15133    Th = An({
15134  logLoss_: function (t, e, n, r, o) {
15135    void 0 === r && (r = 1e-7), void 0 === o && (o = Ch.SUM_BY_NONZERO_WEIGHTS);
15136    var a = mn(t, "labels", "logLoss"),
15137        i = mn(e, "predictions", "logLoss"),
15138        s = null;
15139    null != n && (s = mn(n, "weights", "logLoss")), E(a.shape, i.shape, "Error in logLoss: ");
15140    var u = On(1),
15141        c = On(r),
15142        l = a.mul(i.add(c).log()).neg().sub(u.sub(a).mul(u.sub(i).add(c).log()));
15143    return Ih(l, s, o);
15144  }
15145}),
15146    Dh = An({
15147  meanSquaredError_: function (t, e, n, r) {
15148    void 0 === r && (r = Ch.SUM_BY_NONZERO_WEIGHTS);
15149    var o = mn(t, "labels", "meanSquaredError"),
15150        a = mn(e, "predictions", "meanSquaredError"),
15151        i = null;
15152    null != n && (i = mn(n, "weights", "meanSquaredError")), E(o.shape, a.shape, "Error in meanSquaredError: ");
15153    var s = o.squaredDifference(a);
15154    return Ih(s, i, r);
15155  }
15156}),
15157    Nh = An({
15158  sigmoidCrossEntropy_: function (t, e, n, r, o) {
15159    void 0 === r && (r = 0), void 0 === o && (o = Ch.SUM_BY_NONZERO_WEIGHTS);
15160    var a = mn(t, "multiClassLabels", "sigmoidCrossEntropy"),
15161        i = mn(e, "logits", "sigmoidCrossEntropy"),
15162        s = null;
15163
15164    if (null != n && (s = mn(n, "weights", "sigmoidCrossEntropy")), E(a.shape, i.shape, "Error in sigmoidCrossEntropy: "), r > 0) {
15165      var u = On(r),
15166          c = On(1),
15167          l = On(.5);
15168      a = a.mul(c.sub(u)).add(l.mul(u));
15169    }
15170
15171    var h = function (t, e) {
15172      var n = mn(t, "labels", "sigmoidCrossEntropyWithLogits"),
15173          r = mn(e, "logits", "sigmoidCrossEntropyWithLogits");
15174      E(n.shape, r.shape, "Error in sigmoidCrossEntropyWithLogits: ");
15175      var o = r.relu(),
15176          a = r.mul(n),
15177          i = r.abs().neg().exp().log1p();
15178      return o.sub(a).add(i);
15179    }(a, i);
15180
15181    return Ih(h, s, o);
15182  }
15183}),
15184    Fh = An({
15185  softmaxCrossEntropy_: function (t, e, n, r, o) {
15186    void 0 === r && (r = 0), void 0 === o && (o = Ch.SUM_BY_NONZERO_WEIGHTS);
15187    var a = mn(t, "onehotLabels", "softmaxCrossEntropy"),
15188        i = mn(e, "logits", "softmaxCrossEntropy"),
15189        s = null;
15190
15191    if (null != n && (s = mn(n, "weights", "softmaxCrossEntropy")), E(a.shape, i.shape, "Error in softmaxCrossEntropy: "), r > 0) {
15192      var u = On(r),
15193          c = On(1),
15194          l = On(a.shape[1]);
15195      a = a.mul(c.sub(u)).add(u.div(l));
15196    }
15197
15198    var h = function (t, e, n) {
15199      if (void 0 === n && (n = -1), -1 === n && (n = e.rank - 1), n !== e.rank - 1) throw Error("Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank " + e.rank + " and dim was " + n);
15200      return ea(function (t, e, r) {
15201        var o = e.logSumExp([n], !0),
15202            a = e.toFloat().sub(o);
15203        r([t, a]);
15204        return {
15205          value: a.mul(t).neg().sum([n]),
15206          gradFunc: function (t, e) {
15207            var r = e[0],
15208                o = e[1],
15209                a = wn(t.shape, [n]);
15210            return [t.reshape(a).mul(r.toFloat().sub(o.exp())), t.reshape(a).mul(o.exp().sub(r.toFloat()))];
15211          }
15212        };
15213      })(t, e);
15214    }(a, i);
15215
15216    return Ih(h, s, o);
15217  }
15218}),
15219    _h = Object.freeze({
15220  get Reduction() {
15221    return Ch;
15222  },
15223
15224  absoluteDifference: Rh,
15225  computeWeightedLoss: Ih,
15226  cosineDistance: kh,
15227  hingeLoss: Sh,
15228  huberLoss: Ah,
15229  logLoss: Th,
15230  meanSquaredError: Dh,
15231  sigmoidCrossEntropy: Nh,
15232  softmaxCrossEntropy: Fh
15233});
15234
15235exports.losses = _h;
15236
15237function Oh(t, e) {
15238  return void 0 === e && (e = !1), Lt.tidy(function () {
15239    if (2 !== t.shape.length) throw new Error("qr2d() requires a 2D Tensor, but got a " + t.shape.length + "D Tensor.");
15240
15241    for (var n = t.shape[0], r = t.shape[1], o = oc(n), a = t.clone(), i = Bn([[1]], [1, 1]), s = i.clone(), u = n >= r ? r : n, c = function (t) {
15242      var e,
15243          u = a,
15244          c = s,
15245          l = o;
15246      e = Lt.tidy(function () {
15247        var e = a.slice([t, t], [n - t, 1]),
15248            u = e.norm(),
15249            c = a.slice([t, t], [1, 1]),
15250            l = Bn([[-1]]).where(c.greater(0), Bn([[1]])),
15251            h = c.sub(l.mul(u)),
15252            f = e.div(h);
15253        s = 1 === f.shape[0] ? i.clone() : i.concat(f.slice([1, 0], [f.shape[0] - 1, f.shape[1]]), 0);
15254        var d = l.matMul(h).div(u).neg(),
15255            p = a.slice([t, 0], [n - t, r]),
15256            v = d.mul(s);
15257        if (0 === t) a = p.sub(v.matMul(s.transpose().matMul(p)));else {
15258          var m = p.sub(v.matMul(s.transpose().matMul(p)));
15259          a = a.slice([0, 0], [t, r]).concat(m, 0);
15260        }
15261        var g = o.slice([0, t], [n, o.shape[1] - t]);
15262        if (0 === t) o = g.sub(g.matMul(s).matMul(v.transpose()));else {
15263          var y = g.sub(g.matMul(s).matMul(v.transpose()));
15264          o = o.slice([0, 0], [n, t]).concat(y, 1);
15265        }
15266        return [s, a, o];
15267      }), s = e[0], a = e[1], o = e[2], tn([u, c, l]);
15268    }, l = 0; l < u; ++l) c(l);
15269
15270    return !e && n > r && (o = o.slice([0, 0], [n, r]), a = a.slice([0, 0], [r, r])), [o, a];
15271  });
15272}
15273
15274var Mh = An({
15275  bandPart_: function (t, e, n) {
15276    if (e % 1 != 0) throw new Error("bandPart(): numLower must be an integer, got " + e + ".");
15277    if (n % 1 != 0) throw new Error("bandPart(): numUpper must be an integer, got " + n + ".");
15278    var r = mn(t, "a", "bandPart");
15279    if (r.rank < 2) throw new Error("bandPart(): Rank must be at least 2, got " + r.rank + ".");
15280    var o = r.shape,
15281        a = r.shape.slice(-2),
15282        i = a[0],
15283        s = a[1];
15284    if (!(e <= i)) throw new Error("bandPart(): numLower (" + e + ") must not be greater than the number of rows (" + i + ").");
15285    if (!(n <= s)) throw new Error("bandPart(): numUpper (" + n + ") must not be greater than the number of columns (" + s + ").");
15286    e < 0 && (e = i), n < 0 && (n = s);
15287    var u = Kn(0, i, 1, "int32").reshape([-1, 1]),
15288        c = Kn(0, s, 1, "int32"),
15289        l = No(u, c),
15290        h = $u(l.lessEqual(On(+e, "int32")), l.greaterEqual(On(-n, "int32"))),
15291        f = Gn([i, s], r.dtype);
15292    return mr(gr(r.reshape([-1, i, s])).map(function (t) {
15293      return tc(h, t, f);
15294    })).reshape(o);
15295  }
15296}),
15297    Bh = An({
15298  gramSchmidt_: function (t) {
15299    var e;
15300
15301    if (Array.isArray(t)) {
15302      e = !1, C(null != t && t.length > 0, function () {
15303        return "Gram-Schmidt process: input must not be null, undefined, or empty";
15304      });
15305
15306      for (var n = t[0].shape[0], r = function (e) {
15307        C(t[e].shape[0] === n, function () {
15308          return "Gram-Schmidt: Non-unique lengths found in the input vectors: (" + t[e].shape[0] + " vs. " + n + ")";
15309        });
15310      }, o = 1; o < t.length; ++o) r(o);
15311    } else e = !0, t = tr(t, t.shape[0], 0).map(function (t) {
15312      return vr(t, [0]);
15313    });
15314
15315    C(t.length <= t[0].shape[0], function () {
15316      return "Gram-Schmidt: Number of vectors (" + t.length + ") exceeds number of dimensions (" + t[0].shape[0] + ").";
15317    });
15318
15319    var a = [],
15320        i = t,
15321        s = function (t) {
15322      a.push(Lt.tidy(function () {
15323        var e = i[t];
15324        if (t > 0) for (var n = 0; n < t; ++n) {
15325          var r = Hl(a[n].mulStrict(e)).mul(a[n]);
15326          e = e.sub(r);
15327        }
15328        return e.div(th(e, "euclidean"));
15329      }));
15330    };
15331
15332    for (o = 0; o < t.length; ++o) s(o);
15333
15334    return e ? mr(a, 0) : a;
15335  }
15336}),
15337    Ph = An({
15338  qr_: function (t, e) {
15339    if (void 0 === e && (e = !1), t.rank < 2) throw new Error("qr() requires input tensor to have a rank >= 2, but got rank " + t.rank);
15340    if (2 === t.rank) return Oh(t, e);
15341    var n = t.shape.slice(0, t.shape.length - 2).reduce(function (t, e) {
15342      return t * e;
15343    }),
15344        r = gr(t.reshape([n, t.shape[t.shape.length - 2], t.shape[t.shape.length - 1]]), 0),
15345        o = [],
15346        a = [];
15347    return r.forEach(function (t) {
15348      var n = Oh(t, e),
15349          r = n[0],
15350          i = n[1];
15351      o.push(r), a.push(i);
15352    }), [mr(o, 0).reshape(t.shape), mr(a, 0).reshape(t.shape)];
15353  }
15354}),
15355    Lh = Object.freeze({
15356  bandPart: Mh,
15357  gramSchmidt: Bh,
15358  qr: Ph
15359});
15360exports.linalg = Lh;
15361
15362function Wh(t, e, n, r, o, a) {
15363  null == r && (r = .5), null == o && (o = Number.NEGATIVE_INFINITY), null == a && (a = 0);
15364  var i = t.shape[0];
15365  return n = Math.min(n, i), C(0 <= r && r <= 1, function () {
15366    return "iouThreshold must be in [0, 1], but was '" + r + "'";
15367  }), C(2 === t.rank, function () {
15368    return "boxes must be a 2D tensor, but was of rank '" + t.rank + "'";
15369  }), C(4 === t.shape[1], function () {
15370    return "boxes must have 4 columns, but 2nd dimension was " + t.shape[1];
15371  }), C(1 === e.rank, function () {
15372    return "scores must be a 1D tensor";
15373  }), C(e.shape[0] === i, function () {
15374    return "scores has incompatible shape with boxes. Expected " + i + ", but was " + e.shape[0];
15375  }), C(0 <= a && a <= 1, function () {
15376    return "softNmsSigma must be in [0, 1], but was '" + a + "'";
15377  }), {
15378    maxOutputSize: n,
15379    iouThreshold: r,
15380    scoreThreshold: o,
15381    softNmsSigma: a
15382  };
15383}
15384
15385var Uh = An({
15386  resizeBilinear_: function (t, e, n) {
15387    void 0 === n && (n = !1);
15388    var r = mn(t, "images", "resizeBilinear");
15389    C(3 === r.rank || 4 === r.rank, function () {
15390      return "Error in resizeBilinear: x must be rank 3 or 4, but got rank " + r.rank + ".";
15391    }), C(2 === e.length, function () {
15392      return "Error in resizeBilinear: new shape must 2D, but got shape " + e + ".";
15393    });
15394    var o = r,
15395        a = !1;
15396    3 === r.rank && (a = !0, o = r.as4D(1, r.shape[0], r.shape[1], r.shape[2]));
15397    var i = e[0],
15398        s = e[1],
15399        u = Lt.runKernelFunc(function (t, e) {
15400      return e([o]), t.resizeBilinear(o, i, s, n);
15401    }, {
15402      x: o
15403    }, function (t, e) {
15404      return {
15405        x: function () {
15406          return Lt.runKernelFunc(function (r) {
15407            return r.resizeBilinearBackprop(t, e[0], n);
15408          }, {});
15409        }
15410      };
15411    }, "ResizeBilinear", {
15412      alignCorners: n,
15413      newHeight: i,
15414      newWidth: s
15415    });
15416    return a ? u.as3D(u.shape[1], u.shape[2], u.shape[3]) : u;
15417  }
15418}),
15419    Vh = An({
15420  resizeNearestNeighbor_: function (t, e, n) {
15421    void 0 === n && (n = !1);
15422    var r = mn(t, "images", "resizeNearestNeighbor");
15423    C(3 === r.rank || 4 === r.rank, function () {
15424      return "Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank " + r.rank + ".";
15425    }), C(2 === e.length, function () {
15426      return "Error in resizeNearestNeighbor: new shape must 2D, but got shape " + e + ".";
15427    }), C("float32" === r.dtype || "int32" === r.dtype, function () {
15428      return "`images` must have `int32` or `float32` as dtype";
15429    });
15430    var o = r,
15431        a = !1;
15432    3 === r.rank && (a = !0, o = r.as4D(1, r.shape[0], r.shape[1], r.shape[2]));
15433    var i = e[0],
15434        s = e[1],
15435        u = Lt.runKernelFunc(function (t, e) {
15436      return e([o]), t.resizeNearestNeighbor(o, i, s, n);
15437    }, {
15438      batchImages: o
15439    }, function (t, e) {
15440      return {
15441        batchImages: function () {
15442          return Lt.runKernelFunc(function (r) {
15443            return r.resizeNearestNeighborBackprop(t, e[0], n);
15444          }, {});
15445        }
15446      };
15447    });
15448    return a ? u.as3D(u.shape[1], u.shape[2], u.shape[3]) : u;
15449  }
15450}),
15451    zh = An({
15452  nonMaxSuppression_: function (t, e, n, r, o) {
15453    void 0 === r && (r = .5), void 0 === o && (o = Number.NEGATIVE_INFINITY);
15454    var a = mn(t, "boxes", "nonMaxSuppression"),
15455        i = mn(e, "scores", "nonMaxSuppression"),
15456        s = Wh(a, i, n, r, o);
15457    n = s.maxOutputSize, r = s.iouThreshold, o = s.scoreThreshold;
15458    var u = {
15459      maxOutputSize: n,
15460      iouThreshold: r,
15461      scoreThreshold: o
15462    };
15463    return Lt.runKernelFunc(function (t) {
15464      return t.nonMaxSuppression(a, i, n, r, o);
15465    }, {
15466      boxes: a,
15467      scores: i
15468    }, null, "NonMaxSuppressionV3", u);
15469  }
15470}),
15471    Gh = function (t, e, o, a, i) {
15472  return void 0 === a && (a = .5), void 0 === i && (i = Number.NEGATIVE_INFINITY), n(this, void 0, void 0, function () {
15473    var n, s, u, c, l, h, f;
15474    return r(this, function (r) {
15475      switch (r.label) {
15476        case 0:
15477          return n = mn(t, "boxes", "nonMaxSuppressionAsync"), s = mn(e, "scores", "nonMaxSuppressionAsync"), u = Wh(n, s, o, a, i), o = u.maxOutputSize, a = u.iouThreshold, i = u.scoreThreshold, [4, Promise.all([n.data(), s.data()])];
15478
15479        case 1:
15480          return c = r.sent(), l = c[0], h = c[1], f = Da(l, h, o, a, i), n !== t && n.dispose(), s !== e && s.dispose(), [2, f];
15481      }
15482    });
15483  });
15484},
15485    Hh = An({
15486  nonMaxSuppressionWithScore_: function (t, e, n, r, o, a) {
15487    void 0 === r && (r = .5), void 0 === o && (o = Number.NEGATIVE_INFINITY), void 0 === a && (a = 0);
15488    var i = mn(t, "boxes", "nonMaxSuppression"),
15489        s = mn(e, "scores", "nonMaxSuppression"),
15490        u = Wh(i, s, n, r, o, a),
15491        c = {
15492      maxOutputSize: n = u.maxOutputSize,
15493      iouThreshold: r = u.iouThreshold,
15494      scoreThreshold: o = u.scoreThreshold,
15495      softNmsSigma: a = u.softNmsSigma
15496    },
15497        l = Lt.runKernel("NonMaxSuppressionV5", {
15498      boxes: i,
15499      scores: s
15500    }, c);
15501    return {
15502      selectedIndices: l[0],
15503      selectedScores: l[1]
15504    };
15505  }
15506}),
15507    qh = function (t, e, o, a, i, s) {
15508  return void 0 === a && (a = .5), void 0 === i && (i = Number.NEGATIVE_INFINITY), void 0 === s && (s = 0), n(this, void 0, void 0, function () {
15509    var n, u, c, l, h, f, d;
15510    return r(this, function (r) {
15511      switch (r.label) {
15512        case 0:
15513          return n = mn(t, "boxes", "nonMaxSuppressionAsync"), u = mn(e, "scores", "nonMaxSuppressionAsync"), c = Wh(n, u, o, a, i, s), o = c.maxOutputSize, a = c.iouThreshold, i = c.scoreThreshold, s = c.softNmsSigma, [4, Promise.all([n.data(), u.data()])];
15514
15515        case 1:
15516          return l = r.sent(), h = l[0], f = l[1], d = Na(h, f, o, a, i, s), n !== t && n.dispose(), u !== e && u.dispose(), [2, d];
15517      }
15518    });
15519  });
15520},
15521    Kh = An({
15522  cropAndResize_: function (t, e, n, r, o, a) {
15523    var i = mn(t, "image", "cropAndResize"),
15524        s = mn(e, "boxes", "cropAndResize", "float32"),
15525        u = mn(n, "boxInd", "cropAndResize", "int32");
15526    o = o || "bilinear", a = a || 0;
15527    var c = s.shape[0];
15528    return C(4 === i.rank, function () {
15529      return "Error in cropAndResize: image must be rank 4,but got rank " + i.rank + ".";
15530    }), C(2 === s.rank && 4 === s.shape[1], function () {
15531      return "Error in cropAndResize: boxes must be have size [" + c + ",4] but had shape " + s.shape + ".";
15532    }), C(1 === u.rank && u.shape[0] === c, function () {
15533      return "Error in cropAndResize: boxInd must be have size [" + c + "] but had shape " + s.shape + ".";
15534    }), C(2 === r.length, function () {
15535      return "Error in cropAndResize: cropSize must be of length 2, but got length " + r.length + ".";
15536    }), C(r[0] >= 1 && r[1] >= 1, function () {
15537      return "cropSize must be atleast [1,1], but was " + r;
15538    }), C("bilinear" === o || "nearest" === o, function () {
15539      return "method must be bilinear or nearest, but was " + o;
15540    }), Lt.runKernelFunc(function (t, e) {
15541      return t.cropAndResize(i, s, u, r, o, a);
15542    }, {
15543      images: i,
15544      boxes: s,
15545      boxInd: u
15546    }, null, "CropAndResize", {
15547      method: o,
15548      extrapolationValue: a,
15549      cropSize: r
15550    });
15551  }
15552}),
15553    jh = Object.freeze({
15554  resizeBilinear: Uh,
15555  resizeNearestNeighbor: Vh,
15556  nonMaxSuppression: zh,
15557  nonMaxSuppressionAsync: Gh,
15558  nonMaxSuppressionWithScore: Hh,
15559  nonMaxSuppressionWithScoreAsync: qh,
15560  cropAndResize: Kh
15561}),
15562    Xh = function (t, e) {
15563  return !(t > 0) || "linear" === e;
15564},
15565    Yh = function (t, e, n) {
15566  if (null == n || "linear" === n) return t;
15567  if ("relu" === n) return t.mul(e.step());
15568  throw new Error("Gradient for activation " + n + " has not been implemented yet.");
15569},
15570    $h = function (t, e) {
15571  var n = e,
15572      r = Nr(t.shape, e.shape);
15573  return r.length > 0 && (n = n.sum(r)), n.reshape(t.shape);
15574},
15575    Qh = function (t, e, n) {
15576  if ("linear" === e) return t;
15577  if ("relu" === e) return Yl(t);
15578  if ("elu" === e) return Kl(t);
15579  if ("relu6" === e) return $l(t);
15580  if ("prelu" === e) return Xl(t, n);
15581  throw new Error("Unknown fused activation " + e + ".");
15582};
15583
15584exports.image = jh;
15585var Jh = An({
15586  fusedMatMul_: function (t) {
15587    var e,
15588        n = t.a,
15589        r = t.b,
15590        o = t.transposeA,
15591        a = void 0 !== o && o,
15592        i = t.transposeB,
15593        s = void 0 !== i && i,
15594        u = t.bias,
15595        c = t.activation,
15596        l = void 0 === c ? "linear" : c,
15597        h = t.preluActivationWeights;
15598
15599    if (!1 === Xh(Lt.state.gradientDepth, l)) {
15600      var f = pl(n, r, a, s);
15601      return null != u && (f = po(f, u)), Qh(f, l, h);
15602    }
15603
15604    var d = mn(n, "a", "fused matMul"),
15605        p = mn(r, "b", "fused matMul");
15606    e = Nt(d, p), d = e[0], p = e[1];
15607    var v = a ? d.shape[d.rank - 2] : d.shape[d.rank - 1],
15608        m = s ? p.shape[p.rank - 1] : p.shape[p.rank - 2],
15609        g = a ? d.shape[d.rank - 1] : d.shape[d.rank - 2],
15610        y = s ? p.shape[p.rank - 2] : p.shape[p.rank - 1],
15611        x = d.shape.slice(0, -2),
15612        b = p.shape.slice(0, -2),
15613        w = k(x),
15614        E = k(b);
15615    C(d.rank >= 2 && p.rank >= 2 && d.rank === p.rank, function () {
15616      return "Error in fused matMul: inputs must have the same rank of at least 2, got ranks " + d.rank + " and " + p.rank + ".";
15617    }), C(S(x, b), function () {
15618      return "Error in fused matMul: outer dimensions (" + x + ") and (" + b + ") of Tensors with shapes " + d.shape + " and " + p.shape + " must match.";
15619    }), C(v === m, function () {
15620      return "Error in fused matMul: inner shapes (" + v + ") and (" + m + ") of Tensors with shapes " + d.shape + " and " + p.shape + " and transposeA=" + a + " and transposeB=" + s + " must match.";
15621    });
15622    var R,
15623        I,
15624        A = d.shape.slice(0, -2).concat([g, y]),
15625        T = a ? d.as3D(w, v, g) : d.as3D(w, g, v),
15626        D = s ? p.as3D(E, y, m) : p.as3D(E, m, y);
15627    null != u && Fr(A, (R = Nt(R = mn(u, "bias", "fused matMul"), d)[0]).shape), null != h && (I = mn(h, "prelu weights", "fused matMul"));
15628    var N = {
15629      a: T,
15630      b: D
15631    };
15632    null != u && (N.bias = R), null != h && (N.preluActivationWeights = I);
15633    var F = [T, D];
15634    return Lt.runKernelFunc(function (t, e) {
15635      var n = t.fusedBatchMatMul({
15636        a: T,
15637        b: D,
15638        transposeA: a,
15639        transposeB: s,
15640        bias: R,
15641        activation: l,
15642        preluActivationWeights: I
15643      });
15644      return e([T, D, n]), n;
15645    }, N, function (t, e) {
15646      var n = e[0],
15647          r = e[1],
15648          o = e[2],
15649          i = Yh(t, o, l),
15650          c = {};
15651      return null != u && (c = {
15652        bias: function () {
15653          return $h(R, i);
15654        }
15655      }), a || s ? !a && s ? Object.assign({
15656        a: function () {
15657          return i.matMul(r, !1, !1);
15658        },
15659        b: function () {
15660          return i.matMul(n, !0, !1);
15661        }
15662      }, c) : a && !s ? Object.assign({
15663        a: function () {
15664          return r.matMul(i, !1, !0);
15665        },
15666        b: function () {
15667          return n.matMul(i, !1, !1);
15668        }
15669      }, c) : Object.assign({
15670        a: function () {
15671          return r.matMul(i, !0, !0);
15672        },
15673        b: function () {
15674          return i.matMul(n, !0, !0);
15675        }
15676      }, c) : Object.assign({
15677        a: function () {
15678          return i.matMul(r, !1, !0);
15679        },
15680        b: function () {
15681          return n.matMul(i, !0, !1);
15682        }
15683      }, c);
15684    }, "_FusedMatMul", {
15685      transposeA: a,
15686      transposeB: s,
15687      activation: l
15688    }, F, [!0]).reshape(A);
15689  }
15690}),
15691    Zh = An({
15692  fusedConv2d_: function (t) {
15693    var e = t.x,
15694        n = t.filter,
15695        r = t.strides,
15696        o = t.pad,
15697        a = t.dataFormat,
15698        i = void 0 === a ? "NHWC" : a,
15699        s = t.dilations,
15700        u = void 0 === s ? [1, 1] : s,
15701        c = t.dimRoundingMode,
15702        l = t.bias,
15703        h = t.activation,
15704        f = void 0 === h ? "linear" : h,
15705        d = t.preluActivationWeights;
15706
15707    if (f = f || "linear", !1 === Xh(Lt.state.gradientDepth, f)) {
15708      var p = ol(e, n, r, o, i, u, c);
15709      return null != l && (p = po(p, l)), Qh(p, f, d);
15710    }
15711
15712    var v = mn(e, "x", "conv2d"),
15713        m = mn(n, "filter", "conv2d"),
15714        g = v,
15715        y = !1;
15716    3 === v.rank && (y = !0, g = v.as4D(1, v.shape[0], v.shape[1], v.shape[2])), C(4 === g.rank, function () {
15717      return "Error in fused conv2d: input must be rank 4, but got rank " + g.rank + ".";
15718    }), C(4 === m.rank, function () {
15719      return "Error in fused conv2d: filter must be rank 4, but got rank " + m.rank + ".";
15720    }), null != c && C(A(o), function () {
15721      return "Error in fused conv2d: pad must be an integer when using, dimRoundingMode " + c + " but got pad " + o + ".";
15722    }), C(g.shape[3] === m.shape[2], function () {
15723      return "Error in conv2d: depth of input (" + g.shape[3] + ") must match input depth for filter " + m.shape[2] + ".";
15724    }), C(ya(r, u), function () {
15725      return "Error in conv2D: Either strides or dilations must be 1. Got strides " + r + " and dilations '" + u + "'";
15726    }), C("NHWC" === i, function () {
15727      return "Error in conv2d: got dataFormat of " + i + " but only NHWC is currently supported.";
15728    });
15729    var x,
15730        b,
15731        w = la(g.shape, m.shape, r, u, o, c);
15732    null != l && (x = Nt(x = mn(l, "bias", "fused conv2d"), v)[0], Fr(w.outShape, x.shape)), null != d && (b = mn(d, "prelu weights", "fused conv2d"));
15733    var E = {
15734      x: g,
15735      filter: m
15736    };
15737    null != l && (E.bias = x), null != d && (E.preluActivationWeights = b);
15738    var R = [m, g],
15739        I = Lt.runKernelFunc(function (t, e) {
15740      var n = t.fusedConv2d({
15741        input: g,
15742        filter: m,
15743        convInfo: w,
15744        bias: x,
15745        activation: f,
15746        preluActivationWeights: b
15747      });
15748      return e([m, g, n]), n;
15749    }, E, function (t, e) {
15750      var n = e,
15751          a = n[0],
15752          i = n[1],
15753          s = n[2],
15754          c = Yh(t, s, f);
15755      C(ga(u), function () {
15756        return "Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '" + u + "'";
15757      });
15758      var h = {};
15759      return null != l && (h = {
15760        bias: function () {
15761          return $h(x, c);
15762        }
15763      }), Object.assign({
15764        x: function () {
15765          return sl(i.shape, c, a, r, o);
15766        },
15767        filter: function () {
15768          return il(i, c, a.shape, r, o);
15769        }
15770      }, h);
15771    }, "FusedConv2D", {
15772      convInfo: w,
15773      activation: f
15774    }, R, [!0]);
15775    return y ? I.as3D(I.shape[1], I.shape[2], I.shape[3]) : I;
15776  }
15777}),
15778    tf = An({
15779  fusedDepthwiseConv2d_: function (t) {
15780    var e = t.x,
15781        n = t.filter,
15782        r = t.strides,
15783        o = t.pad,
15784        a = t.dataFormat,
15785        i = void 0 === a ? "NHWC" : a,
15786        s = t.dilations,
15787        u = void 0 === s ? [1, 1] : s,
15788        c = t.dimRoundingMode,
15789        l = t.bias,
15790        h = t.activation,
15791        f = void 0 === h ? "linear" : h,
15792        d = t.preluActivationWeights;
15793
15794    if (!1 === Xh(Lt.state.gradientDepth, f)) {
15795      var p = ul(e, n, r, o, i, u, c);
15796      return null != l && (p = po(p, l)), Qh(p, f, d);
15797    }
15798
15799    var v = mn(e, "x", "depthwiseConv2d"),
15800        m = mn(n, "filter", "depthwiseConv2d"),
15801        g = v,
15802        y = !1;
15803    3 === v.rank && (y = !0, g = v.as4D(1, v.shape[0], v.shape[1], v.shape[2])), C(4 === g.rank, function () {
15804      return "Error in fused depthwiseConv2d: input must be rank 4, but got rank " + g.rank + ".";
15805    }), C(4 === m.rank, function () {
15806      return "Error in fused depthwiseConv2d: filter must be rank 4, but got rank " + m.rank + ".";
15807    }), C(g.shape[3] === m.shape[2], function () {
15808      return "Error in fused depthwiseConv2d: number of input channels (" + g.shape[3] + ") must match the inChannels dimension in filter " + m.shape[2] + ".";
15809    }), null == u && (u = [1, 1]), C(ya(r, u), function () {
15810      return "Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides " + r + " and dilations '" + u + "'";
15811    }), null != c && C(A(o), function () {
15812      return "Error in fused depthwiseConv2d: pad must be an integer when using dimRoundingMode " + c + " but got pad " + o + ".";
15813    });
15814    var x,
15815        b,
15816        w = la(g.shape, m.shape, r, u, o, c, !0);
15817    null != l && (x = Nt(x = mn(l, "bias", "fused conv2d"), v)[0], Fr(w.outShape, x.shape)), null != d && (b = mn(d, "prelu weights", "fused depthwiseConv2d"));
15818    var E = {
15819      x: g,
15820      filter: m
15821    };
15822    null != l && (E.bias = x), null != d && (E.preluActivationWeights = b);
15823    var R = [m, g],
15824        I = Lt.runKernelFunc(function (t, e) {
15825      var n = t.fusedDepthwiseConv2D({
15826        input: g,
15827        filter: m,
15828        convInfo: w,
15829        bias: x,
15830        activation: f,
15831        preluActivationWeights: b
15832      });
15833      return e([m, g, n]), n;
15834    }, E, function (t, e) {
15835      C(ga(u), function () {
15836        return "Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '" + u + "'";
15837      });
15838      var n = e[0],
15839          r = e[1],
15840          o = e[2],
15841          a = Yh(t, o, f),
15842          i = {};
15843      return null != l && (i = {
15844        bias: function () {
15845          return $h(x, a);
15846        }
15847      }), Object.assign({
15848        x: function () {
15849          return cl(r.shape, a, n, w);
15850        },
15851        filter: function () {
15852          return ll(r, a, n.shape, w);
15853        }
15854      }, i);
15855    }, "FusedDepthwiseConv2D", {
15856      convInfo: w,
15857      activation: f
15858    }, R, [!0]);
15859    return y ? I.as3D(I.shape[1], I.shape[2], I.shape[3]) : I;
15860  }
15861}),
15862    ef = Object.freeze({
15863  matMul: Jh,
15864  conv2d: Zh,
15865  depthwiseConv2d: tf
15866}),
15867    nf = Object.freeze({
15868  image: jh,
15869  linalg: Lh,
15870  losses: _h,
15871  spectral: hh,
15872  fused: ef,
15873  signal: wh,
15874  broadcastTo: Xu,
15875  clone: Yu,
15876  div: _o,
15877  divNoNan: nc,
15878  eye: oc,
15879  multinomial: ac,
15880  oneHot: ic,
15881  rand: sc,
15882  randomGamma: gc,
15883  randomNormal: yc,
15884  randomUniform: xc,
15885  square: bc,
15886  squaredDifference: wc,
15887  tile: rc,
15888  truncatedNormal: Cc,
15889  conv1d: rl,
15890  conv2d: ol,
15891  conv3d: al,
15892  depthwiseConv2d: ul,
15893  separableConv2d: hl,
15894  conv2dTranspose: fl,
15895  conv3dTranspose: dl,
15896  op: An,
15897  batchNormalization2d: Tc,
15898  batchNormalization3d: Dc,
15899  batchNormalization4d: Nc,
15900  batchNormalization: Fc,
15901  batchNorm: _c,
15902  batchNorm2d: Oc,
15903  batchNorm3d: Mc,
15904  batchNorm4d: Bc,
15905  booleanMaskAsync: Zc,
15906  complex: Tn,
15907  real: Dn,
15908  imag: Nn,
15909  concat: Yn,
15910  concat1d: $n,
15911  concat2d: Qn,
15912  concat3d: Jn,
15913  concat4d: Zn,
15914  split: tr,
15915  matMul: pl,
15916  dot: vl,
15917  outerProduct: ml,
15918  reverse: gl,
15919  reverse1d: yl,
15920  reverse2d: xl,
15921  reverse3d: bl,
15922  reverse4d: wl,
15923  maxPool: Rl,
15924  avgPool: Il,
15925  pool: kl,
15926  maxPool3d: Sl,
15927  avgPool3d: Al,
15928  slice: Tl,
15929  slice1d: Dl,
15930  slice2d: Nl,
15931  slice3d: Fl,
15932  slice4d: _l,
15933  abs: _r,
15934  acos: Or,
15935  acosh: Mr,
15936  asin: Br,
15937  asinh: Pr,
15938  atan: Lr,
15939  atanh: Wr,
15940  ceil: Ur,
15941  clipByValue: Vr,
15942  cos: zr,
15943  cosh: Gr,
15944  erf: Hr,
15945  exp: qr,
15946  expm1: Kr,
15947  floor: jr,
15948  log: Xr,
15949  log1p: Yr,
15950  logSigmoid: $r,
15951  neg: Qr,
15952  reciprocal: Jr,
15953  round: Zr,
15954  rsqrt: to,
15955  sigmoid: eo,
15956  sign: no,
15957  isNaN: ro,
15958  isInf: oo,
15959  isFinite: ao,
15960  sin: io,
15961  sinh: so,
15962  softplus: uo,
15963  sqrt: co,
15964  step: lo,
15965  tan: ho,
15966  tanh: fo,
15967  all: Ml,
15968  any: Bl,
15969  argMax: Pl,
15970  argMin: Ll,
15971  logSumExp: Wl,
15972  max: Ul,
15973  mean: Vl,
15974  min: zl,
15975  moments: Gl,
15976  sum: Hl,
15977  prod: ql,
15978  equal: Pc,
15979  equalStrict: Lc,
15980  greater: Wc,
15981  greaterEqual: Uc,
15982  greaterEqualStrict: Vc,
15983  greaterStrict: zc,
15984  less: Gc,
15985  lessEqual: Hc,
15986  lessEqualStrict: qc,
15987  lessStrict: Kc,
15988  notEqual: jc,
15989  notEqualStrict: Xc,
15990  add: po,
15991  addN: vo,
15992  addStrict: mo,
15993  atan2: go,
15994  divStrict: yo,
15995  floorDiv: xo,
15996  maximum: bo,
15997  maximumStrict: wo,
15998  minimum: Co,
15999  minimumStrict: Eo,
16000  mod: Ro,
16001  modStrict: Io,
16002  mul: ko,
16003  mulStrict: So,
16004  pow: Ao,
16005  powStrict: To,
16006  squaredDifferenceStrict: Do,
16007  sub: No,
16008  subStrict: Fo,
16009  elu: Kl,
16010  leakyRelu: jl,
16011  prelu: Xl,
16012  relu: Yl,
16013  relu6: $l,
16014  selu: Ql,
16015  logicalAnd: $u,
16016  logicalNot: Qu,
16017  logicalOr: Ju,
16018  logicalXor: Zu,
16019  where: tc,
16020  whereAsync: ec,
16021  buffer: er,
16022  print: nr,
16023  batchToSpaceND: rr,
16024  cast: or,
16025  cumsum: ar,
16026  depthToSpace: ir,
16027  expandDims: sr,
16028  pad: ur,
16029  pad1d: cr,
16030  pad2d: lr,
16031  pad3d: hr,
16032  pad4d: fr,
16033  reshape: dr,
16034  spaceToBatchND: pr,
16035  squeeze: vr,
16036  stack: mr,
16037  unstack: gr,
16038  setdiff1dAsync: yr,
16039  fill: Hn,
16040  linspace: qn,
16041  ones: zn,
16042  range: Kn,
16043  scalar: On,
16044  tensor: Fn,
16045  tensor1d: Mn,
16046  tensor2d: Bn,
16047  tensor3d: Pn,
16048  tensor4d: Ln,
16049  tensor5d: Wn,
16050  tensor6d: Un,
16051  variable: Vn,
16052  zeros: Gn,
16053  onesLike: jn,
16054  zerosLike: Xn,
16055  transpose: Jl,
16056  softmax: ra,
16057  logSoftmax: oa,
16058  localResponseNormalization: Zl,
16059  norm: th,
16060  gather: Qc,
16061  unsortedSegmentSum: Jc,
16062  basicLSTMCell: eh,
16063  multiRNNCell: nh,
16064  movingAverage: rh,
16065  stridedSlice: oh,
16066  topk: ah,
16067  scatterND: ih,
16068  fft: sh,
16069  ifft: uh,
16070  rfft: ch,
16071  irfft: lh,
16072  sparseToDense: fh,
16073  gatherND: dh,
16074  diag: ph,
16075  dropout: vh,
16076  hannWindow: gh,
16077  hammingWindow: yh,
16078  frame: xh,
16079  stft: bh,
16080  inTopKAsync: Eh
16081});
16082exports.fused = ef;
16083
16084function rf(t, e) {
16085  Array.isArray(t) || (t = [t]), t.forEach(function (t) {
16086    null != t && C("complex64" !== t.dtype, function () {
16087      return e + " does not support complex64 tensors.";
16088    });
16089  });
16090}
16091
16092function of(t, e, n, r) {
16093  if ("linear" === n) return t.linear(e);
16094  if ("relu" === n) return t.relu(e);
16095  if ("elu" === n) return t.elu(e);
16096  if ("relu6" === n) return t.relu6(e);
16097  if ("prelu" === n) return t.prelu(e, r);
16098  throw new Error("Activation " + n + " has not been implemented for the CPU backend.");
16099}
16100
16101var af = function (t) {
16102  function o() {
16103    var e = t.call(this) || this;
16104    return e.blockSize = 48, e.firstUse = !0, e.data = new aa(e, Lt), e;
16105  }
16106
16107  return e(o, t), o.prototype.write = function (t, e, n) {
16108    this.firstUse && (this.firstUse = !1, i().get("IS_NODE") && dn("\n============================\nHi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require('@tensorflow/tfjs-node'); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.\n============================"));
16109    var r = {};
16110    return this.data.set(r, {
16111      values: t,
16112      dtype: n
16113    }), r;
16114  }, o.prototype.move = function (t, e, n, r) {
16115    this.data.set(t, {
16116      values: e,
16117      dtype: r
16118    });
16119  }, o.prototype.numDataIds = function () {
16120    return this.data.numDataIds();
16121  }, o.prototype.read = function (t) {
16122    return n(this, void 0, void 0, function () {
16123      return r(this, function (e) {
16124        return [2, this.readSync(t)];
16125      });
16126    });
16127  }, o.prototype.readSync = function (t) {
16128    var e = this.data.get(t),
16129        n = e.dtype,
16130        r = e.complexTensors;
16131    return "complex64" === n ? Ra(this.readSync(r.real.dataId), this.readSync(r.imag.dataId)) : this.data.get(t).values;
16132  }, o.prototype.bufferSync = function (t) {
16133    var e = this.readSync(t.dataId),
16134        n = e;
16135    if ("string" === t.dtype) try {
16136      n = e.map(function (t) {
16137        return ot(t);
16138      });
16139    } catch (t) {
16140      throw new Error("Failed to decode encoded string bytes into utf-8");
16141    }
16142    return er(t.shape, t.dtype, n);
16143  }, o.prototype.makeOutput = function (t, e, n) {
16144    var r = this.write(t, e, n);
16145    return Lt.makeTensorFromDataId(r, e, n, this);
16146  }, o.prototype.disposeData = function (t) {
16147    if (this.data.has(t)) {
16148      var e = this.data.get(t).complexTensors;
16149      null != e && (e.real.dispose(), e.imag.dispose()), this.data.delete(t);
16150    }
16151  }, o.prototype.time = function (t) {
16152    return n(this, void 0, void 0, function () {
16153      var e;
16154      return r(this, function (n) {
16155        return e = et(), t(), [2, {
16156          kernelMs: et() - e
16157        }];
16158      });
16159    });
16160  }, o.prototype.memory = function () {
16161    return {
16162      unreliable: !0,
16163      reasons: ["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]
16164    };
16165  }, o.prototype.complex = function (t, e) {
16166    var n = this.makeOutput(null, t.shape, "complex64");
16167    return this.data.get(n.dataId).complexTensors = {
16168      real: Lt.keep(t.clone()),
16169      imag: Lt.keep(e.clone())
16170    }, n;
16171  }, o.prototype.real = function (t) {
16172    return this.data.get(t.dataId).complexTensors.real.clone();
16173  }, o.prototype.imag = function (t) {
16174    return this.data.get(t.dataId).complexTensors.imag.clone();
16175  }, o.prototype.slice = function (t, e, n) {
16176    if (rf(t, "slice"), jo(t.shape, e, n)) {
16177      var r = Xo(e, t.strides),
16178          o = k(n);
16179      return Fn(this.readSync(t.dataId).subarray(r, r + o), n, t.dtype);
16180    }
16181
16182    for (var a = er(n, t.dtype), i = this.bufferSync(t), s = 0; s < a.size; ++s) {
16183      var u = a.indexToLoc(s).map(function (t, n) {
16184        return t + e[n];
16185      });
16186      a.values[s] = i.get.apply(i, u);
16187    }
16188
16189    return a.toTensor();
16190  }, o.prototype.stridedSlice = function (t, e, n, r) {
16191    rf(t, "stridedSlice");
16192    var o = Ho(e, n, r);
16193    if (o.some(function (t) {
16194      return 0 === t;
16195    })) return Fn([], o);
16196
16197    for (var a = er(o, t.dtype), i = this.bufferSync(t), s = 0; s < a.size; s++) {
16198      for (var u = a.indexToLoc(s), c = new Array(u.length), l = 0; l < c.length; l++) c[l] = u[l] * r[l] + e[l];
16199
16200      a.set.apply(a, [i.get.apply(i, c)].concat(u));
16201    }
16202
16203    return a.toTensor();
16204  }, o.prototype.diag = function (t) {
16205    for (var e = this.readSync(t.dataId), n = er([t.size, t.size], t.dtype), r = n.values, o = 0; o < e.length; o++) r[o * t.size + o] = e[o];
16206
16207    return n.toTensor();
16208  }, o.prototype.unstack = function (t, e) {
16209    for (var n = t.shape[e], r = new Array(t.rank - 1), o = 0, a = 0; a < t.rank; a++) a !== e && (r[o++] = t.shape[a]);
16210
16211    var i = new Array(t.rank).fill(0),
16212        s = t.shape.slice();
16213    s[e] = 1;
16214    var u = new Array(n);
16215
16216    for (a = 0; a < u.length; a++) i[e] = a, u[a] = this.slice(t, i, s).reshape(r);
16217
16218    return u;
16219  }, o.prototype.reverse = function (t, e) {
16220    rf(t, "reverse");
16221
16222    for (var n = er(t.shape, t.dtype), r = this.bufferSync(t), o = function (o) {
16223      var a = n.indexToLoc(o),
16224          i = a.slice();
16225      e.forEach(function (e) {
16226        return i[e] = t.shape[e] - 1 - i[e];
16227      }), n.set.apply(n, [r.get.apply(r, i)].concat(a));
16228    }, a = 0; a < n.size; a++) o(a);
16229
16230    return n.toTensor();
16231  }, o.prototype.concat = function (t, e) {
16232    var n = this;
16233
16234    if ("complex64" === t[0].dtype) {
16235      var r = t.map(function (t) {
16236        return Dn(t);
16237      }),
16238          o = t.map(function (t) {
16239        return Nn(t);
16240      });
16241      return Tn(this.concat(r, e), this.concat(o, e));
16242    }
16243
16244    var a = t.map(function (t) {
16245      var n = k(t.shape.slice(e));
16246      return t.as2D(-1, n);
16247    }),
16248        i = Sn(a.map(function (t) {
16249      return t.shape;
16250    }), 1),
16251        s = er(i, t[0].dtype).values;
16252
16253    if (1 === a[0].shape[0]) {
16254      var u = 0;
16255      a.forEach(function (t) {
16256        s.set(n.readSync(t.dataId), u), u += t.size;
16257      });
16258    } else {
16259      var c = 0;
16260      a.forEach(function (t) {
16261        for (var e = n.readSync(t.dataId), r = 0, o = 0; o < t.shape[0]; ++o) for (var a = o * i[1] + c, u = 0; u < t.shape[1]; ++u) s[a + u] = e[r++];
16262
16263        c += t.shape[1];
16264      });
16265    }
16266
16267    var l = Sn(t.map(function (t) {
16268      return t.shape;
16269    }), e);
16270    return Fn(s, l, t[0].dtype);
16271  }, o.prototype.neg = function (t) {
16272    return rf(t, "neg"), this.multiply(On(-1), t);
16273  }, o.prototype.add = function (t, e) {
16274    return "complex64" === t.dtype || "complex64" === e.dtype ? this.broadcastedBinaryComplexOp(t.cast("complex64"), e.cast("complex64"), function (t, e, n, r) {
16275      return {
16276        real: t + n,
16277        imag: e + r
16278      };
16279    }) : this.broadcastedBinaryOp(t, e, Tt(t.dtype, e.dtype), function (t, e) {
16280      return t + e;
16281    });
16282  }, o.prototype.addN = function (t) {
16283    var e = this;
16284    rf(t, "addN");
16285
16286    for (var n = t.map(function (t) {
16287      return e.readSync(t.dataId);
16288    }), r = er(t[0].shape, t[0].dtype), o = r.values, a = 0; a < t.length; a++) for (var i = n[a], s = 0; s < o.length; s++) o[s] += i[s];
16289
16290    return r.toTensor();
16291  }, o.prototype.softmax = function (t, e) {
16292    var n = O([e], t.shape),
16293        r = this.max(t, n),
16294        o = wn(r.shape, n),
16295        a = this.subtract(t, r.reshape(o)),
16296        i = this.exp(a),
16297        s = this.sum(i, n).reshape(o);
16298    return _o(i, s);
16299  }, o.prototype.subtract = function (t, e) {
16300    return "complex64" === t.dtype || "complex64" === e.dtype ? this.broadcastedBinaryComplexOp(t.cast("complex64"), e.cast("complex64"), function (t, e, n, r) {
16301      return {
16302        real: t - n,
16303        imag: e - r
16304      };
16305    }) : this.broadcastedBinaryOp(t, e, Tt(t.dtype, e.dtype), function (t, e) {
16306      return t - e;
16307    });
16308  }, o.prototype.pow = function (t, e) {
16309    return rf([t, e], "pow"), this.broadcastedBinaryOp(t, e, t.dtype, function (t, e) {
16310      return Math.pow(t, e);
16311    });
16312  }, o.prototype.batchMatMul = function (t, e, n, r) {
16313    rf([t, e], "matMul");
16314
16315    for (var o = n ? t.shape[1] : t.shape[2], a = n ? t.shape[2] : t.shape[1], i = r ? e.shape[1] : e.shape[2], s = t.shape[0], u = this.readSync(t.dataId), c = this.readSync(e.dataId), l = n ? [t.strides[0], 1, t.strides[1]] : [t.strides[0], t.strides[1], 1], h = l[0], f = l[1], d = l[2], p = r ? [1, e.strides[1], e.strides[0]] : [e.strides[1], 1, e.strides[0]], v = p[0], m = p[1], g = p[2], y = a * i, x = er([s, a, i], t.dtype), b = x.values, w = this.blockSize, C = 0; C < s; C++) for (var E = 0; E < a;
16315 E += w) for (var R = 0; R < i; R += w) for (var I = 0; I < o; I += w) for (var k = Math.min(E + w, a), S = Math.min(R + w, i), A = Math.min(I + w, o), T = E; T < k; T++) for (var D = R; D < S; D++) {
16316      for (var N = 0, F = I; F < A; F++) N += u[C * h + T * f + F * d] * c[F * v + D * m + C * g];
16317
16318      b[C * y + (T * i + D)] += N;
16319    }
16320
16321    return x.toTensor();
16322  }, o.prototype.fusedBatchMatMul = function (t) {
16323    var e = t.a,
16324        n = t.b,
16325        r = t.transposeA,
16326        o = t.transposeB,
16327        a = t.bias,
16328        i = t.activation,
16329        s = t.preluActivationWeights,
16330        u = this.batchMatMul(e, n, r, o);
16331    return a && (u = this.add(u, a)), i && (u = of(this, u, i, s)), u;
16332  }, o.prototype.multiply = function (t, e) {
16333    return "complex64" === t.dtype || "complex64" === e.dtype ? this.broadcastedBinaryComplexOp(t.cast("complex64"), e.cast("complex64"), function (t, e, n, r) {
16334      return {
16335        real: t * n - e * r,
16336        imag: t * r + e * n
16337      };
16338    }) : this.broadcastedBinaryOp(t, e, Tt(t.dtype, e.dtype), function (t, e) {
16339      return t * e;
16340    });
16341  }, o.prototype.floorDiv = function (t, e) {
16342    rf([t, e], "floorDiv");
16343    return this.broadcastedBinaryOp(t, e, "int32", function (t, e) {
16344      return Math.floor(t / e);
16345    });
16346  }, o.prototype.sum = function (t, e) {
16347    rf(t, "sum"), Cn("sum", e, t.rank);
16348
16349    for (var n = bn(t.shape, e), r = n[0], o = n[1], a = Gn(r, Tt(t.dtype, "int32")), i = k(o), s = this.readSync(a.dataId), u = this.readSync(t.dataId), c = 0; c < s.length; ++c) {
16350      for (var l = c * i, h = 0, f = 0; f < i; ++f) h += u[l + f];
16351
16352      s[c] = h;
16353    }
16354
16355    return a;
16356  }, o.prototype.prod = function (t, e) {
16357    rf(t, "sum");
16358
16359    for (var n = bn(t.shape, e), r = n[0], o = n[1], a = Gn(r, Tt(t.dtype, "int32")), i = k(o), s = this.readSync(a.dataId), u = this.readSync(t.dataId), c = 0; c < s.length; ++c) {
16360      for (var l = c * i, h = 1, f = 0; f < i; ++f) h *= u[l + f];
16361
16362      s[c] = h;
16363    }
16364
16365    return a;
16366  }, o.prototype.unsortedSegmentSum = function (t, e, n) {
16367    rf(t, "unsortedSegmentSum");
16368
16369    for (var r = [], o = t.rank - e.rank, a = 0; a < o; ++a) e = e.expandDims(a + 1);
16370
16371    for (a = 0; a < n; ++a) {
16372      var i = On(a, "int32"),
16373          s = Pc(i, e).asType("float32").mul(t).sum(0);
16374      r.push(s);
16375    }
16376
16377    return mr(r);
16378  }, o.prototype.argMin = function (t, e) {
16379    rf(t, "argMin");
16380    var n = [e];
16381    Cn("argMin", n, t.rank);
16382
16383    for (var r = bn(t.shape, n), o = r[0], a = r[1], i = Gn(o, "int32"), s = k(a), u = this.readSync(i.dataId), c = this.readSync(t.dataId), l = 0; l < u.length; ++l) {
16384      for (var h = l * s, f = c[h], d = 0, p = 0; p < s; ++p) {
16385        var v = c[h + p];
16386        v < f && (f = v, d = p);
16387      }
16388
16389      u[l] = d;
16390    }
16391
16392    return i;
16393  }, o.prototype.argMax = function (t, e) {
16394    rf(t, "argMax");
16395    var n = [e];
16396    Cn("argMax", n, t.rank);
16397
16398    for (var r = bn(t.shape, n), o = r[0], a = r[1], i = Gn(o, "int32"), s = k(a), u = this.readSync(i.dataId), c = this.readSync(t.dataId), l = 0; l < u.length; ++l) {
16399      for (var h = l * s, f = c[h], d = 0, p = 0; p < s; ++p) {
16400        var v = c[h + p];
16401        v > f && (f = v, d = p);
16402      }
16403
16404      u[l] = d;
16405    }
16406
16407    return i;
16408  }, o.prototype.cumsum = function (t, e, n, r) {
16409    if (rf(t, "cumsum"), e !== t.rank - 1) throw new Error("backend.cumsum in CPU expects an inner-most axis=" + (t.rank - 1) + " but got axis=" + e);
16410
16411    for (var o = Tt(t.dtype, "int32"), a = Gn(t.shape, o), i = this.readSync(a.dataId), s = this.readSync(t.dataId), u = t.shape[t.rank - 1], c = r ? function (t, e) {
16412      return t + u - e - 1;
16413    } : function (t, e) {
16414      return t + e;
16415    }, l = 0; l < s.length; l += u) for (var h = 0; h < u; h++) {
16416      var f = c(l, h);
16417      if (0 === h) i[f] = n ? 0 : s[f];else {
16418        var d = c(l, h - 1);
16419        i[f] = n ? s[d] + i[d] : s[f] + i[d];
16420      }
16421    }
16422
16423    return a;
16424  }, o.prototype.equal = function (t, e) {
16425    return rf([t, e], "equal"), this.broadcastedBinaryOp(t, e, "bool", function (t, e) {
16426      return t === e ? 1 : 0;
16427    });
16428  }, o.prototype.notEqual = function (t, e) {
16429    return rf([t, e], "notEqual"), this.broadcastedBinaryOp(t, e, "bool", function (t, e) {
16430      return t !== e ? 1 : 0;
16431    });
16432  }, o.prototype.less = function (t, e) {
16433    return rf([t, e], "less"), this.broadcastedBinaryOp(t, e, "bool", function (t, e) {
16434      return t < e ? 1 : 0;
16435    });
16436  }, o.prototype.lessEqual = function (t, e) {
16437    return rf([t, e], "lessEqual"), this.broadcastedBinaryOp(t, e, "bool", function (t, e) {
16438      return t <= e ? 1 : 0;
16439    });
16440  }, o.prototype.greater = function (t, e) {
16441    return rf([t, e], "greater"), this.broadcastedBinaryOp(t, e, "bool", function (t, e) {
16442      return t > e ? 1 : 0;
16443    });
16444  }, o.prototype.greaterEqual = function (t, e) {
16445    return rf([t, e], "greaterEqual"), this.broadcastedBinaryOp(t, e, "bool", function (t, e) {
16446      return t >= e ? 1 : 0;
16447    });
16448  }, o.prototype.logicalNot = function (t) {
16449    rf(t, "logicalNot");
16450
16451    for (var e = this.readSync(t.dataId), n = new Uint8Array(e.length), r = 0; r < e.length; ++r) n[r] = e[r] ? 0 : 1;
16452
16453    return this.makeOutput(n, t.shape, "bool");
16454  }, o.prototype.logicalAnd = function (t, e) {
16455    return rf([t, e], "logicalAnd"), this.broadcastedBinaryOp(t, e, "bool", function (t, e) {
16456      return t && e;
16457    });
16458  }, o.prototype.logicalOr = function (t, e) {
16459    return rf([t, e], "logicalOr"), this.broadcastedBinaryOp(t, e, "bool", function (t, e) {
16460      return t || e;
16461    });
16462  }, o.prototype.select = function (t, e, n) {
16463    rf([t, e, n], "select");
16464
16465    for (var r = this.readSync(t.dataId), o = this.readSync(e.dataId), a = this.readSync(n.dataId), i = Gn(e.shape, Tt(e.dtype, n.dtype)), s = this.readSync(i.dataId), u = 0, c = 0 === t.rank || t.rank > 1 || 1 === e.rank ? 1 : k(e.shape.slice(1)), l = 0; l < r.length; l++) for (var h = 0; h < c; h++) 1 === r[l] ? s[u++] = o[l] : s[u++] = a[l];
16466
16467    return i;
16468  }, o.prototype.where = function (t) {
16469    rf([t], "where");
16470    var e = this.readSync(t.dataId);
16471    return Wa(t.shape, e);
16472  }, o.prototype.topk = function (t, e, n) {
16473    return rf(t, "topk"), La(this.readSync(t.dataId), t.shape, t.dtype, e);
16474  }, o.prototype.min = function (t, e) {
16475    rf(t, "min"), Cn("min", e, t.rank);
16476
16477    for (var n = bn(t.shape, e), r = n[0], o = n[1], a = Gn(r, t.dtype), i = k(o), s = this.readSync(a.dataId), u = this.readSync(t.dataId), c = 0; c < s.length; ++c) {
16478      for (var l = c * i, h = u[l], f = 0; f < i; ++f) {
16479        var d = u[l + f];
16480        d < h && (h = d);
16481      }
16482
16483      s[c] = h;
16484    }
16485
16486    return a;
16487  }, o.prototype.minimum = function (t, e) {
16488    return rf([t, e], "minimum"), this.broadcastedBinaryOp(t, e, t.dtype, function (t, e) {
16489      return Math.min(t, e);
16490    });
16491  }, o.prototype.mod = function (t, e) {
16492    return rf([t, e], "mod"), this.broadcastedBinaryOp(t, e, t.dtype, function (t, e) {
16493      var n = t % e;
16494      return t < 0 && e < 0 || t >= 0 && e >= 0 ? n : (n + e) % e;
16495    });
16496  }, o.prototype.max = function (t, e) {
16497    rf(t, "max"), Cn("max", e, t.rank);
16498
16499    for (var n = bn(t.shape, e), r = n[0], o = n[1], a = Gn(r, t.dtype), i = k(o), s = this.readSync(a.dataId), u = this.readSync(t.dataId), c = 0; c < s.length; ++c) {
16500      for (var l = c * i, h = u[l], f = 0; f < i; ++f) {
16501        var d = u[l + f];
16502        d > h && (h = d);
16503      }
16504
16505      s[c] = h;
16506    }
16507
16508    return a;
16509  }, o.prototype.maximum = function (t, e) {
16510    return rf([t, e], "maximum"), this.broadcastedBinaryOp(t, e, t.dtype, function (t, e) {
16511      return Math.max(t, e);
16512    });
16513  }, o.prototype.all = function (t, e) {
16514    rf(t, "all"), Cn("all", e, t.rank);
16515
16516    for (var n = bn(t.shape, e), r = n[0], o = n[1], a = Gn(r, t.dtype), i = k(o), s = this.readSync(a.dataId), u = this.readSync(t.dataId), c = 0; c < s.length; ++c) {
16517      for (var l = c * i, h = u[l], f = 0; f < i; ++f) {
16518        var d = u[l + f];
16519        h = h && d;
16520      }
16521
16522      s[c] = h;
16523    }
16524
16525    return a;
16526  }, o.prototype.any = function (t, e) {
16527    rf(t, "any"), Cn("any", e, t.rank);
16528
16529    for (var n = bn(t.shape, e), r = n[0], o = n[1], a = Gn(r, t.dtype), i = k(o), s = this.readSync(a.dataId), u = this.readSync(t.dataId), c = 0; c < s.length; ++c) {
16530      for (var l = c * i, h = u[l], f = 0; f < i; ++f) {
16531        var d = u[l + f];
16532        h = h || d;
16533      }
16534
16535      s[c] = h;
16536    }
16537
16538    return a;
16539  }, o.prototype.squaredDifference = function (t, e) {
16540    return rf([t, e], "squaredDifference"), this.broadcastedBinaryOp(t, e, t.dtype, function (t, e) {
16541      var n = t - e;
16542      return n * n;
16543    });
16544  }, o.prototype.ceil = function (t) {
16545    rf(t, "ceil");
16546
16547    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) n[r] = Math.ceil(e[r]);
16548
16549    return this.makeOutput(n, t.shape, "float32");
16550  }, o.prototype.floor = function (t) {
16551    rf(t, "floor");
16552
16553    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) n[r] = Math.floor(e[r]);
16554
16555    return this.makeOutput(n, t.shape, "float32");
16556  }, o.prototype.sign = function (t) {
16557    rf(t, "x");
16558
16559    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) e[r] < 0 ? n[r] = -1 : e[r] > 0 ? n[r] = 1 : n[r] = 0;
16560
16561    return this.makeOutput(n, t.shape, "float32");
16562  }, o.prototype.isNaN = function (t) {
16563    rf(t, "x");
16564
16565    for (var e = this.readSync(t.dataId), n = new Uint8Array(e.length), r = 0; r < e.length; ++r) Number.isNaN(e[r]) && (n[r] = 1);
16566
16567    return this.makeOutput(n, t.shape, "bool");
16568  }, o.prototype.isInf = function (t) {
16569    rf(t, "x");
16570
16571    for (var e = this.readSync(t.dataId), n = new Uint8Array(e.length), r = 0; r < e.length; ++r) Math.abs(e[r]) === 1 / 0 && (n[r] = 1);
16572
16573    return this.makeOutput(n, t.shape, "bool");
16574  }, o.prototype.isFinite = function (t) {
16575    rf(t, "x");
16576
16577    for (var e = this.readSync(t.dataId), n = new Uint8Array(e.length), r = 0; r < e.length; ++r) Number.isFinite(e[r]) && (n[r] = 1);
16578
16579    return this.makeOutput(n, t.shape, "bool");
16580  }, o.prototype.round = function (t) {
16581    rf(t, "round");
16582
16583    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) {
16584      var o = Math.floor(e[r]);
16585      e[r] - o < .5 ? n[r] = Math.floor(e[r]) : e[r] - o > .5 ? n[r] = Math.ceil(e[r]) : n[r] = o % 2 == 0 ? o : o + 1;
16586    }
16587
16588    return this.makeOutput(n, t.shape, "float32");
16589  }, o.prototype.exp = function (t) {
16590    rf(t, "exp");
16591
16592    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) n[r] = Math.exp(e[r]);
16593
16594    return this.makeOutput(n, t.shape, "float32");
16595  }, o.prototype.expm1 = function (t) {
16596    rf(t, "expm1");
16597
16598    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) n[r] = Math.expm1(e[r]);
16599
16600    return this.makeOutput(n, t.shape, "float32");
16601  }, o.prototype.log = function (t) {
16602    rf(t, "log");
16603
16604    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) {
16605      var o = e[r];
16606      n[r] = Math.log(o);
16607    }
16608
16609    return this.makeOutput(n, t.shape, "float32");
16610  }, o.prototype.log1p = function (t) {
16611    rf(t, "log1p");
16612
16613    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) {
16614      var o = e[r];
16615      n[r] = Math.log1p(o);
16616    }
16617
16618    return this.makeOutput(n, t.shape, "float32");
16619  }, o.prototype.sqrt = function (t) {
16620    rf(t, "sqrt");
16621
16622    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) {
16623      var o = e[r];
16624      n[r] = Math.sqrt(o);
16625    }
16626
16627    return this.makeOutput(n, t.shape, "float32");
16628  }, o.prototype.rsqrt = function (t) {
16629    rf(t, "rsqrt");
16630
16631    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) {
16632      var o = e[r];
16633      n[r] = 1 / Math.sqrt(o);
16634    }
16635
16636    return this.makeOutput(n, t.shape, "float32");
16637  }, o.prototype.reciprocal = function (t) {
16638    rf(t, "reciprocal");
16639
16640    for (var e = this.readSync(t.dataId), n = new Float32Array(e.length), r = 0; r < e.length; ++r) n[r] = 1 / e[r];
16641
16642    return this.makeOutput(n, t.shape, "float32");
16643  }, o.prototype.linear = function (t) {
16644    return t;
16645  }, o.prototype.relu = function (t) {
16646    rf(t, "relu");
16647
16648    for (var e = Gn(t.shape, t.dtype), n = this.readSync(e.dataId), r = this.readSync(t.dataId), o = 0; o < r.length; ++o) n[o] = Math.max(0, r[o]);
16649
16650    return e;
16651  }, o.prototype.relu6 = function (t) {
16652    rf(t, "relu");
16653
16654    for (var e = Gn(t.shape, t.dtype), n = this.readSync(e.dataId), r = this.readSync(t.dataId), o = 0; o < r.length; ++o) n[o] = Math.min(Math.max(0, r[o]), 6);
16655
16656    return e;
16657  }, o.prototype.prelu = function (t, e) {
16658    return rf([t, e], "prelu"), this.broadcastedBinaryOp(t, e, t.dtype, function (t, e) {
16659      return t < 0 ? e * t : t;
16660    });
16661  }, o.prototype.elu = function (t) {
16662    rf(t, "elu");
16663
16664    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) {
16665      var o = n[r];
16666      e[r] = o >= 0 ? o : Math.exp(o) - 1;
16667    }
16668
16669    return this.makeOutput(e, t.shape, "float32");
16670  }, o.prototype.eluDer = function (t, e) {
16671    rf([t, e], "eluDer");
16672
16673    for (var n = new Float32Array(e.size), r = this.readSync(e.dataId), o = this.readSync(t.dataId), a = 0; a < r.length; ++a) {
16674      var i = r[a];
16675      n[a] = i >= 1 ? o[a] : o[a] * (i + 1);
16676    }
16677
16678    return this.makeOutput(n, e.shape, "float32");
16679  }, o.prototype.selu = function (t) {
16680    rf(t, "selu");
16681
16682    for (var e = au, n = iu, r = new Float32Array(t.size), o = this.readSync(t.dataId), a = 0; a < o.length; ++a) {
16683      var i = o[a];
16684      r[a] = i >= 0 ? n * i : e * (Math.exp(i) - 1);
16685    }
16686
16687    return this.makeOutput(r, t.shape, "float32");
16688  }, o.prototype.clip = function (t, e, n) {
16689    rf(t, "clip");
16690
16691    for (var r = new Float32Array(t.size), o = this.readSync(t.dataId), a = 0; a < o.length; ++a) {
16692      var i = o[a];
16693      r[a] = i > n ? n : i < e ? e : i;
16694    }
16695
16696    return this.makeOutput(r, t.shape, "float32");
16697  }, o.prototype.abs = function (t) {
16698    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.abs(n[r]);
16699
16700    return this.makeOutput(e, t.shape, "float32");
16701  }, o.prototype.complexAbs = function (t) {
16702    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < t.size; ++r) {
16703      var o = n[2 * r],
vendor: 23,825 bytes, lines 16704-17124
16704          a = n[2 * r + 1];
16705      e[r] = Math.hypot(o, a);
16706    }
16707
16708    return this.makeOutput(e, t.shape, "float32");
16709  }, o.prototype.int = function (t) {
16710    rf(t, "int");
16711
16712    for (var e = new Int32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = n[r];
16713
16714    return this.makeOutput(e, t.shape, "int32");
16715  }, o.prototype.sigmoid = function (t) {
16716    rf(t, "sigmoid");
16717
16718    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = 1 / (1 + Math.exp(-n[r]));
16719
16720    return this.makeOutput(e, t.shape, "float32");
16721  }, o.prototype.softplus = function (t) {
16722    rf(t, "softplus");
16723
16724    for (var e = Math.log(1.1920928955078125e-7) + 2, n = new Float32Array(t.size), r = this.readSync(t.dataId), o = 0; o < r.length; ++o) {
16725      var a = r[o] > -e,
16726          i = r[o] < e,
16727          s = Math.exp(r[o]),
16728          u = void 0;
16729      u = i ? s : a ? r[o] : Math.log(1 + s), n[o] = u;
16730    }
16731
16732    return this.makeOutput(n, t.shape, "float32");
16733  }, o.prototype.sin = function (t) {
16734    rf(t, "sin");
16735
16736    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.sin(n[r]);
16737
16738    return this.makeOutput(e, t.shape, "float32");
16739  }, o.prototype.cos = function (t) {
16740    rf(t, "cos");
16741
16742    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.cos(n[r]);
16743
16744    return this.makeOutput(e, t.shape, "float32");
16745  }, o.prototype.tan = function (t) {
16746    rf(t, "tan");
16747
16748    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.tan(n[r]);
16749
16750    return this.makeOutput(e, t.shape, "float32");
16751  }, o.prototype.asin = function (t) {
16752    rf(t, "asin");
16753
16754    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.asin(n[r]);
16755
16756    return this.makeOutput(e, t.shape, "float32");
16757  }, o.prototype.acos = function (t) {
16758    rf(t, "acos");
16759
16760    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.acos(n[r]);
16761
16762    return this.makeOutput(e, t.shape, "float32");
16763  }, o.prototype.atan = function (t) {
16764    rf(t, "atan");
16765
16766    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.atan(n[r]);
16767
16768    return this.makeOutput(e, t.shape, "float32");
16769  }, o.prototype.atan2 = function (t, e) {
16770    return rf([t, e], "atan2"), this.broadcastedBinaryOp(t, e, t.dtype, function (t, e) {
16771      return Math.atan2(t, e);
16772    });
16773  }, o.prototype.sinh = function (t) {
16774    rf(t, "sinh");
16775
16776    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.sinh(n[r]);
16777
16778    return this.makeOutput(e, t.shape, "float32");
16779  }, o.prototype.cosh = function (t) {
16780    rf(t, "cosh");
16781
16782    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.cosh(n[r]);
16783
16784    return this.makeOutput(e, t.shape, "float32");
16785  }, o.prototype.tanh = function (t) {
16786    rf(t, "tanh");
16787
16788    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = T(n[r]);
16789
16790    return this.makeOutput(e, t.shape, "float32");
16791  }, o.prototype.asinh = function (t) {
16792    rf(t, "asinh");
16793
16794    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.asinh(n[r]);
16795
16796    return this.makeOutput(e, t.shape, "float32");
16797  }, o.prototype.acosh = function (t) {
16798    rf(t, "acosh");
16799
16800    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.acosh(n[r]);
16801
16802    return this.makeOutput(e, t.shape, "float32");
16803  }, o.prototype.atanh = function (t) {
16804    rf(t, "atanh");
16805
16806    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) e[r] = Math.atanh(n[r]);
16807
16808    return this.makeOutput(e, t.shape, "float32");
16809  }, o.prototype.erf = function (t) {
16810    rf(t, "erf");
16811
16812    for (var e = new Float32Array(t.size), n = this.readSync(t.dataId), r = 0; r < n.length; ++r) {
16813      var o = Math.sign(n[r]),
16814          a = Math.abs(n[r]),
16815          i = 1 / (1 + .3275911 * a);
16816      e[r] = o * (1 - ((((1.061405429 * i - 1.453152027) * i + 1.421413741) * i - .284496736) * i + .254829592) * i * Math.exp(-a * a));
16817    }
16818
16819    return this.makeOutput(e, t.shape, "float32");
16820  }, o.prototype.step = function (t, e) {
16821    void 0 === e && (e = 0), rf(t, "step");
16822
16823    for (var n = new Float32Array(t.size), r = this.readSync(t.dataId), o = 0; o < r.length; ++o) {
16824      var a = r[o];
16825      isNaN(a) ? n[o] = NaN : n[o] = a > 0 ? 1 : e;
16826    }
16827
16828    return this.makeOutput(n, t.shape, "float32");
16829  }, o.prototype.fusedConv2d = function (t) {
16830    var e = t.input,
16831        n = t.filter,
16832        r = t.convInfo,
16833        o = t.bias,
16834        a = t.activation,
16835        i = t.preluActivationWeights,
16836        s = this.conv2d(e, n, r);
16837    return o && (s = this.add(s, o)), a && (s = of(this, s, a, i)), s;
16838  }, o.prototype.conv2d = function (t, e, n) {
16839    rf([t, e], "conv2d");
16840
16841    for (var r = n.filterHeight, o = n.filterWidth, a = n.dilationHeight, i = n.dilationWidth, s = n.padInfo.left, u = n.padInfo.top, c = "channelsLast" === n.dataFormat, l = er(n.outShape, t.dtype), h = t.strides[0], f = c ? t.strides[1] : t.strides[2], d = c ? t.strides[2] : 1, p = c ? 1 : t.strides[1], v = l.strides[0], m = c ? l.strides[1] : l.strides[2], g = c ? l.strides[2] : 1, y = c ? 1 : l.strides[1], x = this.readSync(t.dataId), b = this.readSync(e.dataId), w = l.values, C = 0; C < n.batchSize; ++C) for (var E = C * h, R = C * v, I = 0; I < n.outHeight; ++I) for (var k = R + I * m, S = I * n.strideHeight - u, A = 0; A < r; A++) {
16842      var T = S + A * a;
16843      if (!(T < 0 || T >= n.inHeight)) for (var D = A * e.strides[0], N = E + T * f, F = 0; F < n.outWidth; ++F) for (var _ = k + F * g, O = F * n.strideWidth - s, M = 0; M < o; M++) {
16844        var B = O + M * i;
16845        if (!(B < 0 || B >= n.inWidth)) for (var P = N + B * d, L = D + M * e.strides[1], W = 0; W < n.inChannels; ++W) {
16846          for (var U = x[P + W * p], V = 0; V < n.outChannels; ++V) w[_ + V * y] += U * b[L + V];
16847
16848          L += n.outChannels;
16849        }
16850      }
16851    }
16852
16853    return l.toTensor();
16854  }, o.prototype.conv3d = function (t, e, n) {
16855    for (var r = n.filterDepth, o = n.filterHeight, a = n.filterWidth, i = n.dilationDepth, s = n.dilationHeight, u = n.dilationWidth, c = n.padInfo.front, l = n.padInfo.left, h = n.padInfo.top, f = er(n.outShape, t.dtype), d = this.readSync(t.dataId), p = this.readSync(e.dataId), v = f.values, m = 0; m < n.batchSize; ++m) for (var g = m * t.strides[0], y = m * f.strides[0], x = 0; x < n.outDepth; ++x) for (var b = y + x * f.strides[1], w = x * n.strideDepth - c, C = 0; C < r; C++) {
16856      var E = w + C * i;
16857      if (!(E < 0 || E >= n.inDepth)) for (var R = C * e.strides[0], I = g + E * t.strides[1], k = 0; k < n.outHeight; ++k) for (var S = b + k * f.strides[2], A = k * n.strideHeight - h, T = 0; T < o; T++) {
16858        var D = A + T * s;
16859        if (!(D < 0 || D >= n.inHeight)) for (var N = R + T * e.strides[1], F = I + D * t.strides[2], _ = 0; _ < n.outWidth; ++_) for (var O = S + _ * n.outChannels, M = _ * n.strideWidth - l, B = 0; B < a; B++) {
16860          var P = M + B * u;
16861          if (!(P < 0 || P >= n.inWidth)) for (var L = N + B * e.strides[2], W = F + P * n.inChannels, U = L, V = 0; V < n.inChannels; ++V) {
16862            for (var z = d[W + V], G = 0; G < n.outChannels; ++G) v[O + G] += z * p[U + G];
16863
16864            U += n.outChannels;
16865          }
16866        }
16867      }
16868    }
16869
16870    return f.toTensor();
16871  }, o.prototype.conv2dDerInput = function (t, e, n) {
16872    rf([t, e], "conv2dDerInput");
16873
16874    for (var r = er(n.inShape, "float32"), o = r.values, a = this.readSync(t.dataId), i = this.readSync(e.dataId), s = e.strides, u = s[0], c = s[1], l = s[2], h = n.batchSize, f = n.filterHeight, d = n.filterWidth, p = n.inChannels, v = n.inHeight, m = n.inWidth, g = n.outChannels, y = n.outHeight, x = n.outWidth, b = n.strideHeight, w = n.strideWidth, C = n.dataFormat, E = f - 1 - n.padInfo.top, R = d - 1 - n.padInfo.left, I = "channelsLast" === C, k = r.strides[0], S = I ? r.strides[1] : r.strides[2], A = I ? r.strides[2] : 1, T = I ? 1 : r.strides[1], D = t.strides[0], N = I ? t.strides[1] : t.strides[2], F = I ? t.strides[2] : 1, _ = I ? 1 : t.strides[1], O = 0; O < h; ++O) for (var M = 0; M < p; ++M) for (var B = 0; B < v; ++B) for (var P = B - E, L = Math.max(0, Math.ceil(P / b)), W = Math.min(y, (f + P) / b), U = 0; U < m; ++U) {
16875      for (var V = U - R, z = Math.max(0, Math.ceil(V / w)), G = Math.min(x, (d + V) / w), H = 0, q = L; q < W; ++q) for (var K = q * b - P, j = z; j < G; ++j) for (var X = D * O + N * q + F * j, Y = u * (f - 1 - K) + c * (d - 1 - (j * w - V)) + l * M, $ = 0; $ < g; ++$) {
16876        H += a[X + _ * $] * i[Y + $];
16877      }
16878
16879      o[k * O + S * B + A * U + T * M] = H;
16880    }
16881
16882    return r.toTensor();
16883  }, o.prototype.conv3dDerInput = function (t, e, n) {
16884    for (var r = er(n.inShape, "float32"), o = r.values, a = r.strides, i = a[0], s = a[1], u = a[2], c = a[3], l = this.readSync(t.dataId), h = t.strides, f = h[0], d = h[1], p = h[2], v = h[3], m = this.readSync(e.dataId), g = e.strides, y = g[0], x = g[1], b = g[2], w = g[3], C = n.batchSize, E = n.filterDepth, R = n.filterHeight, I = n.filterWidth, k = n.inChannels, S = n.inDepth, A = n.inHeight, T = n.inWidth, D = n.outChannels, N = n.outDepth, F = n.outHeight, _ = n.outWidth, O = n.strideDepth, M = n.strideHeight, B = n.strideWidth, P = E - 1 - n.padInfo.front, L = R - 1 - n.padInfo.top, W = I - 1 - n.padInfo.left, U = 0; U < C; ++U) for (var V = 0; V < k; ++V) for (var z = 0; z < S; ++z) for (var G = z - P, H = Math.max(0, Math.ceil(G / O)), q = Math.min(N, (E + G) / O), K = 0; K < A; ++K) for (var j = K - L, X = Math.max(0, Math.ceil(j / M)), Y = Math.min(F, (R + j) / M), $ = 0; $ < T; ++$) {
16885      for (var Q = $ - W, J = Math.max(0, Math.ceil(Q / B)), Z = Math.min(_, (I + Q) / B), tt = 0, et = H; et < q; ++et) for (var nt = et * O - G, rt = X; rt < Y; ++rt) for (var ot = rt * M - j, at = J; at < Z; ++at) for (var it = f * U + d * et + p * rt + v * at, st = y * (E - 1 - nt) + x * (R - 1 - ot) + b * (I - 1 - (at * B - Q)) + w * V, ut = 0; ut < D; ++ut) {
16886        tt += l[it + ut] * m[st + ut];
16887      }
16888
16889      o[i * U + s * z + u * K + c * $ + V] = tt;
16890    }
16891
16892    return r.toTensor();
16893  }, o.prototype.conv2dDerFilter = function (t, e, n) {
16894    rf([t, e], "conv2dDerFilter");
16895
16896    for (var r = n.strideHeight, o = n.strideWidth, a = n.filterHeight, i = n.filterWidth, s = "channelsLast" === n.dataFormat, u = er(n.filterShape, "float32"), c = n.padInfo.left, l = n.padInfo.top, h = this.bufferSync(t), f = this.bufferSync(e), d = 0; d < a; ++d) for (var p = Math.max(0, Math.ceil((l - d) / r)), v = Math.min(n.outHeight, (n.inHeight + l - d) / r), m = 0; m < i; ++m) for (var g = Math.max(0, Math.ceil((c - m) / o)), y = Math.min(n.outWidth, (n.inWidth + c - m) / o), x = 0; x < n.inChannels; ++x) for (var b = 0; b < n.outChannels; ++b) {
16897      for (var w = 0, C = 0; C < n.batchSize; ++C) for (var E = p; E < v; ++E) for (var R = d + E * r - l, I = g; I < y; ++I) {
16898        var k = m + I * o - c;
16899        w += s ? h.get(C, R, k, x) * f.get(C, E, I, b) : h.get(C, x, R, k) * f.get(C, b, E, I);
16900      }
16901
16902      u.set(w, d, m, x, b);
16903    }
16904
16905    return u.toTensor();
16906  }, o.prototype.conv3dDerFilter = function (t, e, n) {
16907    for (var r = n.strideDepth, o = n.strideHeight, a = n.strideWidth, i = n.filterDepth, s = n.filterHeight, u = n.filterWidth, c = er(n.filterShape, "float32"), l = c.values, h = c.strides, f = h[0], d = h[1], p = h[2], v = h[3], m = this.readSync(e.dataId), g = e.strides, y = g[0], x = g[1], b = g[2], w = g[3], C = this.readSync(t.dataId), E = t.strides, R = E[0], I = E[1], k = E[2], S = E[3], A = n.padInfo.front, T = n.padInfo.left, D = n.padInfo.top, N = 0; N < i; ++N) for (var F = Math.max(0, Math.ceil((A - N) / r)), _ = Math.min(n.outDepth, (n.inDepth + A - N) / r), O = N * f, M = 0; M < s; ++M) for (var B = Math.max(0, Math.ceil((D - M) / o)), P = Math.min(n.outHeight, (n.inHeight + D - M) / o), L = M * d + O, W = 0; W < u; ++W) for (var U = Math.max(0, Math.ceil((T - W) / a)), V = Math.min(n.outWidth, (n.inWidth + T - W) / a), z = W * p + L, G = 0; G < n.inChannels; ++G) for (var H = G * v + z, q = 0; q < n.outChannels; ++q) {
16908      for (var K = 0, j = 0; j < n.batchSize; ++j) for (var X = j * R, Y = j * y, $ = F; $ < _; ++$) for (var Q = (N + $ * r - A) * I + X, J = $ * x + Y, Z = B; Z < P; ++Z) for (var tt = (M + Z * o - D) * k + Q, et = Z * b + J, nt = U; nt < V; ++nt) {
16909        var rt = nt * w + et;
16910        K += C[(W + nt * a - T) * S + tt + G] * m[rt + q];
16911      }
16912
16913      l[H + q] = K;
16914    }
16915
16916    return c.toTensor();
16917  }, o.prototype.fusedDepthwiseConv2D = function (t) {
16918    var e = t.input,
16919        n = t.filter,
16920        r = t.convInfo,
16921        o = t.bias,
16922        a = t.activation,
16923        i = t.preluActivationWeights,
16924        s = this.depthwiseConv2D(e, n, r);
16925    return o && (s = this.add(s, o)), a && (s = of(this, s, a, i)), s;
16926  }, o.prototype.depthwiseConv2D = function (t, e, n) {
16927    rf([t, e], "depthwiseConv2D");
16928
16929    for (var r = n.filterHeight, o = n.filterWidth, a = n.dilationHeight, i = n.dilationWidth, s = n.padInfo.left, u = n.padInfo.top, c = n.outChannels / n.inChannels, l = er(n.outShape, t.dtype), h = this.readSync(t.dataId), f = this.readSync(e.dataId), d = l.values, p = 0; p < n.batchSize; ++p) for (var v = p * t.strides[0], m = p * l.strides[0], g = 0; g < n.outHeight; ++g) for (var y = m + g * l.strides[1], x = g * n.strideHeight - s, b = 0; b < r; ++b) {
16930      var w = x + b * a;
16931      if (!(w < 0 || w >= n.inHeight)) for (var C = b * e.strides[0], E = v + w * t.strides[1], R = 0; R < n.outWidth; ++R) for (var I = y + R * l.strides[2], k = R * n.strideWidth - u, S = 0; S < o; ++S) {
16932        var A = k + S * i;
16933        if (!(A < 0 || A >= n.inWidth)) for (var T = C + S * e.strides[1], D = E + A * n.inChannels, N = I, F = T, _ = 0; _ < n.inChannels; ++_) {
16934          for (var O = h[D + _], M = 0; M < c; ++M) d[N + M] += O * f[F + M];
16935
16936          N += c, F += c;
16937        }
16938      }
16939    }
16940
16941    return l.toTensor();
16942  }, o.prototype.depthwiseConv2DDerInput = function (t, e, n) {
16943    rf([t, e], "depthwiseConv2DDerInput");
16944
16945    for (var r = er(n.inShape, "float32"), o = r.values, a = r.strides, i = a[0], s = a[1], u = a[2], c = this.readSync(t.dataId), l = t.strides, h = l[0], f = l[1], d = l[2], p = this.readSync(e.dataId), v = e.strides, m = v[0], g = v[1], y = v[2], x = n.batchSize, b = n.filterHeight, w = n.filterWidth, C = n.inChannels, E = n.inHeight, R = n.inWidth, I = n.outChannels, k = n.outHeight, S = n.outWidth, A = n.strideHeight, T = n.strideWidth, D = b - 1 - n.padInfo.top, N = w - 1 - n.padInfo.left, F = I / C, _ = 0; _ < x; ++_) for (var O = 0; O < C; ++O) for (var M = 0; M < E; ++M) for (var B = M - D, P = Math.max(0, Math.ceil(B / A)), L = Math.min(k, (b + B) / A), W = 0; W < R; ++W) {
16946      for (var U = W - N, V = Math.max(0, Math.ceil(U / T)), z = Math.min(S, (w + U) / T), G = 0, H = P; H < L; ++H) for (var q = H * A - B, K = V; K < z; ++K) for (var j = h * _ + f * H + d * K, X = m * (b - 1 - q) + g * (w - 1 - (K * T - U)) + y * O, Y = 0; Y < F; ++Y) {
16947        G += c[j + (O * F + Y)] * p[X + Y];
16948      }
16949
16950      o[i * _ + s * M + u * W + O] = G;
16951    }
16952
16953    return r.toTensor();
16954  }, o.prototype.depthwiseConv2DDerFilter = function (t, e, n) {
16955    rf([t, e], "depthwiseConv2DDerFilter");
16956
16957    for (var r = n.strideHeight, o = n.strideWidth, a = n.filterHeight, i = n.filterWidth, s = er(n.filterShape, "float32"), u = n.padInfo.left, c = n.padInfo.top, l = n.outChannels / n.inChannels, h = this.bufferSync(t), f = this.bufferSync(e), d = 0; d < a; ++d) for (var p = Math.max(0, Math.ceil((c - d) / r)), v = Math.min(n.outHeight, (n.inHeight + c - d) / r), m = 0; m < i; ++m) for (var g = Math.max(0, Math.ceil((u - m) / o)), y = Math.min(n.outWidth, (n.inWidth + u - m) / o), x = 0; x < n.outChannels; ++x) {
16958      for (var b = Math.trunc(x / l), w = x % l, C = 0, E = 0; E < n.batchSize; ++E) for (var R = p; R < v; ++R) for (var I = d + R * r - c, k = g; k < y; ++k) {
16959        var S = m + k * o - u;
16960        C += h.get(E, I, S, b) * f.get(E, R, k, x);
16961      }
16962
16963      s.set(C, d, m, b, w);
16964    }
16965
16966    return s.toTensor();
16967  }, o.prototype.tile = function (t, e) {
16968    return rf(t, "tile"), Pa(this.bufferSync(t), e);
16969  }, o.prototype.pad = function (t, e, n) {
16970    rf(t, "pad");
16971    var r = e.map(function (e, n) {
16972      return e[0] + t.shape[n] + e[1];
16973    }),
16974        o = e.map(function (t) {
16975      return t[0];
16976    }),
16977        a = this.bufferSync(t),
16978        i = er(r, t.dtype);
16979    0 !== n && i.values.fill(n);
16980
16981    for (var s = 0; s < t.size; s++) {
16982      var u = a.indexToLoc(s),
16983          c = u.map(function (t, e) {
16984        return t + o[e];
16985      });
16986      i.set.apply(i, [a.get.apply(a, u)].concat(c));
16987    }
16988
16989    return i.toTensor();
16990  }, o.prototype.transpose = function (t, e) {
16991    rf(t, "transpose");
16992
16993    for (var n = new Array(t.rank), r = 0; r < n.length; r++) n[r] = t.shape[e[r]];
16994
16995    var o = this.readSync(t.dataId),
16996        a = er(n, t.dtype),
16997        i = this.bufferSync(t);
16998
16999    for (r = 0; r < t.size; ++r) {
17000      for (var s = i.indexToLoc(r), u = new Array(s.length), c = 0; c < u.length; c++) u[c] = s[e[c]];
17001
17002      var l = a.locToIndex(u);
17003      a.values[l] = o[r];
17004    }
17005
17006    return a.toTensor();
17007  }, o.prototype.gather = function (t, e, n) {
17008    rf([t, e], "gather");
17009    var r = t.shape.slice(),
17010        o = this.readSync(e.dataId);
17011    r[n] = o.length;
17012
17013    for (var a = er(r, t.dtype), i = this.bufferSync(t), s = 0; s < a.size; ++s) {
17014      var u = a.indexToLoc(s),
17015          c = u.slice();
17016      c[n] = o[u[n]];
17017      var l = i.locToIndex(c);
17018      a.values[s] = i.values[l];
17019    }
17020
17021    return a.toTensor();
17022  }, o.prototype.batchToSpaceND = function (t, e, n) {
17023    rf([t], "batchToSpaceND");
17024    var r = e.reduce(function (t, e) {
17025      return t * e;
17026    }),
17027        o = xr(t.shape, e, r),
17028        a = br(o.length, e.length),
17029        i = wr(t.shape, e, r),
17030        s = Cr(n, e.length),
17031        u = Er(i, n, e.length);
17032    return t.reshape(o).transpose(a).reshape(i).slice(s, u);
17033  }, o.prototype.spaceToBatchND = function (t, e, n) {
17034    rf([t], "spaceToBatchND");
17035    var r = e.reduce(function (t, e) {
17036      return t * e;
17037    }),
17038        o = [[0, 0]];
17039    o.push.apply(o, n);
17040
17041    for (var a = 1 + e.length; a < t.shape.length; ++a) o.push([0, 0]);
17042
17043    var i = t.pad(o),
17044        s = xr(i.shape, e, r, !1),
17045        u = br(s.length, e.length, !1),
17046        c = wr(i.shape, e, r, !1);
17047    return i.reshape(s).transpose(u).reshape(c);
17048  }, o.prototype.pool = function (t, e, n) {
17049    rf(t, "pool");
17050
17051    for (var r = e.strideHeight, o = e.strideWidth, a = e.dilationHeight, i = e.dilationWidth, s = e.effectiveFilterHeight, u = e.effectiveFilterWidth, c = e.padInfo.top, l = e.padInfo.left, h = "max" === n ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, f = this.readSync(t.dataId), d = er(e.outShape, t.dtype), p = d.values, v = e.outShape[1] * e.outShape[2] * e.outShape[3], m = e.outShape[2] * e.outShape[3], g = e.outShape[3], y = 0; y < e.batchSize; ++y) for (var x = y * v, b = y * t.strides[0], w = 0; w < e.inChannels; ++w) for (var C = 0; C < e.outHeight; ++C) for (var E = C * r - c, R = Math.max(0, E), I = Math.min(e.inHeight, s + E), k = x + C * m, S = 0; S < e.outWidth; ++S) {
17052      for (var A = S * o - l, T = Math.max(0, A), D = Math.min(e.inWidth, u + A), N = h, F = 0, _ = 0, O = R; O < I; O += a) {
17053        for (var M = b + O * t.strides[1], B = T; B < D; B += i) {
17054          var P = f[M + B * t.strides[2] + w];
17055          "max" === n && P > N ? N = P : "avg" === n && (F += P, _++);
17056        }
17057
17058        if (isNaN(N)) break;
17059      }
17060
17061      p[k + S * g + w] = "avg" === n ? F / _ : N;
17062    }
17063
17064    return d.toTensor();
17065  }, o.prototype.maxPool = function (t, e) {
17066    return this.pool(t, e, "max");
17067  }, o.prototype.maxPoolPositions = function (t, e) {
17068    for (var n = er(e.outShape, "int32"), r = e.strideHeight, o = e.strideWidth, a = e.dilationHeight, i = e.dilationWidth, s = e.effectiveFilterHeight, u = e.effectiveFilterWidth, c = e.padInfo.top, l = e.padInfo.left, h = this.bufferSync(t), f = 0; f < e.batchSize; ++f) for (var d = 0; d < e.inChannels; ++d) for (var p = 0; p < e.outHeight; ++p) {
17069      for (var v = p * r - c, m = v; m < 0;) m += a;
17070
17071      for (var g = Math.min(e.inHeight, s + v), y = 0; y < e.outWidth; ++y) {
17072        for (var x = y * o - l, b = x; b < 0;) b += i;
17073
17074        for (var w = Math.min(e.inWidth, u + x), C = Number.NEGATIVE_INFINITY, E = -1, R = m; R < g; R += a) for (var I = R - v, k = b; k < w; k += i) {
17075          var S = k - x,
17076              A = h.get(f, R, k, d);
17077          A > C && (C = A, E = I * u + S);
17078        }
17079
17080        n.set(E, f, p, y, d);
17081      }
17082    }
17083
17084    return n.toTensor();
17085  }, o.prototype.maxPoolBackprop = function (t, e, n, r) {
17086    rf([e, n], "maxPoolBackprop");
17087
17088    for (var o = this.maxPoolPositions(e, r), a = r.strideHeight, i = r.strideWidth, s = r.dilationHeight, u = r.dilationWidth, c = r.effectiveFilterHeight, l = r.effectiveFilterWidth, h = l - 1 - r.padInfo.left, f = c - 1 - r.padInfo.top, d = er(e.shape, "float32"), p = this.bufferSync(o), v = this.bufferSync(t), m = 0; m < r.batchSize; ++m) for (var g = 0; g < r.inChannels; ++g) for (var y = 0; y < r.inHeight; ++y) for (var x = 0; x < r.inWidth; ++x) {
17089      for (var b = y - f, w = x - h, C = 0, E = 0; E < c; E += s) {
17090        var R = (b + E) / a;
17091        if (!(R < 0 || R >= r.outHeight || Math.floor(R) !== R)) for (var I = 0; I < l; I += u) {
17092          var k = (w + I) / i;
17093
17094          if (!(k < 0 || k >= r.outWidth || Math.floor(k) !== k)) {
17095            var S = c * l - 1 - p.get(m, R, k, g) === E * l + I ? 1 : 0;
17096            if (0 !== S) C += v.get(m, R, k, g) * S;
17097          }
17098        }
17099      }
17100
17101      d.set(C, m, y, x, g);
17102    }
17103
17104    return d.toTensor();
17105  }, o.prototype.avgPoolBackprop = function (t, e, n) {
17106    rf([t, e], "avgPoolBackprop");
17107
17108    for (var r = n.strideHeight, o = n.strideWidth, a = n.filterHeight, i = n.filterWidth, s = n.dilationHeight, u = n.dilationWidth, c = n.effectiveFilterHeight, l = n.effectiveFilterWidth, h = l - 1 - n.padInfo.left, f = c - 1 - n.padInfo.top, d = er(e.shape, "float32"), p = 1 / (a * i), v = this.bufferSync(t), m = 0; m < n.batchSize; ++m) for (var g = 0; g < n.inChannels; ++g) for (var y = 0; y < n.inHeight; ++y) for (var x = 0; x < n.inWidth; ++x) {
17109      for (var b = y - f, w = x - h, C = 0, E = 0; E < c; E += s) {
17110        var R = (b + E) / r;
17111        if (!(R < 0 || R >= n.outHeight || Math.floor(R) !== R)) for (var I = 0; I < l; I += u) {
17112          var k = (w + I) / o;
17113          if (!(k < 0 || k >= n.outWidth || Math.floor(k) !== k)) C += v.get(m, R, k, g);
17114        }
17115      }
17116
17117      d.set(C * p, m, y, x, g);
17118    }
17119
17120    return d.toTensor();
17121  }, o.prototype.pool3d = function (t, e, n) {
17122    rf(t, "pool3d");
17123
17124    for (var r = e.strideDepth, o = e.strideHeight, a = e.strideWidth, i = e.dilationDepth, s = e.dilationHeight, u = e.dilationWidth, c = e.effectiveFilterDepth, l = e.effectiveFilterHeight, h = e.effectiveFilterWidth, f = e.padInfo.front, d = e.padInfo.top, p = e.padInfo.left, v = "max" === n ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, m = this.readSync(t.dataId), g = er(e.outShape, t.dtype), y = g.values, x = e.outShape[1] * e.outShape[2] * e.outShape[3] * e.outShape[4], b = e.outShape[2] * e.outShape[3] * e.outShape[4], w = e.outShape[3] * e.outShape[4], C = e.outShape[4], E = 0; E < e.batchSize; ++E) for (var R = E * x, I = E * t.strides[0], k = 0; k < e.inChannels; ++k) for (var S = 0; S < e.outDepth; ++S) {
17125      for (var A = S * r - f, T = A; T < 0;) T += i;
17126
17127      for (var D = Math.min(e.inDepth, c + A), N = R + S * b, F = 0; F < e.outHeight; ++F) {
17128        for (var _ = F * o - d, O = _; O < 0;) O += s;
17129
17130        for (var M = Math.min(e.inHeight, l + _), B = N + F * w, P = 0; P < e.outWidth; ++P) {
17131          for (var L = P * a - p, W = L; W < 0;) W += u;
17132
17133          for (var U = Math.min(e.inWidth, h + L), V = B + P * C, z = v, G = 0, H = 0, q = T; q < D; q += i) {
17134            for (var K = I + q * t.strides[1], j = O; j < M; j += s) {
17135              for (var X = K + j * t.strides[2], Y = W; Y < U; Y += u) {
17136                var $ = m[X + Y * t.strides[3] + k];
17137                if ("max" === n && $ > z ? z = $ : "avg" === n && (G += $, H++), isNaN(z)) break;
17138              }
17139
17140              if (isNaN(z)) break;
17141            }
17142
17143            if (isNaN(z)) break;
17144          }
17145
17146          y[V + k] = "avg" === n ? G / H : z;
17147        }
17148      }
17149    }
17150
17151    return g.toTensor();
17152  }, o.prototype.avgPool3d = function (t, e) {
17153    return rf(t, "avgPool3d"), this.pool3d(t, e, "avg").toFloat();
17154  }, o.prototype.avgPool3dBackprop = function (t, e, n) {
17155    rf([t, e], "avgPool3dBackprop");
17156
17157    for (var r = n.strideDepth, o = n.strideHeight, a = n.strideWidth, i = n.filterDepth, s = n.filterHeight, u = n.filterWidth, c = n.dilationDepth, l = n.dilationHeight, h = n.dilationWidth, f = n.effectiveFilterDepth, d = n.effectiveFilterHeight, p = n.effectiveFilterWidth, v = f - 1 - n.padInfo.front, m = p - 1 - n.padInfo.left, g = d - 1 - n.padInfo.top, y = er(e.shape, "float32"), x = 1 / (i * s * u), b = this.bufferSync(t), w = 0; w < n.batchSize; ++w) for (var C = 0; C < n.inChannels; ++C) for (var E = 0; E < n.inDepth; ++E) for (var R = 0; R < n.inHeight; ++R) for (var I = 0; I < n.inWidth; ++I) {
17158      for (var k = E - v, S = R - g, A = I - m, T = 0, D = 0; D < f; D += c) {
17159        var N = (k + D) / r;
17160        if (!(N < 0 || N >= n.outDepth || Math.floor(N) !== N)) for (var F = 0; F < d; F += l) {
17161          var _ = (S + F) / o;
17162
17163          if (!(_ < 0 || _ >= n.outHeight || Math.floor(_) !== _)) for (var O = 0; O < p; O += h) {
17164            var M = (A + O) / a;
17165            if (!(M < 0 || M >= n.outWidth || Math.floor(M) !== M)) T += b.get(w, N, _, M, C);
17166          }
17167        }
17168      }
17169
17170      y.set(T * x, w, E, R, I, C);
17171    }
17172
17173    return y.toTensor();
17174  }, o.prototype.maxPool3d = function (t, e) {
17175    return rf(t, "maxPool3d"), this.pool3d(t, e, "max").toFloat();
17176  }, o.prototype.maxPool3dPositions = function (t, e) {
17177    for (var n = er(e.outShape, "int32"), r = e.strideDepth, o = e.strideHeight, a = e.strideWidth, i = e.dilationDepth, s = e.dilationHeight, u = e.dilationWidth, c = e.effectiveFilterDepth, l = e.effectiveFilterHeight, h = e.effectiveFilterWidth, f = e.padInfo.front, d = e.padInfo.top, p = e.padInfo.left, v = this.bufferSync(t), m = 0; m < e.batchSize; ++m) for (var g = 0; g < e.inChannels; ++g) for (var y = 0; y < e.outDepth; ++y) {
17178      for (var x = y * r - f, b = x; b < 0;) b += i;
17179
17180      for (var w = Math.min(e.inDepth, c + x), C = 0; C < e.outHeight; ++C) {
17181        for (var E = C * o - d, R = E; R < 0;) R += s;
17182
17183        for (var I = Math.min(e.inHeight, l + E), k = 0; k < e.outWidth; ++k) {
17184          for (var S = k * a - p, A = S; A < 0;) A += u;
17185
17186          for (var T = Math.min(e.inWidth, h + S), D = Number.NEGATIVE_INFINITY, N = -1, F = b; F < w; F += i) for (var _ = F - x, O = R; O < I; O += s) for (var M = O - E, B = A; B < T; B += u) {
17187            var P = B - S,
17188                L = v.get(m, F, O, B, g);
17189            L >= D && (D = L, N = _ * l * h + M * l + P);
17190          }
17191
17192          n.set(N, m, y, C, k, g);
17193        }
17194      }
17195    }
17196
17197    return n.toTensor();
17198  }, o.prototype.maxPool3dBackprop = function (t, e, n, r) {
17199    rf([e, n], "maxPool3dBackprop");
17200
17201    for (var o = this.maxPool3dPositions(e, r), a = r.strideDepth, i = r.strideHeight, s = r.strideWidth, u = r.dilationDepth, c = r.dilationHeight, l = r.dilationWidth, h = r.effectiveFilterDepth, f = r.effectiveFilterHeight, d = r.effectiveFilterWidth, p = h - 1 - r.padInfo.front, v = d - 1 - r.padInfo.left, m = f - 1 - r.padInfo.top, g = er(e.shape, "float32"), y = this.bufferSync(o), x = this.bufferSync(t), b = 0; b < r.batchSize; ++b) for (var w = 0; w < r.inChannels; ++w) for (var C = 0; C < r.inDepth; ++C) for (var E = 0; E < r.inHeight; ++E) for (var R = 0; R < r.inWidth; ++R) {
17202      for (var I = C - p, k = E - m, S = R - v, A = 0, T = 0; T < h; T += u) {
17203        var D = (I + T) / a;
17204        if (!(D < 0 || D >= r.outDepth || Math.floor(D) !== D)) for (var N = 0; N < f; N += c) {
17205          var F = (k + N) / i;
17206          if (!(F < 0 || F >= r.outHeight || Math.floor(F) !== F)) for (var _ = 0; _ < d; _ += l) {
17207            var O = (S + _) / s;
17208
17209            if (!(O < 0 || O >= r.outWidth || Math.floor(O) !== O)) {
17210              var M = h * f * d - 1 - y.get(b, D, F, O, w) === T * f * d + N * d + _ ? 1 : 0;
17211              if (0 !== M) A += x.get(b, D, F, O, w) * M;
17212            }
17213          }
17214        }
17215      }
17216
17217      g.set(A, b, C, E, R, w);
17218    }
17219
17220    return g.toTensor();
17221  }, o.prototype.cast = function (t, e) {
17222    return ba(t, e, this);
17223  }, o.prototype.reshape = function (t, e) {
17224    return wa(t, e);
17225  }, o.prototype.avgPool = function (t, e) {
vendor: 8,804 bytes, lines 17226-17398
17226    return rf(t, "avgPool"), this.pool(t, e, "avg").toFloat();
17227  }, o.prototype.resizeBilinear = function (t, e, n, r) {
17228    rf(t, "resizeBilinear");
17229
17230    for (var o = t.shape, a = o[0], i = o[1], s = o[2], u = o[3], c = this.readSync(t.dataId), l = new Float32Array(k([a, e, n, u])), h = [r && e > 1 ? i - 1 : i, r && n > 1 ? s - 1 : s], f = [r && e > 1 ? e - 1 : e, r && n > 1 ? n - 1 : n], d = 0, p = h[0] / f[0], v = h[1] / f[1], m = 0; m < a; m++) for (var g = 0; g < e; g++) for (var y = p * g, x = Math.floor(y), b = y - x, w = Math.min(i - 1, Math.ceil(y)), C = m * t.strides[0] + x * t.strides[1], E = m * t.strides[0] + w * t.strides[1], R = 0; R < n; R++) for (var I = v * R, S = Math.floor(I), A = I - S, T = Math.min(s - 1, Math.ceil(I)), D = C + S * t.strides[2], N = E + S * t.strides[2], F = C + T * t.strides[2], _ = E + T * t.strides[2], O = 0; O < u; O++) {
17231      var M = c[D + O],
17232          B = c[N + O],
17233          P = M + (c[F + O] - M) * A,
17234          L = P + (B + (c[_ + O] - B) * A - P) * b;
17235      l[d++] = L;
17236    }
17237
17238    return Fn(l, [a, e, n, u]);
17239  }, o.prototype.resizeBilinearBackprop = function (t, e, n) {
17240    rf([t, e], "resizeBilinearBackprop");
17241
17242    for (var r = e.shape, o = r[0], a = r[1], i = r[2], s = r[3], u = t.shape, c = u[1], l = u[2], h = new Float32Array(o * a * i * s), f = [n && c > 1 ? a - 1 : a, n && l > 1 ? i - 1 : i], d = [n && c > 1 ? c - 1 : c, n && l > 1 ? l - 1 : l], p = f[0] / d[0], v = f[1] / d[1], m = this.readSync(t.dataId), g = 0, y = 0; y < o; y++) for (var x = y * e.strides[0], b = 0; b < c; b++) for (var w = b * p, C = Math.floor(w), E = Math.min(Math.ceil(w), a - 1), R = x + C * e.strides[1], I = x + E * e.strides[1], k = w - C, S = 1 - k, A = 0; A < l; A++) for (var T = A * v, D = Math.floor(T), N = Math.min(Math.ceil(T), i - 1), F = T - D, _ = 1 - F, O = R + D * e.strides[2], M = R + N * e.strides[2], B = I + D * e.strides[2], P = I + N * e.strides[2], L = S * _, W = S * F, U = k * _, V = k * F, z = 0; z < s; z++) {
17243      var G = m[g++];
17244      h[O + z] += G * L, h[M + z] += G * W, h[B + z] += G * U, h[P + z] += G * V;
17245    }
17246
17247    return Ln(h, [o, i, a, s], e.dtype);
17248  }, o.prototype.resizeNearestNeighbor = function (t, e, n, r) {
17249    rf(t, "resizeNearestNeighbor");
17250
17251    for (var o = t.shape, a = o[0], i = o[1], s = o[2], u = o[3], c = this.readSync(t.dataId), l = new Float32Array(a * e * n * u), h = [r && e > 1 ? i - 1 : i, r && n > 1 ? s - 1 : s], f = [r && e > 1 ? e - 1 : e, r && n > 1 ? n - 1 : n], d = h[0] / f[0], p = h[1] / f[1], v = 0, m = 0; m < a; m++) for (var g = m * t.strides[0], y = 0; y < e; y++) for (var x = d * y, b = g + Math.min(i - 1, r ? Math.round(x) : Math.floor(x)) * t.strides[1], w = 0; w < n; w++) for (var C = p * w, E = b + Math.min(s - 1, r ? Math.round(C) : Math.floor(C)) * t.strides[2], R = 0; R < u; R++) {
17252      var I = c[E + R];
17253      l[v++] = I;
17254    }
17255
17256    return Fn(l, [a, e, n, u], t.dtype);
17257  }, o.prototype.resizeNearestNeighborBackprop = function (t, e, n) {
17258    rf([t, e], "resizeNearestNeighborBackprop");
17259
17260    for (var r = e.shape, o = r[0], a = r[1], i = r[2], s = r[3], u = t.shape, c = u[1], l = u[2], h = new Float32Array(o * a * i * s), f = this.readSync(t.dataId), d = [n && c > 1 ? a - 1 : a, n && l > 1 ? i - 1 : i], p = [n && c > 1 ? c - 1 : c, n && l > 1 ? l - 1 : l], v = d[0] / p[0], m = d[1] / p[1], g = 1 / v, y = 1 / m, x = 2 * Math.ceil(g) + 2, b = 2 * Math.ceil(y) + 2, w = 0; w < o; w++) for (var C = w * e.strides[0], E = 0; E < a; E++) for (var R = C + E * e.strides[1], I = Math.floor(E * g), k = Math.floor(I - x / 2), S = 0; S < i; S++) for (var A = R + S * e.strides[2], T = Math.floor(S * y), D = Math.floor(T - b / 2), N = 0; N < s; N++) {
17261      for (var F = 0, _ = 0; _ < x; _++) {
17262        var O = _ + k;
17263
17264        if (!(O < 0 || O >= c)) {
17265          var M = C + O * t.strides[1],
17266              B = O * v;
17267          if (E === Math.min(a - 1, n ? Math.round(B) : Math.floor(B))) for (var P = 0; P < b; P++) {
17268            var L = P + D;
17269
17270            if (!(L < 0 || L >= l)) {
17271              var W = M + L * t.strides[2],
17272                  U = L * m;
17273              S === Math.min(i - 1, n ? Math.round(U) : Math.floor(U)) && (F += f[W + N]);
17274            }
17275          }
17276        }
17277      }
17278
17279      h[A + N] = F;
17280    }
17281
17282    return Ln(h, e.shape, e.dtype);
17283  }, o.prototype.batchNormalization = function (t, e, n, r, o, a) {
17284    rf([t, e, n, o, a], "batchNorm");
17285
17286    for (var i = this.readSync(t.dataId), s = this.readSync(e.dataId), u = this.readSync(n.dataId), c = o ? this.readSync(o.dataId) : new Float32Array([1]), l = a ? this.readSync(a.dataId) : new Float32Array([0]), h = new Float32Array(i.length), f = l.length, d = c.length, p = u.length, v = s.length, m = 0, g = 0, y = 0, x = 0, b = 0; b < i.length; ++b) h[b] = l[m++] + (i[b] - s[g++]) * c[y++] / Math.sqrt(u[x++] + r), m >= f && (m = 0), g >= v && (g = 0), y >= d && (y = 0), x >= p && (x = 0);
17287
17288    return Ln(h, t.shape);
17289  }, o.prototype.localResponseNormalization4D = function (t, e, n, r, o) {
17290    rf(t, "localResponseNormalization4D");
17291    var a = t.shape[3],
17292        i = a - 1,
17293        s = this.readSync(t.dataId),
17294        u = t.size,
17295        c = new Float32Array(u);
17296
17297    function l(t) {
17298      for (var n = t % a, r = t - n + Math.max(0, n - e), o = t - n + Math.min(n + e, i), u = 0; r <= o; r++) {
17299        var c = s[r];
17300        u += c * c;
17301      }
17302
17303      return u;
17304    }
17305
17306    for (var h = 0; h < u; h++) {
17307      var f = l(h),
17308          d = s[h] * Math.pow(n + r * f, -o);
17309      c[h] = d;
17310    }
17311
17312    return Ln(c, t.shape);
17313  }, o.prototype.LRNGrad = function (t, e, n, r, o, a, i) {
17314    rf(t, "LRNGrad");
17315
17316    for (var s = t.shape[3], u = this.readSync(t.dataId), c = this.readSync(e.dataId), l = this.readSync(n.dataId), h = new Float32Array(t.size), f = t.size, d = 0; d < f; d++) {
17317      for (var p = d % s, v = d - p + Math.max(0, p - r), m = d - p + Math.min(s, p + r + 1), g = 0, y = v; y < m; y++) g += Math.pow(c[y], 2);
17318
17319      g = a * g + o;
17320
17321      for (y = v; y < m; y++) {
17322        var x = -2 * a * i * c[y] * l[d] / g;
17323        d === y && (x += Math.pow(g, -i)), x *= u[d], h[y] += x;
17324      }
17325    }
17326
17327    return Ln(h, t.shape);
17328  }, o.prototype.multinomial = function (t, e, n, r) {
17329    rf(t, "multinomial");
17330
17331    for (var o = e ? t : ra(t), a = o.shape[0], i = o.shape[1], s = Gn([a, n], "int32"), u = this.readSync(s.dataId), c = this.readSync(o.dataId), l = 0; l < a; ++l) {
17332      var h = l * i,
17333          f = new Float32Array(i - 1);
17334      f[0] = c[h];
17335
17336      for (var d = 1; d < f.length; ++d) f[d] = f[d - 1] + c[h + d];
17337
17338      for (var p = ju(r.toString()), v = l * n, m = 0; m < n; ++m) {
17339        var g = p();
17340        u[v + m] = f.length;
17341
17342        for (var y = 0; y < f.length; y++) if (g < f[y]) {
17343          u[v + m] = y;
17344          break;
17345        }
17346      }
17347    }
17348
17349    return s;
17350  }, o.prototype.oneHot = function (t, e, n, r) {
17351    rf(t, "oneHot");
17352    var o = new Float32Array(t.size * e);
17353    o.fill(r);
17354
17355    for (var a = this.readSync(t.dataId), i = 0; i < t.size; ++i) a[i] >= 0 && a[i] < e && (o[i * e + a[i]] = n);
17356
17357    return Bn(o, [t.size, e], "int32");
17358  }, o.prototype.nonMaxSuppression = function (t, e, n, r, o) {
17359    return rf(t, "nonMaxSuppression"), Da(this.readSync(t.dataId), this.readSync(e.dataId), n, r, o);
17360  }, o.prototype.fft = function (t) {
17361    return this.fftBatch(t, !1);
17362  }, o.prototype.ifft = function (t) {
17363    return this.fftBatch(t, !0);
17364  }, o.prototype.fftBatch = function (t, e) {
17365    for (var n = t.shape[0], r = t.shape[1], o = er(t.shape, "float32"), a = er(t.shape, "float32"), i = Dn(t).as2D(n, r), s = Nn(t).as2D(n, r), u = 0; u < n; u++) for (var c = i.slice([u, 0], [1, r]), l = s.slice([u, 0], [1, r]), h = Tn(c, l), f = this.readSync(this.fftImpl(h, e).dataId), d = 0; d < r; d++) {
17366      var p = Ia(f, d);
17367      o.values[u * r + d] = p.real, a.values[u * r + d] = p.imag;
17368    }
17369
17370    return Tn(o.toTensor(), a.toTensor()).as2D(n, r);
17371  }, o.prototype.fftImpl = function (t, e) {
17372    var n = t.as1D(),
17373        r = n.size;
17374
17375    if (this.isExponentOf2(r)) {
17376      var o = this.fftRadix2(n, r, e).as2D(t.shape[0], t.shape[1]);
17377      return e && (o = Tn(Dn(o).div(On(r)), Nn(o).div(On(r)))), o;
17378    }
17379
17380    var a = this.readSync(t.dataId),
17381        i = function (t) {
17382      for (var e = new Float32Array(t.length / 2), n = new Float32Array(t.length / 2), r = 0; r < t.length; r += 2) e[r / 2] = t[r], n[r / 2] = t[r + 1];
17383
17384      return {
17385        real: e,
17386        imag: n
17387      };
17388    }(this.fourierTransformByMatmul(a, r, e));
17389
17390    return Tn(i.real, i.imag).as2D(t.shape[0], t.shape[1]);
17391  }, o.prototype.isExponentOf2 = function (t) {
17392    return 0 == (t & t - 1);
17393  }, o.prototype.fftRadix2 = function (t, e, n) {
17394    if (1 === e) return t;
17395
17396    var r = this.readSync(t.dataId),
17397        o = e / 2,
17398        a = function (t) {
17399      for (var e = Math.ceil(t.length / 4), n = new Float32Array(e), r = new Float32Array(e), o = 0; o < t.length; o += 4) n[Math.floor(o / 4)] = t[o], r[Math.floor(o / 4)] = t[o + 1];
17400
17401      return {
17402        real: n,
17403        imag: r
17404      };
17405    }(r),
17406        i = Tn(a.real, a.imag).as1D(),
17407        s = function (t) {
17408      for (var e = Math.floor(t.length / 4), n = new Float32Array(e), r = new Float32Array(e), o = 2; o < t.length; o += 4) n[Math.floor(o / 4)] = t[o], r[Math.floor(o / 4)] = t[o + 1];
17409
17410      return {
17411        real: n,
17412        imag: r
17413      };
17414    }(r),
17415        u = Tn(s.real, s.imag).as1D();
17416
17417    i = this.fftRadix2(i, o, n), u = this.fftRadix2(u, o, n);
17418
17419    var c = function (t, e) {
17420      for (var n = new Float32Array(t / 2), r = new Float32Array(t / 2), o = 0; o < Math.ceil(t / 2); o++) {
17421        var a = (e ? 2 : -2) * Math.PI * (o / t);
17422        n[o] = Math.cos(a), r[o] = Math.sin(a);
17423      }
17424
17425      return {
17426        real: n,
17427        imag: r
17428      };
17429    }(e, n),
17430        l = Tn(c.real, c.imag).mul(u),
17431        h = i.add(l),
17432        f = i.sub(l),
17433        d = Dn(h).concat(Dn(f)),
17434        p = Nn(h).concat(Nn(f));
17435
17436    return Tn(d, p).as1D();
17437  }, o.prototype.fourierTransformByMatmul = function (t, e, n) {
17438    for (var r = new Float32Array(2 * e), o = 0; o < e; o++) {
17439      for (var a = 0, i = 0, s = 0; s < e; s++) {
17440        var u = Sa(o * s, e, n),
17441            c = Ia(t, s);
17442        a += c.real * u.real - c.imag * u.imag, i += c.real * u.imag + c.imag * u.real;
17443      }
17444
17445      n && (a /= e, i /= e), ka(r, a, i, o);
17446    }
17447
17448    return r;
17449  }, o.prototype.depthToSpace = function (t, e, n) {
17450    C("NHWC" === n, function () {
17451      return "Only NHWC dataFormat supported on CPU for depthToSpace. Got " + n;
17452    }), C(e > 1, function () {
17453      return "blockSize should be > 1 for depthToSpace, but was: " + e;
17454    });
17455
17456    for (var r = t.shape[0], o = t.shape[1], a = t.shape[2], i = t.shape[3], s = o * e, u = a * e, c = i / (e * e), l = this.readSync(t.dataId), h = new Float32Array(r * s * u * c), f = 0, d = 0; d < r; ++d) for (var p = 0; p < s; ++p) for (var v = Math.floor(p / e), m = p % e, g = 0; g < u; ++g) for (var y = Math.floor(g / e), x = (m * e + g % e) * c, b = 0; b < c; ++b) {
17457      var w = b + x + i * (y + a * (v + o * d));
17458      h[f++] = l[w];
17459    }
17460
17461    return Ln(h, [r, s, u, c]);
17462  }, o.prototype.broadcastedBinaryOp = function (t, e, n, r) {
17463    var o = Fr(t.shape, e.shape),
17464        a = er(o, n),
17465        i = this.readSync(t.dataId),
17466        s = this.readSync(e.dataId),
17467        u = Dr(t.shape, o),
17468        c = Dr(e.shape, o),
17469        l = a.values;
17470    if (u.length + c.length === 0) for (var h = 0; h < l.length; ++h) l[h] = r(i[h % i.length], s[h % s.length]);else {
17471      var f = this.bufferSync(t),
17472          d = this.bufferSync(e),
17473          p = function (n) {
17474        var o = a.indexToLoc(n),
17475            h = o.slice(-t.rank);
17476        u.forEach(function (t) {
17477          return h[t] = 0;
17478        });
17479        var p = f.locToIndex(h),
17480            v = o.slice(-e.rank);
17481        c.forEach(function (t) {
17482          return v[t] = 0;
17483        });
17484        var m = d.locToIndex(v);
17485        l[n] = r(i[p], s[m]);
17486      };
17487
17488      for (h = 0; h < l.length; ++h) p(h);
17489    }
17490    return a.toTensor();
17491  }, o.prototype.broadcastedBinaryComplexOp = function (t, e, n) {
17492    var r = Fr(t.shape, e.shape),
17493        o = er(r, "float32"),
17494        a = er(r, "float32"),
17495        i = this.readSync(t.dataId),
17496        s = this.readSync(e.dataId),
17497        u = Dr(t.shape, r),
17498        c = Dr(e.shape, r),
17499        l = o.values,
17500        h = a.values;
17501    if (u.length + c.length === 0) for (var f = 0; f < l.length; f++) {
17502      var d = f % i.length,
17503          p = f % s.length,
17504          v = n(i[2 * d], i[2 * d + 1], s[2 * p], s[2 * p + 1]);
17505      l[f] = v.real, h[f] = v.imag;
17506    } else {
17507      var m = this.bufferSync(this.data.get(t.dataId).complexTensors.real),
17508          g = this.bufferSync(this.data.get(e.dataId).complexTensors.real),
17509          y = function (r) {
17510        var a = o.indexToLoc(r),
17511            f = a.slice(-t.rank);
17512        u.forEach(function (t) {
17513          return f[t] = 0;
17514        });
17515        var d = m.locToIndex(f),
17516            p = a.slice(-e.rank);
17517        c.forEach(function (t) {
17518          return p[t] = 0;
17519        });
17520        var v = g.locToIndex(p),
17521            y = n(i[2 * d], i[2 * d + 1], s[2 * v], s[2 * v + 1]);
17522        l[r] = y.real, h[r] = y.imag;
17523      };
17524
17525      for (f = 0; f < l.length; f++) y(f);
17526    }
17527    return this.complex(o.toTensor(), a.toTensor());
17528  }, o.prototype.split = function (t, e, n) {
17529    return Ba(t, e, n);
17530  }, o.prototype.dispose = function () {}, o.prototype.floatPrecision = function () {
17531    return 32;
17532  }, o.prototype.epsilon = function () {
17533    return 1e-7;
17534  }, o.prototype.cropAndResize = function (t, e, n, r, o, a) {
17535    for (var i = t.shape, s = i[0], u = i[1], c = i[2], l = i[3], h = e.shape[0], f = r[0], d = r[1], p = er([h, f, d, l], "float32"), v = this.readSync(e.dataId), m = this.readSync(n.dataId), g = this.readSync(t.dataId), y = t.strides, x = p.strides, b = 0; b < h; b++) {
17536      var w = 4 * b,
17537          C = v[w],
17538          E = v[w + 1],
17539          R = v[w + 2],
17540          I = v[w + 3],
17541          k = m[b];
17542      if (!(k >= s)) for (var S = f > 1 ? (R - C) * (u - 1) / (f - 1) : 0, A = d > 1 ? (I - E) * (c - 1) / (d - 1) : 0, T = 0; T < f; T++) {
17543        var D = f > 1 ? C * (u - 1) + T * S : .5 * (C + R) * (u - 1);
17544        if (D < 0 || D > u - 1) for (var N = 0; N < d; N++) for (var F = 0; F < l; F++) {
17545          var _ = F + N * x[2] + T * x[1] + b * x[0];
17546
17547          p.values[_] = a;
17548        } else if ("bilinear" === o) {
17549          var O = Math.floor(D),
17550              M = Math.ceil(D),
17551              B = D - O;
17552
17553          for (N = 0; N < d; N++) {
17554            if ((q = d > 1 ? E * (c - 1) + N * A : .5 * (E + I) * (c - 1)) < 0 || q > c - 1) for (F = 0; F < l; F++) {
17555              _ = F + N * x[2] + T * x[1] + b * x[0];
17556              p.values[_] = a;
17557            } else {
17558              var P = Math.floor(q),
17559                  L = Math.ceil(q),
17560                  W = q - P;
17561
17562              for (F = 0; F < l; F++) {
17563                var U = g[_ = F + P * y[2] + O * y[1] + k * y[0]],
17564                    V = g[_ = F + L * y[2] + O * y[1] + k * y[0]],
17565                    z = g[_ = F + P * y[2] + M * y[1] + k * y[0]],
17566                    G = U + (V - U) * W,
17567                    H = z + (g[_ = F + L * y[2] + M * y[1] + k * y[0]] - z) * W;
17568                _ = F + N * x[2] + T * x[1] + b * x[0], p.values[_] = G + (H - G) * B;
17569              }
17570            }
17571          }
17572        } else for (N = 0; N < d; ++N) {
17573          var q;
17574          if ((q = d > 1 ? E * (c - 1) + N * A : .5 * (E + I) * (c - 1)) < 0 || q > c - 1) for (F = 0; F < l; F++) {
17575            _ = F + N * x[2] + T * x[1] + b * x[0];
17576            p.values[_] = a;
17577          } else {
17578            var K = Math.round(q),
17579                j = Math.round(D);
17580
17581            for (F = 0; F < l; F++) {
17582              var X = F + K * y[2] + j * y[1] + k * y[0],
17583                  Y = F + N * x[2] + T * x[1] + b * x[0];
17584              p.values[Y] = g[X];
17585            }
17586          }
17587        }
17588      }
17589    }
17590
17591    return p.toTensor();
17592  }, o.prototype.sparseToDense = function (t, e, n, r) {
17593    var o = Uo(0, t, n),
17594        a = o.sliceRank,
17595        i = o.numUpdates,
17596        s = o.sliceSize,
17597        u = o.strides,
17598        c = o.outputSize;
17599    return this.scatter(t, e, n, c, s, i, a, u, r, !1);
17600  }, o.prototype.gatherND = function (t, e) {
17601    var n = e.shape,
17602        r = n[n.length - 1],
17603        o = Oo(t, e),
17604        a = o[0],
17605        i = o[1],
17606        s = o[2],
17607        u = o[3];
17608    if (0 === i) return Fn([], a, t.dtype);
17609
17610    for (var c = new gt([i, s], t.dtype), l = this.readSync(e.dataId), h = this.readSync(t.dataId), f = 0; f < i; f++) {
17611      for (var d = [], p = 0, v = 0; v < r; v++) {
17612        var m = l[f * r + v];
17613        p += m * u[v], d.push(m);
17614      }
17615
17616      if (p < 0 || p >= t.size / s) throw new Error("Invalid indices: " + d + " does not index into " + t.shape);
17617
17618      for (var g = 0; g < s; g++) c.values[f * s + g] = h[p * s + g];
17619    }
17620
17621    return c.toTensor().reshape(a);
17622  }, o.prototype.scatterND = function (t, e, n) {
17623    var r = Uo(0, t, n),
17624        o = r.sliceRank,
17625        a = r.numUpdates,
17626        i = r.sliceSize,
17627        s = r.strides,
17628        u = r.outputSize,
17629        c = On(0);
17630    return this.scatter(t, e, n, u, i, a, o, s, c, !0);
17631  }, o.prototype.fill = function (t, e, n) {
17632    var r = P(n = n || j(e), k(t));
17633    return r.fill(e), Lt.makeTensor(r, t, n, this);
17634  }, o.prototype.onesLike = function (t) {
17635    if ("string" === t.dtype) throw new Error("onesLike is not supported for string tensors");
17636    return this.fill(t.shape, 1, t.dtype);
17637  }, o.prototype.zerosLike = function (t) {
17638    var e = P(t.dtype, k(t.shape));
17639    return this.makeOutput(e, t.shape, t.dtype);
17640  }, o.prototype.linspace = function (t, e, n) {
17641    return Ca(t, e, n);
17642  }, o.prototype.scatter = function (t, e, n, r, o, a, i, s, u, c) {
17643    var l = [r / o, o],
17644        h = this.readSync(t.dataId),
17645        f = this.readSync(e.dataId);
17646    if (0 === r) return Fn([], n, e.dtype);
17647    var d = new gt(l, e.dtype);
17648    d.values.fill(this.readSync(u.dataId)[0]);
17649
17650    for (var p = 0; p < a; p++) {
17651      for (var v = [], m = 0, g = 0; g < i; g++) {
17652        var y = h[p * i + g];
17653        v.push(y), m += y * s[g];
17654      }
17655
17656      if (m < 0 || m >= r / o) throw new Error("Invalid indices: " + v + " does not index into " + n);
17657
17658      for (var x = 0; x < o; x++) c ? d.values[m * o + x] += f[p * o + x] : d.values[m * o + x] = 0 === e.rank ? f[0] : f[p * o + x];
17659    }
17660
17661    return d.toTensor().reshape(n);
17662  }, o;
17663}(ia);
17664
17665function sf(t, e) {
17666  return {
17667    kernelName: t,
17668    backendName: "cpu",
17669    kernelFunc: function (n) {
17670      var r = n.inputs,
17671          o = n.backend,
17672          a = r,
17673          i = a.a,
17674          s = a.b,
17675          u = o;
17676      rf([i, s], t);
17677      var c = u.data.get(i.dataId).values,
17678          l = u.data.get(s.dataId).values,
17679          h = e(i.shape, s.shape, c, l, i.dtype),
17680          f = h[0],
17681          d = h[1];
17682      return {
17683        dataId: u.write(f, d, i.dtype),
17684        shape: d,
17685        dtype: i.dtype
17686      };
17687    }
17688  };
17689}
17690
17691function uf(t) {
17692  return function (e, n, r, o, a) {
17693    var i = Fr(e, n),
17694        s = i.length,
17695        u = $(i),
17696        c = B(a, k(i)),
17697        l = e.length,
17698        h = n.length,
17699        f = $(e),
17700        d = $(n),
17701        p = Dr(e, i),
17702        v = Dr(n, i);
17703    if (p.length + v.length === 0) for (var m = 0; m < c.length; ++m) c[m] = t(r[m % r.length], o[m % o.length]);else {
17704      var g = function (e) {
17705        var n = it(e, s, u),
17706            a = n.slice(-l);
17707        p.forEach(function (t) {
17708          return a[t] = 0;
17709        });
17710        var i = at(a, l, f),
17711            m = n.slice(-h);
17712        v.forEach(function (t) {
17713          return m[t] = 0;
17714        });
17715        var g = at(m, h, d);
17716        c[e] = t(r[i], o[g]);
17717      };
17718
17719      for (m = 0; m < c.length; ++m) g(m);
17720    }
17721    return [c, i];
17722  };
17723}
17724
17725Lt.registerBackend("cpu", function () {
17726  return new af();
17727}, 1);
17728
17729for (var cf = uf(function (t, e) {
17730  return t / e;
17731}), lf = sf(Rr, cf), hf = {
17732  kernelName: "NonMaxSuppressionV5",
17733  backendName: "cpu",
17734  kernelFunc: function (t) {
17735    var e = t.inputs,
17736        n = t.backend,
17737        r = t.attrs,
17738        o = e,
17739        a = o.boxes,
17740        i = o.scores,
17741        s = r,
17742        u = s.maxOutputSize,
17743        c = s.iouThreshold,
17744        l = s.scoreThreshold,
17745        h = s.softNmsSigma,
17746        f = n;
17747    rf(a, "NonMaxSuppressionWithScore");
17748    var d = Na(f.data.get(a.dataId).values, f.data.get(i.dataId).values, u, c, l, h);
17749    return [d.selectedIndices, d.selectedScores];
17750  }
17751}, ff = {
17752  kernelName: "Square",
17753  backendName: "cpu",
17754  kernelFunc: function (t) {
17755    var e = t.inputs,
17756        n = t.backend,
17757        r = e.x,
17758        o = n;
17759    rf(r, "square");
17760
17761    for (var a = o.data.get(r.dataId).values, i = new Float32Array(a.length), s = 0; s < a.length; ++s) {
17762      var u = a[s];
17763      i[s] = u * u;
17764    }
17765
17766    return {
17767      dataId: o.write(i, r.shape, r.dtype),
17768      shape: r.shape,
17769      dtype: r.dtype
17770    };
17771  }
17772}, df = uf(function (t, e) {
17773  var n = t - e;
17774  return n * n;
17775}), pf = 0, vf = [hf, ff, sf(Ir, df), lf]; pf < vf.length; pf++) {
17776  d(vf[pf]);
17777}
17778
17779var mf,
17780    gf = function (t) {
17781  this.variableNames = ["A"];
17782  var e = qa(),
17783      n = t[0],
17784      r = t[1];
17785  this.outputShape = t, this.userCode = "\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n        vec2 uv = (vec2(texC, texR) + halfCR) / vec2(" + r + ".0, " + n + ".0);\n\n        vec4 values = " + e.texture2D + "(A, uv);\n        float value;\n        if (depth == 0) {\n          value = values.r;\n        } else if (depth == 1) {\n          value = values.g;\n        } else if (depth == 2) {\n          value = values.b;\n        } else if (depth == 3) {\n          value = values.a;\n        }\n\n        setOutput(floor(value * 255.0 + 0.5));\n      }\n    ";
17786},
17787    yf = function (t) {
17788  this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0;
17789  var e = qa(),
17790      n = t[0],
17791      r = t[1];
17792  this.outputShape = t, this.userCode = "\n      void main() {\n        ivec3 coords = getOutputCoords();\n        int texR = coords[0];\n        int texC = coords[1];\n        int depth = coords[2];\n\n        vec4 result = vec4(0.);\n\n        for(int row=0; row<=1; row++) {\n          for(int col=0; col<=1; col++) {\n            texC = coords[1] + row;\n            depth = coords[2] + col;\n\n            vec2 uv = (vec2(texC, texR) + halfCR) /\n                       vec2(" + r + ".0, " + n + ".0);\n            vec4 values = " + e.texture2D + "(A, uv);\n            float value;\n            if (depth == 0) {\n              value = values.r;\n            } else if (depth == 1) {\n              value = values.g;\n            } else if (depth == 2) {\n              value = values.b;\n            } else if (depth == 3) {\n              value = values.a;\n            }\n\n            result[row * 2 + col] = floor(value * 255.0 + 0.5);\n          }\n        }\n\n        " + e.output + " = result;\n      }\n    ";
17793};
17794
17795for (var xf = 0, bf = [{
17796  kernelName: "FromPixels",
17797  backendName: "webgl",
17798  kernelFunc: function (t) {
17799    var e = t.inputs,
17800        n = t.backend,
17801        r = t.attrs,
17802        o = e.pixels,
17803        a = r.numChannels,
17804        s = "undefined" != typeof HTMLVideoElement && o instanceof HTMLVideoElement,
17805        u = "undefined" != typeof HTMLImageElement && o instanceof HTMLImageElement,
17806        c = s ? [o.videoWidth, o.videoHeight] : [o.width, o.height],
17807        l = c[0],
17808        h = c[1],
17809        f = [h, l],
17810        d = [h, l, a];
17811    (u || s) && (null == mf && (mf = document.createElement("canvas").getContext("2d")), mf.canvas.width = l, mf.canvas.height = h, mf.drawImage(o, 0, 0, l, h), o = mf.canvas);
17812    var p = n.makeTensorInfo(f, "int32");
17813    n.texData.get(p.dataId).usage = zt.PIXELS, n.gpgpu.uploadPixelDataToTexture(n.getTexture(p.dataId), o);
17814    var v = i().getBool("WEBGL_PACK") ? new yf(d) : new gf(d),
17815        m = n.runWebGLProgram(v, [p], "int32");
17816    return n.disposeData(p.dataId), m;
17817  }
17818}, {
17819  kernelName: Rr,
17820  backendName: "webgl",
17821  kernelFunc: function (t) {
17822    var e = t.inputs,
17823        n = t.backend,
17824        r = e;
17825    return function (t, e, n) {
17826      var r = new bi(yi, t.shape, e.shape);
17827      return i().getBool("WEBGL_PACK_BINARY_OPERATIONS") && (r = new Ei(wi, t.shape, e.shape, !0)), n.runWebGLProgram(r, [t, e], "float32");
17828    }(r.a, r.b, n);
17829  }
17830}, {
17831  kernelName: "NonMaxSuppressionV5",
17832  backendName: "webgl",
17833  kernelFunc: function (t) {
17834    var e = t.inputs,
17835        n = t.backend,
17836        r = t.attrs;
17837    dn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead");
17838    var o = e,
17839        a = o.boxes,
17840        i = o.scores,
17841        s = r,
17842        u = s.maxOutputSize,
17843        c = s.iouThreshold,
17844        l = s.scoreThreshold,
17845        h = s.softNmsSigma,
17846        f = n,
17847        d = Na(f.readSync(a.dataId), f.readSync(i.dataId), u, c, l, h);
17848    return [d.selectedIndices, d.selectedScores];
17849  }
17850}, {
17851  kernelName: "Square",
17852  backendName: "webgl",
17853  kernelFunc: function (t) {
17854    var e = t.inputs,
17855        n = t.backend,
17856        r = e.x,
17857        o = n,
17858        a = new su(r.shape, "return x * x;");
17859    return o.runWebGLProgram(a, [r], r.dtype);
17860  }
17861}, {
17862  kernelName: Ir,
17863  backendName: "webgl",
17864  kernelFunc: function (t) {
17865    var e = t.inputs,
17866        n = t.backend,
17867        r = e,
17868        o = r.a,
17869        a = r.b,
17870        s = n,
17871        u = i().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new Ei("return (a 
17871- b) * (a - b);", o.shape, a.shape) : new bi("return (a - b) * (a - b);", o.shape, a.shape);
17872    return s.compileAndRun(u, [o, a]);
17873  }
17874}]; xf < bf.length; xf++) {
17875  d(bf[xf]);
17876}
17877
17878for (var wf = 0, Cf = [{
17879  kernelName: Rr,
17880  inputsToSave: ["a", "b"],
17881  gradFunc: function (t, e) {
17882    var n = e[0],
17883        r = e[1],
17884        o = Fr(n.shape, r.shape);
17885    return {
17886      a: function () {
17887        var e = _o(t, r.toFloat()),
17888            a = Nr(n.shape, o);
17889
17890        return a.length > 0 ? Hl(e, a).reshape(n.shape) : e;
17891      },
17892      b: function () {
17893        var e = t.mul(n.toFloat()),
17894            a = Nr(r.shape, o);
17895        a.length > 0 && (e = Hl(e, a).reshape(r.shape));
17896        var i = bc(r);
17897        return Qr(_o(e, i.toFloat()));
17898      }
17899    };
17900  }
17901}, {
17902  kernelName: "Square",
17903  inputsToSave: ["x"],
17904  gradFunc: function (t, e) {
17905    var n = e[0];
17906    return {
17907      x: function () {
17908        return t.mul(n.toFloat().mul(2));
17909      }
17910    };
17911  }
17912}, {
17913  kernelName: Ir,
17914  inputsToSave: ["a", "b"],
17915  gradFunc: function (t, e) {
17916    var n = e[0],
17917        r = e[1],
17918        o = On(2);
17919    return {
17920      a: function () {
17921        return ko(t, ko(o, No(n, r)));
17922      },
17923      b: function () {
17924        return ko(t, ko(o, No(r, n)));
17925      }
17926    };
17927  }
17928}, {
17929  kernelName: kr,
17930  gradFunc: function (t, e, n) {
17931    for (var r = n, o = r.inputShape, a = r.shape, i = Array.from(a), s = o.length - 1; s >= 0; s--) if (o[s] === a[s]) i[s] = 1;else if (1 !== o[s]) throw new Error("broadcastTo(): [" + o + "] cannot be broadcast to [" + a + "].");
17932
17933    var u = [];
17934
17935    for (s = 0; s < i.length; s++) i[s] > 1 && u.push(s);
17936
17937    return {
17938      x: function () {
17939        return t.sum(u, !0);
17940      }
17941    };
17942  }
17943}, {
17944  kernelName: Ar,
17945  gradFunc: function (t) {
17946    return {
17947      x: function () {
17948        return t.toFloat();
17949      }
17950    };
17951  }
17952}, {
17953  kernelName: Tr,
17954  inputsToSave: ["x"],
17955  gradFunc: function (t, e, n) {
17956    var r = e[0],
17957        o = n.reps;
17958    return {
17959      x: function () {
17960        var e = Xn(r);
17961        if (1 === r.rank) for (var n = 0; n < o[0]; ++n) e = e.add(t.slice([n * r.shape[0]], [r.shape[0]]));else if (2 === r.rank) for (n = 0; n < o[0]; ++n) for (var a = 0; a < o[1]; ++a) e = e.add(t.slice([n * r.shape[0], a * r.shape[1]], [r.shape[0], r.shape[1]]));else if (3 === r.rank) for (n = 0; n < o[0]; ++n) for (a = 0; a < o[1]; ++a) for (var i = 0; i < o[2]; ++i) e = e.add(t.slice([n * r.shape[0], a * r.shape[1], i * r.shape[2]], [r.shape[0], r.shape[1], r.shape[2]]));else {
17962          if (4 !== r.rank) throw new Error("Gradient for tile operation is not implemented for rank-" + r.rank + " tensors yet.");
17963
17964          for (n = 0; n < o[0]; ++n) for (a = 0; a < o[1]; ++a) for (i = 0; i < o[2]; ++i) for (var s = 0; s < o[3]; ++s) e = e.add(t.slice([n * r.shape[0], a * r.shape[1], i * r.shape[2], s * r.shape[3]], [r.shape[0], r.shape[1], r.shape[2], r.shape[3]]));
17965        }
17966        return e;
17967      }
17968    };
17969  }
17970}, {
17971  kernelName: Sr,
17972  inputsToSave: ["indices"],
17973  gradFunc: function (t, e) {
17974    var n = e[0];
17975    return {
17976      indices: function () {
17977        return Gn(n.shape, "float32");
17978      }
17979    };
17980  }
17981}]; wf < Cf.length; wf++) {
17982  p(Cf[wf]);
17983}
17984
17985var Ef = function () {
17986  function t() {}
17987
17988  return t.prototype.fetch = function (t, e) {
17989    return fetch(t, e);
17990  }, t.prototype.now = function () {
17991    return performance.now();
17992  }, t.prototype.encode = function (t, e) {
17993    if ("utf-8" !== e && "utf8" !== e) throw new Error("Browser's encoder only supports utf-8, but got " + e);
17994    return null == this.textEncoder && (this.textEncoder = new TextEncoder()), this.textEncoder.encode(t);
17995  }, t.prototype.decode = function (t, e) {
17996    return new TextDecoder(e).decode(t);
17997  }, t;
17998}();
17999
18000i().get("IS_BROWSER") && i().setPlatform("browser", new Ef());
18001
18002var Rf,
18003    If = function () {
18004  return require("node-fetch");
18005},
18006    kf = function () {
18007  function t() {
18008    this.util = require("util"), this.textEncoder = new this.util.TextEncoder();
18009  }
18010
18011  return t.prototype.fetch = function (t, e) {
18012    return null != i().global.fetch ? i().global.fetch(t, e) : (null == Rf && (Rf = If()), Rf(t, e));
18013  }, t.prototype.now = function () {
18014    var t = process.hrtime();
18015    return 1e3 * t[0] + t[1] / 1e6;
18016  }, t.prototype.encode = function (t, e) {
18017    if ("utf-8" !== e && "utf8" !== e) throw new Error("Node built-in encoder only supports utf-8, but got " + e);
18018    return this.textEncoder.encode(t);
18019  }, t.prototype.decode = function (t, e) {
18020    return 0 === t.length ? "" : new this.util.TextDecoder(e).decode(t);
18021  }, t;
18022}();
18023
18024i().get("IS_NODE") && i().setPlatform("node", new kf());
18025var Sf = {
18026  float32: 4,
18027  int32: 4,
18028  uint16: 2,
18029  uint8: 1,
18030  bool: 1
18031},
18032    Af = 4;
18033
18034function Tf(t, e) {
18035  for (var n = {}, r = 0, o = function (e) {
18036    var o = e.name,
18037        a = e.dtype,
18038        i = e.shape,
18039        s = k(i),
18040        u = void 0;
18041
18042    if (("quantization" in e)) {
18043      var c = e.quantization;
18044      if ("uint8" !== c.dtype && "uint16" !== c.dtype) throw new Error("Weight " + e.name + " has unknown quantization dtype " + c.dtype + ". Supported quantization dtypes are: 'uint8' and 'uint16'.");
18045      var l = Sf[c.dtype],
18046          h = t.slice(r, r + s * l),
18047          f = "uint8" === c.dtype ? new Uint8Array(h) : new Uint16Array(h);
18048      if ("float32" === a) u = Float32Array.from(f, function (t) {
18049        return t * c.scale + c.min;
18050      });else {
18051        if ("int32" !== a) throw new Error("Unsupported dtype in weight '" + o + "': " + a);
18052        u = Int32Array.from(f, function (t) {
18053          return Math.round(t * c.scale + c.min);
18054        });
18055      }
18056      r += s * l;
18057    } else if ("string" === a) {
18058      var d = k(e.shape);
18059      u = [];
18060
18061      for (var p = 0; p < d; p++) {
18062        var v = new Uint32Array(t.slice(r, r + Af))[0];
18063        r += Af;
18064        var m = new Uint8Array(t.slice(r, r + v));
18065        u.push(m), r += v;
18066      }
18067    } else {
18068      var g = Sf[a];
18069      h = t.slice(r, r + s * g);
18070      if ("float32" === a) u = new Float32Array(h);else if ("int32" === a) u = new Int32Array(h);else {
18071        if ("bool" !== a) throw new Error("Unsupported dtype in weight '" + o + "': " + a);
18072        u = new Uint8Array(h);
18073      }
18074      r += s * g;
18075    }
18076
18077    n[o] = Fn(u, i, a);
18078  }, a = 0, i = e; a < i.length; a++) {
18079    o(i[a]);
18080  }
18081
18082  return n;
18083}
18084
18085function Df(t) {
18086  if (null === t) throw new Error("Invalid input value: " + JSON.stringify(t));
18087  var e = 0,
18088      n = [];
18089  t.forEach(function (t) {
18090    if (e += t.byteLength, n.push(t.byteLength === t.buffer.byteLength ? t : new t.constructor(t)), !(t instanceof Float32Array || t instanceof Int32Array || t instanceof Uint8Array)) throw new Error("Unsupported TypedArray subtype: " + t.constructor.name);
18091  });
18092  var r = new Uint8Array(e),
18093      o = 0;
18094  return n.forEach(function (t) {
18095    r.set(new Uint8Array(t.buffer), o), o += t.byteLength;
18096  }), r.buffer;
18097}
18098
18099var Nf = "undefined" != typeof Buffer && ("undefined" == typeof Blob || "undefined" == typeof atob || "undefined" == typeof btoa);
18100
18101function Ff(t) {
18102  return Nf ? Buffer.byteLength(t) : new Blob([t]).size;
18103}
18104
18105function _f(t) {
18106  var e = 0;
18107  t.forEach(function (t) {
18108    e += t.byteLength;
18109  });
18110  var n = new Uint8Array(e),
18111      r = 0;
18112  return t.forEach(function (t) {
18113    n.set(new Uint8Array(t), r), r += t.byteLength;
18114  }), n.buffer;
18115}
18116
18117function Of(t) {
18118  for (t = t.trim(); t.endsWith("/");) t = t.slice(0, t.length - 1);
18119
18120  var e = t.split("/");
18121  return e[e.length - 1];
18122}
18123
18124function Mf(t) {
18125  if (t.modelTopology instanceof ArrayBuffer) throw new Error("Expected JSON model topology, received ArrayBuffer.");
18126  return {
18127    dateSaved: new Date(),
18128    modelTopologyType: "JSON",
18129    modelTopologyBytes: null == t.modelTopology ? 0 : Ff(JSON.stringify(t.modelTopology)),
18130    weightSpecsBytes: null == t.weightSpecs ? 0 : Ff(JSON.stringify(t.weightSpecs)),
18131    weightDataBytes: null == t.weightData ? 0 : t.weightData.byteLength
18132  };
18133}
18134
18135var Bf = function () {
18136  function t() {
18137    this.saveRouters = [], this.loadRouters = [];
18138  }
18139
18140  return t.getInstance = function () {
18141    return null == t.instance && (t.instance = new t()), t.instance;
18142  }, t.registerSaveRouter = function (e) {
18143    t.getInstance().saveRouters.push(e);
18144  }, t.registerLoadRouter = function (e) {
18145    t.getInstance().loadRouters.push(e);
18146  }, t.getSaveHandlers = function (e) {
18147    return t.getHandlers(e, "save");
18148  }, t.getLoadHandlers = function (e, n) {
18149    return t.getHandlers(e, "load", n);
18150  }, t.getHandlers = function (e, n, r) {
18151    var o = [];
18152    return ("load" === n ? t.getInstance().loadRouters : t.getInstance().saveRouters).forEach(function (t) {
18153      var n = t(e, r);
18154      null !== n && o.push(n);
18155    }), o;
18156  }, t;
18157}(),
18158    Pf = "://",
18159    Lf = function () {
18160  function t() {
18161    this.managers = {};
18162  }
18163
18164  return t.getInstance = function () {
18165    return null == t.instance && (t.instance = new t()), t.instance;
18166  }, t.registerManager = function (e, n) {
18167    C(null != e, function () {
18168      return "scheme must not be undefined or null.";
18169    }), e.endsWith(Pf) && (e = e.slice(0, e.indexOf(Pf))), C(e.length > 0, function () {
18170      return "scheme must not be an empty string.";
18171    });
18172    var r = t.getInstance();
18173    C(null == r.managers[e], function () {
18174      return "A model store manager is already registered for scheme '" + e + "'.";
18175    }), r.managers[e] = n;
18176  }, t.getManager = function (t) {
18177    var e = this.getInstance().managers[t];
18178    if (null == e) throw new Error("Cannot find model manager for scheme '" + t + "'");
18179    return e;
18180  }, t.getSchemes = function () {
18181    return Object.keys(this.getInstance().managers);
18182  }, t;
18183}();
18184
18185function Wf(t) {
18186  if (-1 === t.indexOf(Pf)) throw new Error("The url string provided does not contain a scheme. Supported schemes are: " + Lf.getSchemes().join(","));
18187  return {
18188    scheme: t.split(Pf)[0],
18189    path: t.split(Pf)[1]
18190  };
18191}
18192
18193function Uf(t, e, o) {
18194  return void 0 === o && (o = !1), n(this, void 0, void 0, function () {
18195    var n, a, i, s, u, c, l, h, f;
18196    return r(this, function (r) {
18197      switch (r.label) {
18198        case 0:
18199          return C(t !== e, function () {
18200            return "Old path and new path are the same: '" + t + "'";
18201          }), C((n = Bf.getLoadHandlers(t)).length > 0, function () {
18202            return "Copying failed because no load handler is found for source URL " + t + ".";
18203          }), C(n.length < 2, function () {
18204            return "Copying failed because more than one (" + n.length + ") load handlers for source URL " + t + ".";
18205          }), a = n[0], C((i = Bf.getSaveHandlers(e)).length > 0, function () {
18206            return "Copying failed because no save handler is found for destination URL " + e + ".";
18207          }), C(i.length < 2, function () {
18208            return "Copying failed because more than one (" + n.length + ") save handlers for destination URL " + e + ".";
18209          }), s = i[0], u = Wf(t).scheme, c = Wf(t).path, l = u === Wf(t).scheme, [4, a.load()];
18210
18211        case 1:
18212          return h = r.sent(), o && l ? [4, Lf.getManager(u).removeModel(c)] : [3, 3];
18213
18214        case 2:
18215          r.sent(), r.label = 3;
18216
18217        case 3:
18218          return [4, s.save(h)];
18219
18220        case 4:
18221          return f = r.sent(), !o || l ? [3, 6] : [4, Lf.getManager(u).removeModel(c)];
18222
18223        case 5:
18224          r.sent(), r.label = 6;
18225
18226        case 6:
18227          return [2, f.modelArtifactsInfo];
18228      }
18229    });
18230  });
18231}
18232
18233var Vf = "models_store",
18234    zf = "model_info_store";
18235
18236function Gf() {
18237  if (!i().getBool("IS_BROWSER")) throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");
18238  var t = window || self,
18239      e = t.indexedDB || t.mozIndexedDB || t.webkitIndexedDB || t.msIndexedDB || t.shimIndexedDB;
18240  if (null == e) throw new Error("The current browser does not appear to support IndexedDB.");
18241  return e;
18242}
18243
18244function Hf(t) {
18245  var e = t.result;
18246  e.createObjectStore(Vf, {
18247    keyPath: "modelPath"
18248  }), e.createObjectStore(zf, {
18249    keyPath: "modelPath"
18250  });
18251}
18252
18253var qf = function () {
18254  function t(t) {
18255    if (this.indexedDB = Gf(), null == t || !t) throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");
18256    this.modelPath = t;
18257  }
18258
18259  return t.prototype.save = function (t) {
18260    return n(this, void 0, void 0, function () {
18261      return r(this, function (e) {
18262        if (t.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");
18263        return [2, this.databaseAction(this.modelPath, t)];
18264      });
18265    });
18266  }, t.prototype.load = function () {
18267    return n(this, void 0, void 0, function () {
18268      return r(this, function (t) {
18269        return [2, this.databaseAction(this.modelPath)];
18270      });
18271    });
18272  }, t.prototype.databaseAction = function (t, e) {
18273    var n = this;
18274    return new Promise(function (t, r) {
18275      var o = n.indexedDB.open("tensorflowjs", 1);
18276      o.onupgradeneeded = function () {
18277        return Hf(o);
18278      }, o.onsuccess = function () {
18279        var a = o.result;
18280
18281        if (null == e) {
18282          var i = a.transaction(Vf, "readonly"),
18283              s = i.objectStore(Vf).get(n.modelPath);
18284          s.onsuccess = function () {
18285            if (null == s.result) return a.close(), r(new Error("Cannot find model with path '" + n.modelPath + "' in IndexedDB."));
18286            t(s.result.modelArtifacts);
18287          }, s.onerror = function (t) {
18288            return a.close(), r(s.error);
18289          }, i.oncomplete = function () {
18290            return a.close();
18291          };
18292        } else {
18293          var u,
18294              c = Mf(e),
18295              l = a.transaction(zf, "readwrite"),
18296              h = l.objectStore(zf),
18297              f = h.put({
18298            modelPath: n.modelPath,
18299            modelArtifactsInfo: c
18300          });
18301          f.onsuccess = function () {
18302            var o = (u = a.transaction(Vf, "readwrite")).objectStore(Vf).put({
18303              modelPath: n.modelPath,
18304              modelArtifacts: e,
18305              modelArtifactsInfo: c
18306            });
18307            o.onsuccess = function () {
18308              return t({
18309                modelArtifactsInfo: c
18310              });
18311            }, o.onerror = function (t) {
18312              var e = (h = l.objectStore(zf)).delete(n.modelPath);
18313              e.onsuccess = function () {
18314                return a.close(), r(o.error);
18315              }, e.onerror = function (t) {
18316                return a.close(), r(o.error);
18317              };
18318            };
18319          }, f.onerror = function (t) {
18320            return a.close(), r(f.error);
18321          }, l.oncomplete = function () {
18322            null == u ? a.close() : u.oncomplete = function () {
18323              return a.close();
18324            };
18325          };
18326        }
18327      }, o.onerror = function (t) {
18328        return r(o.error);
18329      };
18330    });
18331  }, t.URL_SCHEME = "indexeddb://", t;
18332}(),
18333    Kf = function (t) {
18334  return i().getBool("IS_BROWSER") && !Array.isArray(t) && t.startsWith(qf.URL_SCHEME) ? (e = t.slice(qf.URL_SCHEME.length), new qf(e)) : null;
18335  var e;
18336};
18337
18338Bf.registerSaveRouter(Kf), Bf.registerLoadRouter(Kf);
18339
18340var jf = function () {
18341  function t() {
18342    this.indexedDB = Gf();
18343  }
18344
18345  return t.prototype.listModels = function () {
18346    return n(this, void 0, void 0, function () {
18347      var t = this;
18348      return r(this, function (e) {
18349        return [2, new Promise(function (e, n) {
18350          var r = t.indexedDB.open("tensorflowjs", 1);
18351          r.onupgradeneeded = function () {
18352            return Hf(r);
18353          }, r.onsuccess = function () {
18354            var t = r.result,
18355                o = t.transaction(zf, "readonly"),
18356                a = o.objectStore(zf).getAll();
18357            a.onsuccess = function () {
18358              for (var t = {}, n = 0, r = a.result; n < r.length; n++) {
18359                var o = r[n];
18360                t[o.modelPath] = o.modelArtifactsInfo;
18361              }
18362
18363              e(t);
18364            }, a.onerror = function (e) {
18365              return t.close(), n(a.error);
18366            }, o.oncomplete = function () {
18367              return t.close();
18368            };
18369          }, r.onerror = function (t) {
18370            return n(r.error);
18371          };
18372        })];
18373      });
18374    });
18375  }, t.prototype.removeModel = function (t) {
18376    return n(this, void 0, void 0, function () {
18377      var e = this;
18378      return r(this, function (n) {
18379        var r;
18380        return t = (r = t).startsWith(qf.URL_SCHEME) ? r.slice(qf.URL_SCHEME.length) : r, [2, new Promise(function (n, r) {
18381          var o = e.indexedDB.open("tensorflowjs", 1);
18382          o.onupgradeneeded = function () {
18383            return Hf(o);
18384          }, o.onsuccess = function () {
18385            var e,
18386                a = o.result,
18387                i = a.transaction(zf, "readwrite"),
18388                s = i.objectStore(zf),
18389                u = s.get(t);
18390            u.onsuccess = function () {
18391              if (null == u.result) return a.close(), r(new Error("Cannot find model with path '" + t + "' in IndexedDB."));
18392
18393              var o = s.delete(t),
18394                  i = function () {
18395                var o = (e = a.transaction(Vf, "readwrite")).objectStore(Vf).delete(t);
18396                o.onsuccess = function () {
18397                  return n(u.result.modelArtifactsInfo);
18398                }, o.onerror = function (t) {
18399                  return r(u.error);
18400                };
18401              };
18402
18403              o.onsuccess = i, o.onerror = function (t) {
18404                return i(), a.close(), r(u.error);
18405              };
18406            }, u.onerror = function (t) {
18407              return a.close(), r(u.error);
18408            }, i.oncomplete = function () {
18409              null == e ? a.close() : e.oncomplete = function () {
18410                return a.close();
18411              };
18412            };
18413          }, o.onerror = function (t) {
18414            return r(o.error);
18415          };
18416        })];
18417      });
18418    });
18419  }, t;
18420}();
18421
18422if (i().getBool("IS_BROWSER")) try {
18423  Lf.registerManager(qf.URL_SCHEME, new jf());
18424} catch (t) {}
18425var Xf = "/",
18426    Yf = "tensorflowjs_models",
18427    $f = "info",
18428    Qf = "model_topology",
18429    Jf = "weight_specs",
18430    Zf = "weight_data",
18431    td = "model_metadata";
18432
18433function ed(t) {
18434  return {
18435    info: [Yf, t, $f].join(Xf),
18436    topology: [Yf, t, Qf].join(Xf),
18437    weightSpecs: [Yf, t, Jf].join(Xf),
18438    weightData: [Yf, t, Zf].join(Xf),
18439    modelMetadata: [Yf, t, td].join(Xf)
18440  };
18441}
18442
18443function nd(t) {
18444  var e = t.split(Xf);
18445  if (e.length < 3) throw new Error("Invalid key format: " + t);
18446  return e.slice(1, e.length - 1).join(Xf);
18447}
18448
18449var rd = function () {
18450  function t(t) {
18451    if (!i().getBool("IS_BROWSER") || "undefined" == typeof window || void 0 === window.localStorage) throw new Error("The current environment does not support local storage.");
18452    if (this.LS = window.localStorage, null == t || !t) throw new Error("For local storage, modelPath must not be null, undefined or empty.");
18453    this.modelPath = t, this.keys = ed(this.modelPath);
18454  }
18455
18456  return t.prototype.save = function (t) {
18457    return n(this, void 0, void 0, function () {
18458      var e, n, o;
18459      return r(this, function (r) {
18460        if (t.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");
18461        e = JSON.stringify(t.modelTopology), n = JSON.stringify(t.weightSpecs), o = Mf(t);
18462
18463        try {
18464          return this.LS.setItem(this.keys.info, JSON.stringify(o)), this.LS.setItem(this.keys.topology, e), this.LS.setItem(this.keys.weightSpecs, n), this.LS.setItem(this.keys.weightData, function (t) {
18465            if (Nf) return Buffer.from(t).toString("base64");
18466
18467            for (var e = new Uint8Array(t), n = "", r = 0, o = e.length; r < o; r++) n += String.fromCharCode(e[r]);
18468
18469            return btoa(n);
18470          }(t.weightData)), this.LS.setItem(this.keys.modelMetadata, JSON.stringify({
18471            format: t.format,
18472            generatedBy: t.generatedBy,
18473            convertedBy: t.convertedBy,
18474            userDefinedMetadata: t.userDefinedMetadata
18475          })), [2, {
18476            modelArtifactsInfo: o
18477          }];
18478        } catch (t) {
18479          throw this.LS.removeItem(this.keys.info), this.LS.removeItem(this.keys.topology), this.LS.removeItem(this.keys.weightSpecs), this.LS.removeItem(this.keys.weightData), this.LS.removeItem(this.keys.modelMetadata), new Error("Failed to save model '" + this.modelPath + "' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=" + o.modelTopologyBytes + ", weightSpecsBytes=" + o.weightSpecsBytes + ", weightDataBytes=" + o.weightDataBytes + ".");
18480        }
18481
18482        return [2];
18483      });
18484    });
18485  }, t.prototype.load = function () {
18486    return n(this, void 0, void 0, function () {
18487      var t, e, n, o, a, i, s;
18488      return r(this, function (r) {
18489        if (null == (t = JSON.parse(this.LS.getItem(this.keys.info)))) throw new Error("In local storage, there is no model with name '" + this.modelPath + "'");
18490        if ("JSON" !== t.modelTopologyType) throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");
18491        if (e = {}, null == (n = JSON.parse(this.LS.getItem(this.keys.topology)))) throw new Error("In local storage, the topology of model '" + this.modelPath + "' is missing.");
18492        if (e.modelTopology = n, null == (o = JSON.parse(this.LS.getItem(this.keys.weightSpecs)))) throw new Error("In local storage, the weight specs of model '" + this.modelPath + "' are missing.");
18493        if (e.weightSpecs = o, null != (a = this.LS.getItem(this.keys.modelMetadata)) && (i = JSON.parse(a), e.format = i.format, e.generatedBy = i.generatedBy, e.convertedBy = i.convertedBy, e.userDefinedMetadata = i.userDefinedMetadata), null == (s = this.LS.getItem(this.keys.weightData))) throw new Error("In local storage, the binary weight values of model '" + this.modelPath + "' are missing.");
18494        return e.weightData = function (t) {
18495          if (Nf) {
18496            var e = Buffer.from(t, "base64");
18497            return e.buffer.slice(e.byteOffset, e.byteOffset + e.byteLength);
18498          }
18499
18500          for (var n = atob(t), r = new Uint8Array(n.length), o = 0; o < n.length;
18500 ++o) r.set([n.charCodeAt(o)], o);
18501
18502          return r.buffer;
18503        }(s), [2, e];
18504      });
18505    });
18506  }, t.URL_SCHEME = "localstorage://", t;
18507}(),
18508    od = function (t) {
18509  return i().getBool("IS_BROWSER") && !Array.isArray(t) && t.startsWith(rd.URL_SCHEME) ? (e = t.slice(rd.URL_SCHEME.length), new rd(e)) : null;
18510  var e;
18511};
18512
18513Bf.registerSaveRouter(od), Bf.registerLoadRouter(od);
18514
18515var ad = function () {
18516  function t() {
18517    C(i().getBool("IS_BROWSER"), function () {
18518      return "Current environment is not a web browser";
18519    }), C("undefined" == typeof window || void 0 !== window.localStorage, function () {
18520      return "Current browser does not appear to support localStorage";
18521    }), this.LS = window.localStorage;
18522  }
18523
18524  return t.prototype.listModels = function () {
18525    return n(this, void 0, void 0, function () {
18526      var t, e, n, o, a, i;
18527      return r(this, function (r) {
18528        for (t = {}, e = Yf + Xf, n = Xf + $f, o = 0; o < this.LS.length; ++o) (a = this.LS.key(o)).startsWith(e) && a.endsWith(n) && (i = nd(a), t[i] = JSON.parse(this.LS.getItem(a)));
18529
18530        return [2, t];
18531      });
18532    });
18533  }, t.prototype.removeModel = function (t) {
18534    return n(this, void 0, void 0, function () {
18535      var e, n;
18536      return r(this, function (r) {
18537        var o;
18538        if (t = (o = t).startsWith(rd.URL_SCHEME) ? o.slice(rd.URL_SCHEME.length) : o, e = ed(t), null == this.LS.getItem(e.info)) throw new Error("Cannot find model at path '" + t + "'");
18539        return n = JSON.parse(this.LS.getItem(e.info)), this.LS.removeItem(e.info), this.LS.removeItem(e.topology), this.LS.removeItem(e.weightSpecs), this.LS.removeItem(e.weightData), [2, n];
18540      });
18541    });
18542  }, t;
18543}();
18544
18545if (i().getBool("IS_BROWSER")) try {
18546  Lf.registerManager(rd.URL_SCHEME, new ad());
18547} catch (t) {}
18548var id = "model",
18549    sd = ".json",
18550    ud = ".weights.bin";
18551
18552function cd(t) {
18553  return new Promise(function (t) {
18554    return setTimeout(t);
18555  }).then(t);
18556}
18557
18558var ld = function () {
18559  function t(e) {
18560    if (!i().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");
18561    e.startsWith(t.URL_SCHEME) && (e = e.slice(t.URL_SCHEME.length)), null != e && 0 !== e.length || (e = id), this.modelTopologyFileName = e + sd, this.weightDataFileName = e + ud;
18562  }
18563
18564  return t.prototype.save = function (t) {
18565    return n(this, void 0, void 0, function () {
18566      var e, n, o, a, i, s;
18567      return r(this, function (r) {
18568        switch (r.label) {
18569          case 0:
18570            if ("undefined" == typeof document) throw new Error("Browser downloads are not supported in this environment since `document` is not present");
18571            if (e = window.URL.createObjectURL(new Blob([t.weightData], {
18572              type: "application/octet-stream"
18573            })), !(t.modelTopology instanceof ArrayBuffer)) return [3, 1];
18574            throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");
18575
18576          case 1:
18577            return n = [{
18578              paths: ["./" + this.weightDataFileName],
18579              weights: t.weightSpecs
18580            }], o = {
18581              modelTopology: t.modelTopology,
18582              format: t.format,
18583              generatedBy: t.generatedBy,
18584              convertedBy: t.convertedBy,
18585              weightsManifest: n
18586            }, a = window.URL.createObjectURL(new Blob([JSON.stringify(o)], {
18587              type: "application/json"
18588            })), (i = null == this.jsonAnchor ? document.createElement("a") : this.jsonAnchor).download = this.modelTopologyFileName, i.href = a, [4, cd(function () {
18589              return i.dispatchEvent(new MouseEvent("click"));
18590            })];
18591
18592          case 2:
18593            return r.sent(), null == t.weightData ? [3, 4] : ((s = null == this.weightDataAnchor ? document.createElement("a") : this.weightDataAnchor).download = this.weightDataFileName, s.href = e, [4, cd(function () {
18594              return s.dispatchEvent(new MouseEvent("click"));
18595            })]);
18596
18597          case 3:
18598            r.sent(), r.label = 4;
18599
18600          case 4:
18601            return [2, {
18602              modelArtifactsInfo: Mf(t)
18603            }];
18604        }
18605      });
18606    });
18607  }, t.URL_SCHEME = "downloads://", t;
18608}(),
18609    hd = function () {
18610  function t(t) {
18611    if (null == t || t.length < 1) throw new Error("When calling browserFiles, at least 1 file is required, but received " + t);
18612    this.files = t;
18613  }
18614
18615  return t.prototype.load = function () {
18616    return n(this, void 0, void 0, function () {
18617      var t,
18618          e,
18619          n = this;
18620      return r(this, function (r) {
18621        return t = this.files[0], e = this.files.slice(1), [2, new Promise(function (r, o) {
18622          var a = new FileReader();
18623          a.onload = function (a) {
18624            var i = JSON.parse(a.target.result),
18625                s = i.modelTopology;
18626
18627            if (null != s) {
18628              0 === e.length && r({
18629                modelTopology: s
18630              });
18631              var u = i.weightsManifest;
18632
18633              if (null != u) {
18634                var c;
18635
18636                try {
18637                  c = n.checkManifestAndWeightFiles(u, e);
18638                } catch (t) {
18639                  return void o(t);
18640                }
18641
18642                var l = [],
18643                    h = [],
18644                    f = [];
18645                u.forEach(function (t) {
18646                  t.paths.forEach(function (t) {
18647                    h.push(t), f.push(null);
18648                  }), l.push.apply(l, t.weights);
18649                }), u.forEach(function (t) {
18650                  t.paths.forEach(function (t) {
18651                    var e = new FileReader();
18652                    e.onload = function (e) {
18653                      var n = e.target.result,
18654                          o = h.indexOf(t);
18655                      f[o] = n, -1 === f.indexOf(null) && r({
18656                        modelTopology: s,
18657                        weightSpecs: l,
18658                        weightData: _f(f),
18659                        format: i.format,
18660                        generatedBy: i.generatedBy,
18661                        convertedBy: i.convertedBy,
18662                        userDefinedMetadata: i.userDefinedMetadata
18663                      });
18664                    }, e.onerror = function (e) {
18665                      return o("Failed to weights data from file of path '" + t + "'.");
18666                    }, e.readAsArrayBuffer(c[t]);
18667                  });
18668                });
18669              } else o(new Error("weightManifest field is missing from file " + t.name));
18670            } else o(new Error("modelTopology field is missing from file " + t.name));
18671          }, a.onerror = function (e) {
18672            return o("Failed to read model topology and weights manifest JSON from file '" + t.name + "'. BrowserFiles supports loading Keras-style tf.Model artifacts only.");
18673          }, a.readAsText(t);
18674        })];
18675      });
18676    });
18677  }, t.prototype.checkManifestAndWeightFiles = function (t, e) {
18678    for (var n = [], r = e.map(function (t) {
18679      return Of(t.name);
18680    }), o = {}, a = 0, i = t; a < i.length; a++) {
18681      i[a].paths.forEach(function (t) {
18682        var a = Of(t);
18683        if (-1 !== n.indexOf(a)) throw new Error("Duplicate file basename found in weights manifest: '" + a + "'");
18684        if (n.push(a), -1 === r.indexOf(a)) throw new Error("Weight file with basename '" + a + "' is not provided.");
18685        o[t] = e[r.indexOf(a)];
18686      });
18687    }
18688
18689    if (n.length !== e.length) throw new Error("Mismatch in the number of files in weights manifest (" + n.length + ") and the number of weight files provided (" + e.length + ").");
18690    return o;
18691  }, t;
18692}();
18693
18694function fd(t, e, n, r) {
18695  !function (t) {
18696    C(null != t && Array.isArray(t) && t.length > 0, function () {
18697      return "promises must be a none empty array";
18698    });
18699  }(t), function (t, e) {
18700    C(t >= 0 && t <= 1, function () {
18701      return "Progress fraction must be in range [0, 1], but got startFraction " + t;
18702    }), C(e >= 0 && e <= 1, function () {
18703      return "Progress fraction must be in range [0, 1], but got endFraction " + e;
18704    }), C(e >= t, function () {
18705      return "startFraction must be no more than endFraction, but got startFraction " + t + " and endFraction " + e;
18706    });
18707  }(n = null == n ? 0 : n, r = null == r ? 1 : r);
18708  var o = 0;
18709  return Promise.all(t.map(function (a) {
18710    return a.then(function (a) {
18711      var i = n + ++o / t.length * (r - n);
18712      return e(i), a;
18713    }), a;
18714  }));
18715}
18716
18717function dd(t, e) {
18718  return n(this, void 0, void 0, function () {
18719    var n, o, a, s, u, c, l, h, f;
18720    return r(this, function (r) {
18721      switch (r.label) {
18722        case 0:
18723          return null == e && (e = {}), n = null == e.fetchFunc ? i().platform.fetch : e.fetchFunc, o = t.map(function (t) {
18724            return n(t, e.requestInit, {
18725              isBinary: !0
18726            });
18727          }), a = 0, s = .5, null != e.onProgress ? [3, 2] : [4, Promise.all(o)];
18728
18729        case 1:
18730          return u = r.sent(), [3, 4];
18731
18732        case 2:
18733          return [4, fd(o, e.onProgress, a, s)];
18734
18735        case 3:
18736          u = r.sent(), r.label = 4;
18737
18738        case 4:
18739          return c = u.map(function (t) {
18740            return t.arrayBuffer();
18741          }), l = .5, h = 1, null != e.onProgress ? [3, 6] : [4, Promise.all(c)];
18742
18743        case 5:
18744          return f = r.sent(), [3, 8];
18745
18746        case 6:
18747          return [4, fd(c, e.onProgress, l, h)];
18748
18749        case 7:
18750          f = r.sent(), r.label = 8;
18751
18752        case 8:
18753          return [2, f];
18754      }
18755    });
18756  });
18757}
18758
18759function pd(t) {
18760  var e = this;
18761  return function (o, a, i) {
18762    return void 0 === a && (a = ""), n(e, void 0, void 0, function () {
18763      var e, n, s, u, c, l, h, f, d, p;
18764      return r(this, function (r) {
18765        switch (r.label) {
18766          case 0:
18767            if (e = o.map(function () {
18768              return !1;
18769            }), n = {}, s = null != i ? i.map(function () {
18770              return !1;
18771            }) : [], u = [], o.forEach(function (t, r) {
18772              var o = 0;
18773              t.weights.forEach(function (t) {
18774                var a = "quantization" in t ? t.quantization.dtype : t.dtype,
18775                    c = Sf[a] * k(t.shape),
18776                    l = function () {
18777                  e[r] = !0, null == n[r] && (n[r] = []), n[r].push({
18778                    manifestEntry: t,
18779                    groupOffset: o,
18780                    sizeBytes: c
18781                  });
18782                };
18783
18784                null != i ? i.forEach(function (e, n) {
18785                  e === t.name && (l(), s[n] = !0);
18786                }) : l(), u.push(t.name), o += c;
18787              });
18788            }), !s.every(function (t) {
18789              return t;
18790            })) throw c = i.filter(function (t, e) {
18791              return !s[e];
18792            }), new Error("Could not find weights in manifest with names: " + c.join(", ") + ". \nManifest JSON has weights with names: " + u.join(", ") + ".");
18793            return l = e.reduce(function (t, e, n) {
18794              return e && t.push(n), t;
18795            }, []), h = [], l.forEach(function (t) {
18796              o[t].paths.forEach(function (t) {
18797                var e = a + (a.endsWith("/") ? "" : "/") + t;
18798                h.push(e);
18799              });
18800            }), [4, t(h)];
18801
18802          case 1:
18803            return f = r.sent(), d = {}, p = 0, l.forEach(function (t) {
18804              for (var e = o[t].paths.length, r = 0, a = 0; a < e; a++) r += f[p + a].byteLength;
18805
18806              for (var i = new ArrayBuffer(r), s = new Uint8Array(i), u = 0, c = 0; c < e; c++) {
18807                var l = new Uint8Array(f[p + c]);
18808                s.set(l, u), u += l.byteLength;
18809              }
18810
18811              n[t].forEach(function (t) {
18812                var e = Tf(i.slice(t.groupOffset, t.groupOffset + t.sizeBytes), [t.manifestEntry]);
18813
18814                for (var n in e) d[n] = e[n];
18815              }), p += e;
18816            }), [2, d];
18817        }
18818      });
18819    });
18820  };
18821}
18822
18823Bf.registerSaveRouter(function (t) {
18824  return i().getBool("IS_BROWSER") && !Array.isArray(t) && t.startsWith(ld.URL_SCHEME) ? function (t) {
18825    void 0 === t && (t = "model");
18826    return new ld(t);
18827  }(t.slice(ld.URL_SCHEME.length)) : null;
18828});
18829
18830var vd = function () {
18831  function t(t, e) {
18832    if (this.DEFAULT_METHOD = "POST", null == e && (e = {}), this.weightPathPrefix = e.weightPathPrefix, this.onProgress = e.onProgress, null != e.fetchFunc ? (C("function" == typeof e.fetchFunc, function () {
18833      return "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)";
18834    }), this.fetch = e.fetchFunc) : this.fetch = i().platform.fetch, C(null != t && t.length > 0, function () {
18835      return "URL path for http must not be null, undefined or empty.";
18836    }), Array.isArray(t) && C(2 === t.length, function () {
18837      return "URL paths for http must have a length of 2, (actual length is " + t.length + ").";
18838    }), this.path = t, null != e.requestInit && null != e.requestInit.body) throw new Error("requestInit is expected to have no pre-existing body, but has one.");
18839    this.requestInit = e.requestInit || {};
18840  }
18841
18842  return t.prototype.save = function (t) {
18843    return n(this, void 0, void 0, function () {
18844      var e, n, o, a;
18845      return r(this, function (r) {
18846        switch (r.label) {
18847          case 0:
18848            if (t.modelTopology instanceof ArrayBuffer) throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");
18849            return (e = Object.assign({
18850              method: this.DEFAULT_METHOD
18851            }, this.requestInit)).body = new FormData(), n = [{
18852              paths: ["./model.weights.bin"],
18853              weights: t.weightSpecs
18854            }], o = {
18855              modelTopology: t.modelTopology,
18856              format: t.format,
18857              generatedBy: t.generatedBy,
18858              convertedBy: t.convertedBy,
18859              userDefinedMetadata: t.userDefinedMetadata,
18860              weightsManifest: n
18861            }, e.body.append("model.json", new Blob([JSON.stringify(o)], {
18862              type: "application/json"
18863            }), "model.json"), null != t.weightData && e.body.append("model.weights.bin", new Blob([t.weightData], {
18864              type: "application/octet-stream"
18865            }), "model.weights.bin"), [4, this.fetch(this.path, e)];
18866
18867          case 1:
18868            if ((a = r.sent()).ok) return [2, {
18869              modelArtifactsInfo: Mf(t),
18870              responses: [a]
18871            }];
18872            throw new Error("BrowserHTTPRequest.save() failed due to HTTP response status " + a.status + ".");
18873        }
18874      });
18875    });
18876  }, t.prototype.load = function () {
18877    return n(this, void 0, void 0, function () {
18878      var t, e, n, o, a, i, s, u, c, l, h, f;
18879      return r(this, function (r) {
18880        switch (r.label) {
18881          case 0:
18882            return [4, this.fetch(this.path, this.requestInit)];
18883
18884          case 1:
18885            if (!(t = r.sent()).ok) throw new Error("Request to " + this.path + " failed with status code " + t.status + ". Please verify this URL points to the model JSON of the model to load.");
18886            r.label = 2;
18887
18888          case 2:
18889            return r.trys.push([2, 4,, 5]), [4, t.json()];
18890
18891          case 3:
18892            return e = r.sent(), [3, 5];
18893
18894          case 4:
18895            throw r.sent(), n = "Failed to parse model JSON of response from " + this.path + ".", this.path.endsWith(".pb") ? n += " Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository." : n += " Please make sure the server is serving valid JSON for this request.", new Error(n);
18896
18897          case 5:
18898            if (o = e.modelTopology, a = e.weightsManifest, i = e.generatedBy, s = e.convertedBy, u = e.format, c = e.userDefinedMetadata, null == o && null == a) throw new Error("The JSON from HTTP path " + this.path + " contains 
18898neither model topology or manifest for weights.");
18899            return null == a ? [3, 7] : [4, this.loadWeights(a)];
18900
18901          case 6:
18902            f = r.sent(), l = f[0], h = f[1], r.label = 7;
18903
18904          case 7:
18905            return [2, {
18906              modelTopology: o,
18907              weightSpecs: l,
18908              weightData: h,
18909              userDefinedMetadata: c,
18910              generatedBy: i,
18911              convertedBy: s,
18912              format: u
18913            }];
18914        }
18915      });
18916    });
18917  }, t.prototype.loadWeights = function (t) {
18918    return n(this, void 0, void 0, function () {
18919      var e, n, o, a, i, s, u, c, l, h, f;
18920      return r(this, function (r) {
18921        switch (r.label) {
18922          case 0:
18923            for (e = Array.isArray(this.path) ? this.path[1] : this.path, n = function (t) {
18924              var e = t.lastIndexOf("/"),
18925                  n = t.lastIndexOf("?"),
18926                  r = t.substring(0, e),
18927                  o = n > e ? t.substring(n) : "";
18928              return [r + "/", o];
18929            }(e), o = n[0], a = n[1], i = this.weightPathPrefix || o, s = [], u = 0, c = t; u < c.length; u++) l = c[u], s.push.apply(s, l.weights);
18930
18931            return h = [], t.forEach(function (t) {
18932              t.paths.forEach(function (t) {
18933                h.push(i + t + a);
18934              });
18935            }), [4, dd(h, {
18936              requestInit: this.requestInit,
18937              fetchFunc: this.fetch,
18938              onProgress: this.onProgress
18939            })];
18940
18941          case 1:
18942            return f = r.sent(), [2, [s, _f(f)]];
18943        }
18944      });
18945    });
18946  }, t.URL_SCHEME_REGEX = /^https?:\/\//, t;
18947}();
18948
18949function md(t) {
18950  return null != t.match(vd.URL_SCHEME_REGEX);
18951}
18952
18953var gd = function (t, e) {
18954  if ("undefined" == typeof fetch) return null;
18955  return (Array.isArray(t) ? t.every(function (t) {
18956    return md(t);
18957  }) : md(t)) ? yd(t, {
18958    onProgress: e
18959  }) : null;
18960};
18961
18962function yd(t, e) {
18963  return new vd(t, e);
18964}
18965
18966Bf.registerSaveRouter(gd), Bf.registerLoadRouter(gd);
18967
18968var xd = function () {
18969  function t(t) {
18970    this.modelArtifacts = t;
18971  }
18972
18973  return t.prototype.load = function () {
18974    return n(this, void 0, void 0, function () {
18975      return r(this, function (t) {
18976        return [2, this.modelArtifacts];
18977      });
18978    });
18979  }, t;
18980}(),
18981    bd = function () {
18982  function t(t) {
18983    this.saveHandler = t;
18984  }
18985
18986  return t.prototype.save = function (t) {
18987    return n(this, void 0, void 0, function () {
18988      return r(this, function (e) {
18989        return [2, this.saveHandler(t)];
18990      });
18991    });
18992  }, t;
18993}();
18994
18995var wd = Object.freeze({
18996  browserFiles: function (t) {
18997    return new hd(t);
18998  },
18999  browserHTTPRequest: function (t, e) {
19000    return yd(t, e);
19001  },
19002  concatenateArrayBuffers: _f,
19003  decodeWeights: Tf,
19004  encodeWeights: function (t, e) {
19005    return n(this, void 0, void 0, function () {
19006      var o,
19007          a,
19008          i,
19009          s,
19010          u,
19011          c = this;
19012      return r(this, function (l) {
19013        switch (l.label) {
19014          case 0:
19015            for (o = [], a = [], i = Array.isArray(t) ? t.map(function (t) {
19016              return t.name;
19017            }) : Object.keys(t), s = function (s) {
19018              var u = i[s],
19019                  l = Array.isArray(t) ? t[s].tensor : t[u];
19020              if ("float32" !== l.dtype && "int32" !== l.dtype && "bool" !== l.dtype && "string" !== l.dtype) throw new Error("Unsupported dtype in weight '" + u + "': " + l.dtype);
19021              var h = {
19022                name: u,
19023                shape: l.shape,
19024                dtype: l.dtype
19025              };
19026
19027              if ("string" === l.dtype) {
19028                var f = new Promise(function (t) {
19029                  return n(c, void 0, void 0, function () {
19030                    var e, n, o, a, i, s, u;
19031                    return r(this, function (r) {
19032                      switch (r.label) {
19033                        case 0:
19034                          return [4, l.bytes()];
19035
19036                        case 1:
19037                          for (e = r.sent(), n = e.reduce(function (t, e) {
19038                            return t + e.length;
19039                          }, 0) + Af * e.length, o = new Uint8Array(n), a = 0, i = 0; i < e.length; i++) s = e[i], u = new Uint8Array(new Uint32Array([s.length]).buffer), o.set(u, a), a += Af, o.set(s, a), a += s.length;
19040
19041                          return t(o), [2];
19042                      }
19043                    });
19044                  });
19045                });
19046                a.push(f);
19047              } else a.push(l.data());
19048
19049              null != e && (h.group = e), o.push(h);
19050            }, u = 0; u < i.length; ++u) s(u);
19051
19052            return [4, Promise.all(a)];
19053
19054          case 1:
19055            return [2, {
19056              data: Df(l.sent()),
19057              specs: o
19058            }];
19059        }
19060      });
19061    });
19062  },
19063  fromMemory: function (t, e, n, r) {
19064    return 1 === arguments.length ? null != t.modelTopology || null != t.weightSpecs ? new xd(t) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new xd({
19065      modelTopology: t
19066    })) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new xd({
19067      modelTopology: t,
19068      weightSpecs: e,
19069      weightData: n,
19070      trainingConfig: r
19071    }));
19072  },
19073  getLoadHandlers: function (t, e) {
19074    return Bf.getLoadHandlers(t, e);
19075  },
19076  getModelArtifactsInfoForJSON: Mf,
19077  getSaveHandlers: function (t) {
19078    return Bf.getSaveHandlers(t);
19079  },
19080  http: yd,
19081  isHTTPScheme: md,
19082  loadWeights: function (t, e, o, a) {
19083    return void 0 === e && (e = ""), n(this, void 0, void 0, function () {
19084      return r(this, function (n) {
19085        return [2, pd(function (t) {
19086          return dd(t, {
19087            requestInit: a
19088          });
19089        })(t, e, o)];
19090      });
19091    });
19092  },
19093  registerLoadRouter: function (t) {
19094    return Bf.registerLoadRouter(t);
19095  },
19096  registerSaveRouter: function (t) {
19097    return Bf.registerSaveRouter(t);
19098  },
19099  weightsLoaderFactory: pd,
19100  withSaveHandler: function (t) {
19101    return new bd(t);
19102  },
19103  copyModel: function (t, e) {
19104    return n(this, void 0, void 0, function () {
19105      return r(this, function (n) {
19106        return !1, [2, Uf(t, e, !1)];
19107      });
19108    });
19109  },
19110  listModels: function () {
19111    return n(this, void 0, void 0, function () {
19112      var t, e, n, o, a, i, s;
19113      return r(this, function (r) {
19114        switch (r.label) {
19115          case 0:
19116            t = Lf.getSchemes(), e = {}, n = 0, o = t, r.label = 1;
19117
19118          case 1:
19119            return n < o.length ? (a = o[n], [4, Lf.getManager(a).listModels()]) : [3, 4];
19120
19121          case 2:
19122            for (s in i = r.sent()) e[a + Pf + s] = i[s];
19123
19124            r.label = 3;
19125
19126          case 3:
19127            return n++, [3, 1];
19128
19129          case 4:
19130            return [2, e];
19131        }
19132      });
19133    });
19134  },
19135  moveModel: function (t, e) {
19136    return n(this, void 0, void 0, function () {
19137      return r(this, function (n) {
19138        return !0, [2, Uf(t, e, !0)];
19139      });
19140    });
19141  },
19142  removeModel: function (t) {
19143    return n(this, void 0, void 0, function () {
19144      var e;
19145      return r(this, function (n) {
19146        return e = Wf(t), [2, Lf.getManager(e.scheme).removeModel(e.path)];
19147      });
19148    });
19149  }
19150});
19151exports.io = wd;
19152var Cd,
19153    Ed = An({
19154  confusionMatrix_: function (t, e, n) {
19155    var r = mn(t, "labels", "confusionMatrix"),
19156        o = mn(e, "predictions", "confusionMatrix");
19157    C(null == n || n > 0 && Number.isInteger(n), function () {
19158      return "If provided, numClasses must be a positive integer, but got " + n;
19159    }), C(1 === r.rank, function () {
19160      return "Expected the rank of labels to be 1, but got " + r.rank;
19161    }), C(1 === o.rank, function () {
19162      return "Expected the rank of predictions to be 1, but got " + o.rank;
19163    }), C(r.shape[0] === o.shape[0], function () {
19164      return "Mismatch in the number of examples: " + r.shape[0] + " vs. " + o.shape[0] + ". Labels and predictions should have the same number of elements.";
19165    }), C(n > 0 && Number.isInteger(n), function () {
19166      return "numClasses is required to be a positive integer, but got " + n;
19167    });
19168    var a = ic(r.asType("int32"), n),
19169        i = ic(o.asType("int32"), n);
19170    return a.transpose().matMul(i).asType("int32");
19171  }
19172}),
19173    Rd = Object.freeze({
19174  confusionMatrix: Ed
19175});
19176exports.math = Rd;
19177
19178var Id = An({
19179  fromPixels_: function (t, e) {
19180    if (void 0 === e && (e = 3), e > 4) throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");
19181    if (null == t) throw new Error("pixels passed to tf.browser.fromPixels() can not be null");
19182    var n = !1,
19183        r = !1,
19184        o = !1,
19185        a = !1,
19186        i = !1;
19187    if (t.data instanceof Uint8Array) n = !0;else if ("undefined" != typeof ImageData && t instanceof ImageData) r = !0;else if ("undefined" != typeof HTMLVideoElement && t instanceof HTMLVideoElement) o = !0;else if ("undefined" != typeof HTMLImageElement && t instanceof HTMLImageElement) a = !0;else {
19188      if (null == t.getContext) throw new Error("pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was " + t.constructor.name);
19189      i = !0;
19190    }
19191
19192    if (o) {
19193      if (o && t.readyState < 2) throw new Error("The video element has not loaded data yet. Please wait for `loadeddata` event on the <video> element.");
19194    }
19195
19196    if (null != l("FromPixels", Lt.backendName)) return Lt.runKernel("FromPixels", {
19197      pixels: t
19198    }, {
19199      numChannels: e
19200    });
19201    var s,
19202        u,
19203        c = o ? [t.videoWidth, t.videoHeight] : [t.width, t.height],
19204        h = c[0],
19205        f = c[1];
19206    if (i ? s = t.getContext("2d").getImageData(0, 0, h, f).data : r || n ? s = t.data : (a || o) && (null == Cd && (Cd = document.createElement("canvas").getContext("2d")), Cd.canvas.width = h, Cd.canvas.height = f, Cd.drawImage(t, 0, 0, h, f), s = Cd.getImageData(0, 0, h, f).data), 4 === e) u = new Int32Array(s);else {
19207      var d = h * f;
19208      u = new Int32Array(d * e);
19209
19210      for (var p = 0; p < d; p++) for (var v = 0; v < e; ++v) u[p * e + v] = s[4 * p + v];
19211    }
19212    return Pn(u, [f, h, e], "int32");
19213  }
19214}),
19215    kd = Object.freeze({
19216  toPixels: function (t, e) {
19217    return n(this, void 0, void 0, function () {
19218      var n, o, a, i, s, u, c, l, h, f, d, p, v, m, g, y, x, b, w, C, E, R, I;
19219      return r(this, function (r) {
19220        switch (r.label) {
19221          case 0:
19222            if (n = mn(t, "img", "toPixels"), t instanceof wt || (n = n.toInt()), 2 !== n.rank && 3 !== n.rank) throw new Error("toPixels only supports rank 2 or 3 tensors, got rank " + n.rank + ".");
19223            if (o = n.shape.slice(0, 2), a = o[0], i = o[1], (s = 2 === n.rank ? 1 : n.shape[2]) > 4 || 2 === s) throw new Error("toPixels only supports depth of size 1, 3 or 4 but got " + s);
19224            return [4, n.data()];
19225
19226          case 1:
19227            return u = r.sent(), c = n.min(), l = n.max(), [4, Promise.all([c.data(), l.data()])];
19228
19229          case 2:
19230            if (h = r.sent(), f = h[0], d = h[1], p = f[0], v = d[0], c.dispose(), l.dispose(), "float32" === n.dtype) {
19231              if (p < 0 || v > 1) throw new Error("Tensor values for a float32 Tensor must be in the range [0 - 1] but got range [" + p + " - " + v + "].");
19232            } else {
19233              if ("int32" !== n.dtype) throw new Error("Unsupported type for toPixels: " + n.dtype + ". Please use float32 or int32 tensors.");
19234              if (p < 0 || v > 255) throw new Error("Tensor values for a int32 Tensor must be in the range [0 - 255] but got range [" + p + " - " + v + "].");
19235            }
19236
19237            for (m = "float32" === n.dtype ? 255 : 1, g = new Uint8ClampedArray(i * a * 4), y = 0; y < a * i; ++y) x = void 0, b = void 0, w = void 0, C = void 0, 1 === s ? (x = u[y] * m, b = u[
19237y] * m, w = u[y] * m, C = 255) : 3 === s ? (x = u[3 * y] * m, b = u[3 * y + 1] * m, w = u[3 * y + 2] * m, C = 255) : 4 === s && (x = u[4 * y] * m, b = u[4 * y + 1] * m, w = u[4 * y + 2] * m, C = u[4 * y + 3] * m), g[(E = 4 * y) + 0] = Math.round(x), g[E + 1] = Math.round(b), g[E + 2] = Math.round(w), g[E + 3] = Math.round(C);
19238
19239            return null != e && (e.width = i, e.height = a, R = e.getContext("2d"), I = new ImageData(g, i, a), R.putImageData(I, 0, 0)), n !== t && n.dispose(), [2, g];
19240        }
19241      });
19242    });
19243  },
19244  fromPixels: Id
19245}),
19246    Sd = function () {
19247  function t() {}
19248
19249  return t.prototype.getClassName = function () {
19250    return this.constructor.className;
19251  }, t.fromConfig = function (t, e) {
19252    return new t(e);
19253  }, t;
19254}(),
19255    Ad = function () {
19256  function t() {
19257    this.classNameMap = {};
19258  }
19259
19260  return t.getMap = function () {
19261    return null == t.instance && (t.instance = new t()), t.instance;
19262  }, t.register = function (e) {
19263    t.getMap().classNameMap[e.className] = [e, e.fromConfig];
19264  }, t;
19265}();
19266
19267exports.browser = kd;
19268
19269function Td(t) {
19270  C(null != t.className, function () {
19271    return "Class being registered does not have the static className property defined.";
19272  }), C("string" == typeof t.className, function () {
19273    return "className is required to be a string, but got type " + typeof t.className;
19274  }), C(t.className.length > 0, function () {
19275    return "Class being registered has an empty-string as its className, which is disallowed.";
19276  }), Ad.register(t);
19277}
19278
19279var Dd = Object.freeze({
19280  Serializable: Sd,
19281  SerializationMap: Ad,
19282  registerClass: Td
19283}),
19284    Nd = "1.7.1";
19285exports.version_core = Nd;
19286exports.serialization = Dd;
19287
19288var Fd = Object.freeze({
19289  gpgpu_util: bs,
19290  webgl_util: Ge,
19291  forceHalfFloat: function () {
19292    i().set("WEBGL_FORCE_F16_TEXTURES", !0);
19293  },
19294  MathBackendWebGL: Lu,
19295  setWebGLContext: Kt,
19296  GPGPUContext: ws
19297}),
19298    _d = function (t) {
19299  function o() {
19300    return null !== t && t.apply(this, arguments) || this;
19301  }
19302
19303  return e(o, t), o.prototype.minimize = function (t, e, n) {
19304    void 0 === e && (e = !1);
19305    var r = this.computeGradients(t, n),
19306        o = r.value,
19307        a = r.grads;
19308
19309    if (null != n) {
19310      var i = n.map(function (t) {
19311        return {
19312          name: t.name,
19313          tensor: a[t.name]
19314        };
19315      });
19316      this.applyGradients(i);
19317    } else this.applyGradients(a);
19318
19319    return tn(a), e ? o : (o.dispose(), null);
19320  }, Object.defineProperty(o.prototype, "iterations", {
19321    get: function () {
19322      return null == this.iterations_ && (this.iterations_ = 0), this.iterations_;
19323    },
19324    enumerable: !0,
19325    configurable: !0
19326  }), o.prototype.incrementIterations = function () {
19327    this.iterations_ = this.iterations + 1;
19328  }, o.prototype.computeGradients = function (t, e) {
19329    return ta(t, e);
19330  }, o.prototype.dispose = function () {
19331    null != this.iterations_ && tn(this.iterations_);
19332  }, o.prototype.saveIterations = function () {
19333    return n(this, void 0, void 0, function () {
19334      return r(this, function (t) {
19335        return null == this.iterations_ && (this.iterations_ = 0), [2, {
19336          name: "iter",
19337          tensor: On(this.iterations_, "int32")
19338        }];
19339      });
19340    });
19341  }, o.prototype.getWeights = function () {
19342    return n(this, void 0, void 0, function () {
19343      return r(this, function (t) {
19344        throw new Error("getWeights() is not implemented for this optimizer yet.");
19345      });
19346    });
19347  }, o.prototype.setWeights = function (t) {
19348    return n(this, void 0, void 0, function () {
19349      return r(this, function (t) {
19350        throw new Error("setWeights() is not implemented for this optimizer class " + this.getClassName());
19351      });
19352    });
19353  }, o.prototype.extractIterations = function (t) {
19354    return n(this, void 0, void 0, function () {
19355      var e;
19356      return r(this, function (n) {
19357        switch (n.label) {
19358          case 0:
19359            return e = this, [4, t[0].tensor.data()];
19360
19361          case 1:
19362            return e.iterations_ = n.sent()[0], [2, t.slice(1)];
19363        }
19364      });
19365    });
19366  }, o;
19367}(Sd);
19368
19369exports.Optimizer = _d;
19370exports.webgl = Fd;
19371Object.defineProperty(_d, Symbol.hasInstance, {
19372  value: function (t) {
19373    return null != t.minimize && null != t.computeGradients && null != t.applyGradients;
19374  }
19375});
19376
19377var Od = function (t) {
19378  function o(e, n, r) {
19379    void 0 === r && (r = null);
19380    var o = t.call(this) || this;
19381    return o.learningRate = e, o.rho = n, o.epsilon = r, o.accumulatedGrads = [], o.accumulatedUpdates = [], null == r && (o.epsilon = Lt.backend.epsilon()), o;
19382  }
19383
19384  return e(o, t), o.prototype.applyGradients = function (t) {
19385    var e = this;
19386    (Array.isArray(t) ? t.map(function (t) {
19387      return t.name;
19388    }
19388) : Object.keys(t)).forEach(function (n, r) {
19389      var o = Lt.registeredVariables[n];
19390      null == e.accumulatedGrads[r] && (e.accumulatedGrads[r] = {
19391        originalName: n + "/accum_grad",
19392        variable: Ze(function () {
19393          return Xn(o).variable(!1);
19394        })
19395      }), null == e.accumulatedUpdates[r] && (e.accumulatedUpdates[r] = {
19396        originalName: n + "/accum_var",
19397        variable: Ze(function () {
19398          return Xn(o).variable(!1);
19399        })
19400      });
19401      var a = Array.isArray(t) ? t[r].tensor : t[n];
19402
19403      if (null != a) {
19404        var i = e.accumulatedGrads[r].variable,
19405            s = e.accumulatedUpdates[r].variable;
19406        Ze(function () {
19407          var t = i.mul(e.rho).add(a.square().mul(1 - e.rho)),
19408              n = s.add(e.epsilon).sqrt().div(i.add(e.epsilon).sqrt()).mul(a),
19409              r = s.mul(e.rho).add(n.square().mul(1 - e.rho));
19410          i.assign(t), s.assign(r);
19411          var u = n.mul(-e.learningRate).add(o);
19412          o.assign(u);
19413        });
19414      }
19415    }), this.incrementIterations();
19416  }, o.prototype.dispose = function () {
19417    null != this.accumulatedUpdates && (tn(this.accumulatedGrads.map(function (t) {
19418      return t.variable;
19419    })), tn(this.accumulatedUpdates.map(function (t) {
19420      return t.variable;
19421    })));
19422  }, o.prototype.getWeights = function () {
19423    return n(this, void 0, void 0, function () {
19424      var t;
19425      return r(this, function (e) {
19426        switch (e.label) {
19427          case 0:
19428            return t = this.accumulatedGrads.concat(this.accumulatedUpdates), [4, this.saveIterations()];
19429
19430          case 1:
19431            return [2, [e.sent()].concat(t.map(function (t) {
19432              return {
19433                name: t.originalName,
19434                tensor: t.variable
19435              };
19436            }))];
19437        }
19438      });
19439    });
19440  }, o.prototype.setWeights = function (t) {
19441    return n(this, void 0, void 0, function () {
19442      var e;
19443      return r(this, function (n) {
19444        switch (n.label) {
19445          case 0:
19446            return [4, this.extractIterations(t)];
19447
19448          case 1:
19449            return t = n.sent(), e = t.length / 2, !1, this.accumulatedGrads = t.slice(0, e).map(function (t) {
19450              return {
19451                originalName: t.name,
19452                variable: t.tensor.variable(!1)
19453              };
19454            }), this.accumulatedUpdates = t.slice(e, 2 * e).map(function (t) {
19455              return {
19456                originalName: t.name,
19457                variable: t.tensor.variable(!1)
19458              };
19459            }), [2];
19460        }
19461      });
19462    });
19463  }, o.prototype.getConfig = function () {
19464    return {
19465      learningRate: this.learningRate,
19466      rho: this.rho,
19467      epsilon: this.epsilon
19468    };
19469  }, o.fromConfig = function (t, e) {
19470    return new t(e.learningRate, e.rho, e.epsilon);
19471  }, o.className = "Adadelta", o;
19472}(_d);
19473
19474exports.AdadeltaOptimizer = Od;
19475Td(Od);
19476
19477var Md = function (t) {
19478  function o(e, n) {
19479    void 0 === n && (n = .1);
19480    var r = t.call(this) || this;
19481    return r.learningRate = e, r.initialAccumulatorValue = n, r.accumulatedGrads = [], r;
19482  }
19483
19484  return e(o, t), o.prototype.applyGradients = function (t) {
19485    var e = this;
19486    (Array.isArray(t) ? t.map(function (t) {
19487      return t.name;
19488    }) : Object.keys(t)).forEach(function (n, r) {
19489      var o = Lt.registeredVariables[n];
19490
19491      if (null == e.accumulatedGrads[r]) {
19492        e.accumulatedGrads[r] = {
19493          originalName: n + "/accumulator",
19494          variable: Ze(function () {
19495            return Hn(o.shape, e.initialAccumulatorValue).variable(!1);
19496          })
19497        };
19498      }
19499
19500      var a = Array.isArray(t) ? t[r].tensor : t[n];
19501
19502      if (null != a) {
19503        var i = e.accumulatedGrads[r].variable;
19504        Ze(function () {
19505          var t = i.add(a.square());
19506          i.assign(t);
19507          var n = a.div(t.add(Lt.backend.epsilon()).sqrt()).mul(-e.learningRate).add(o);
19508          o.assign(n);
19509        });
19510      }
19511    }), this.incrementIterations();
19512  }, o.prototype.dispose = function () {
19513    null != this.accumulatedGrads && tn(this.accumulatedGrads.map(function (t) {
19514      return t.variable;
19515    }));
19516  }, o.prototype.getWeights = function () {
19517    return n(this, void 0, void 0, function () {
19518      return r(this, function (t) {
19519        switch (t.label) {
19520          case 0:
19521            return [4, this.saveIterations()];
19522
19523          case 1:
19524            return [2, [t.sent()].concat(this.accumulatedGrads.map(function (t) {
19525              return {
19526                name: t.originalName,
19527                tensor: t.variable
19528              };
19529            }))];
19530        }
19531      });
19532    });
19533  }, o.prototype.setWeights = function (t) {
19534    return n(this, void 0, void 0, function () {
19535      return r(this, function (e) {
19536        switch (e.label) {
19537          case 0:
19538            return [4, this.extractIterations(t)];
19539
19540          case 1:
19541            return t = e.sent(), !1, this.accumulatedGrads = t.map(function (t) {
19542              return {
19543                originalName: t.name,
19544                variable: t.tensor.variable(!1)
19545              };
19546            }), [2];
19547        }
19548      });
19549    });
19550  }, o.prototype.getConfig = function () {
19551    return {
19552      learningRate: this.learningRate,
19553      initialAccumulatorValue: this.initialAccumulatorValue
19554    };
19555  }, o.fromConfig = function (t, e) {
19556    return new t(e.learningRate, e.initialAccumulatorValue);
19557  }, o.className = "Adagrad", o;
19558}(_d);
19559
19560exports.AdagradOptimizer = Md;
19561Td(Md);
19562
19563var Bd = function (t) {
19564  function o(e, n, r, o) {
19565    void 0 === o && (o = null);
19566    var a = t.call(this) || this;
19567    return a.learningRate = e, a.beta1 = n, a.beta2 = r, a.epsilon = o, a.accumulatedFirstMoment = [], a.accumulatedSecondMoment = [], Ze(function () {
19568      a.accBeta1 = On(n).variable(), a.accBeta2 = On(r).variable();
19569    }), null == o && (a.epsilon = Lt.backend.epsilon()), a;
19570  }
19571
19572  return e(o, t), o.prototype.applyGradients = function (t) {
19573    var e = this,
19574        n = Array.isArray(t) ? t.map(function (t) {
19575      return t.name;
19576    }) : Object.keys(t);
19577    Ze(function () {
19578      var r = No(1, e.accBeta1),
19579          o = No(1, e.accBeta2);
19580      n.forEach(function (n, a) {
19581        var i = Lt.registeredVariables[n];
19582        null == e.accumulatedFirstMoment[a] && (e.accumulatedFirstMoment[a] = {
19583          originalName: n + "/m",
19584          variable: Ze(function () {
19585            return Xn(i).variable(!1);
19586          })
19587        }), null == e.accumulatedSecondMoment[a] && (e.accumulatedSecondMoment[a] = {
19588          originalName: n + "/v",
19589          variable: Ze(function () {
19590            return Xn(i).variable(!1);
19591          })
19592        });
19593        var s = Array.isArray(t) ? t[a].tensor : t[n];
19594
19595        if (null != s) {
19596          var u = e.accumulatedFirstMoment[a].variable,
19597              c = e.accumulatedSecondMoment[a].variable,
19598              l = u.mul(e.beta1).add(s.mul(1 - e.beta1)),
19599              h = c.mul(e.beta2).add(s.square().mul(1 - e.beta2)),
19600              f = l.div(r),
19601              d = h.div(o);
19602          u.assign(l), c.assign(h);
19603          var p = f.div(d.sqrt().add(e.epsilon)).mul(-e.learningRate).add(i);
19604          i.assign(p);
19605        }
19606      }), e.accBeta1.assign(e.accBeta1.mul(e.beta1)), e.accBeta2.assign(e.accBeta2.mul(e.beta2));
19607    }), this.incrementIterations();
19608  }, o.prototype.dispose = function () {
19609    this.accBeta1.dispose(), this.accBeta2.dispose(), null != this.accumulatedFirstMoment && tn(this.accumulatedFirstMoment.map(function (t) {
19610      return t.variable;
19611    })), null != this.accumulatedSecondMoment && tn(this.accumulatedSecondMoment.map(function (t) {
19612      return t.variable;
19613    }));
19614  }, o.prototype.getWeights = function () {
19615    return n(this, void 0, void 0, function () {
19616      var t;
19617      return r(this, function (e) {
19618        switch (e.label) {
19619          case 0:
19620            return t = this.accumulatedFirstMoment.concat(this.accumulatedSecondMoment), [4, this.saveIterations()];
19621
19622          case 1:
19623            return [2, [e.sent()].concat(t.map(function (t) {
19624              return {
19625                name: t.originalName,
19626                tensor: t.variable
19627              };
19628            }))];
19629        }
19630      });
19631    });
19632  }, o.prototype.setWeights = function (t) {
19633    return n(this, void 0, void 0, function () {
19634      var e,
19635          n = this;
19636      return r(this, function (r) {
19637        switch (r.label) {
19638          case 0:
19639            return [4, this.extractIterations(t)];
19640
19641          case 1:
19642            return t = r.sent(), Ze(function () {
19643              n.accBeta1.assign(Ao(n.beta1, n.iterations_ + 1)), n.accBeta2.assign(Ao(n.beta2, n.iterations_ + 1));
19644            }), e = t.length / 2, !1, this.accumulatedFirstMoment = t.slice(0, e).map(function (t) {
19645              return {
19646                originalName: t.name,
19647                variable: t.tensor.variable(!1)
19648              };
19649            }), this.accumulatedSecondMoment = t.slice(e, 2 * e).map(function (t) {
19650              return {
19651                originalName: t.name,
19652                variable: t.tensor.variable(!1)
19653              };
19654            }), [2];
19655        }
19656      });
19657    });
19658  }, o.prototype.getConfig = function () {
19659    return {
19660      learningRate: this.learningRate,
19661      beta1: this.beta1,
19662      beta2: this.beta2,
19663      epsilon: this.epsilon
19664    };
19665  }, o.fromConfig = function (t, e) {
19666    return new t(e.learningRate, e.beta1, e.beta2, e.epsilon);
19667  }, o.className = "Adam", o;
19668}(_d);
19669
19670exports.AdamOptimizer = Bd;
19671Td(Bd);
19672
19673var Pd = function (t) {
19674  function o(e, n, r, o, a) {
19675    void 0 === o && (o = null), void 0 === a && (a = 0);
19676    var i = t.call(this) || this;
19677    return i.learningRate = e, i.beta1 = n, i.beta2 = r, i.epsilon = o, i.decay = a, i.accumulatedFirstMoment = [], i.accumulatedWeightedInfNorm = [], Ze(function () {
19678      i.iteration = On(0).variable(), i.accBeta1 = On(n).variable();
19679    }), null == o && (i.epsilon = Lt.backend.epsilon()), i;
19680  }
19681
19682  return e(o, t), o.prototype.applyGradients = function (t) {
19683    var e = this,
19684        n = Array.isArray(t) ? t.map(function (t) {
19685      return t.name;
19686    }) : Object.keys(t);
19687    Ze(function () {
19688      var r = No(1, e.accBeta1),
19689          o = _o(-e.learningRate, e.iteration.mul(e.decay).add(1));
19690
19691      n.forEach(function (n, a) {
19692        var i = Lt.registeredVariables[n];
19693        null == e.accumulatedFirstMoment[a] && (e.accumulatedFirstMoment[a] = {
19694          originalName: n + "/m",
19695          variable: Xn(i).variable(!1)
19696        }), null == e.accumulatedWeightedInfNorm[a] && (e.accumulatedWeightedInfNorm[a] = {
19697          originalName: n + "/v",
19698          variable: Xn(i).variable(!1)
19699        });
19700        var s = Array.isArray(t) ? t[a].tensor : t[n];
19701
19702        if (null != s) {
19703          var u = e.accumulatedFirstMoment[a].variable,
19704              c = e.accumulatedWeightedInfNorm[a].variable,
19705              l = u.mul(e.beta1).add(s.mul(1 - e.beta1)),
19706              h = c.mul(e.beta2),
19707              f = s.abs(),
19708              d = h.maximum(f);
19709          u.assign(l), c.assign(d);
19710          var p = o.div(r).mul(l.div(d.add(e.epsilon))).add(i);
19711          i.assign(p);
19712        }
19713      }), e.iteration.assign(e.iteration.add(1)), e.accBeta1.assign(e.accBeta1.mul(e.beta1));
19714    }), this.incrementIterations();
19715  }, o.prototype.dispose = function () {
19716    this.accBeta1.dispose(), this.iteration.dispose(), null != this.accumulatedFirstMoment && tn(this.accumulatedFirstMoment.map(function (t) {
19717      return t.variable;
19718    })), null != this.accumulatedWeightedInfNorm && tn(this.accumulatedWeightedInfNorm.map(function (t) {
19719      return t.variable;
19720    }));
19721  }, o.prototype.getWeights = function () {
19722    return n(this, void 0, void 0, function () {
19723      return r(this, function (t) {
19724        throw new Error("getWeights() is not implemented for Adamax yet.");
19725      });
19726    });
19727  }, o.prototype.setWeights = function (t) {
19728    return n(this, void 0, void 0, function () {
19729      return r(this, function (t) {
19730        throw new Error("setWeights() is not implemented for Adamax yet.");
19731      });
19732    });
19733  }, o.prototype.getConfig = function () {
19734    return {
19735      learningRate: this.learningRate,
19736      beta1: this.beta1,
19737      beta2: this.beta2,
19738      epsilon: this.epsilon,
19739      decay: this.decay
19740    };
19741  }, o.fromConfig = function (t, e) {
19742    return new t(e.learningRate, e.beta1, e.beta2, e.epsilon, e.decay);
19743  }, o.className = "Adamax", o;
19744}(_d);
19745
19746exports.AdamaxOptimizer = Pd;
19747Td(Pd);
19748
19749var Ld = function (t) {
19750  function o(e) {
19751    var n = t.call(this) || this;
19752    return n.learningRate = e, n.setLearningRate(e), n;
19753  }
19754
19755  return e(o, t), o.prototype.applyGradients = function (t) {
19756    var e = this;
19757    (Array.isArray(t) ? t.map(function (t) {
19758      return t.name;
19759    }
19759) : Object.keys(t)).forEach(function (n, r) {
19760      var o = Array.isArray(t) ? t[r].tensor : t[n];
19761
19762      if (null != o) {
19763        var a = Lt.registeredVariables[n];
19764        Ze(function () {
19765          var t = e.c.mul(o).add(a);
19766          a.assign(t);
19767        });
19768      }
19769    }), this.incrementIterations();
19770  }, o.prototype.setLearningRate = function (t) {
19771    this.learningRate = t, null != this.c && this.c.dispose(), this.c = en(On(-t));
19772  }, o.prototype.dispose = function () {
19773    this.c.dispose();
19774  }, o.prototype.getWeights = function () {
19775    return n(this, void 0, void 0, function () {
19776      return r(this, function (t) {
19777        switch (t.label) {
19778          case 0:
19779            return [4, this.saveIterations()];
19780
19781          case 1:
19782            return [2, [t.sent()]];
19783        }
19784      });
19785    });
19786  }, o.prototype.setWeights = function (t) {
19787    return n(this, void 0, void 0, function () {
19788      return r(this, function (e) {
19789        switch (e.label) {
19790          case 0:
19791            return [4, this.extractIterations(t)];
19792
19793          case 1:
19794            if (0 !== (t = e.sent()).length) throw new Error("SGD optimizer does not have settable weights.");
19795            return [2];
19796        }
19797      });
19798    });
19799  }, o.prototype.getConfig = function () {
19800    return {
19801      learningRate: this.learningRate
19802    };
19803  }, o.fromConfig = function (t, e) {
19804    return new t(e.learningRate);
19805  }, o.className = "SGD", o;
19806}(_d);
19807
19808exports.SGDOptimizer = Ld;
19809Td(Ld);
19810
19811var Wd = function (t) {
19812  function o(e, n, r) {
19813    void 0 === r && (r = !1);
19814    var o = t.call(this, e) || this;
19815    return o.learningRate = e, o.momentum = n, o.useNesterov = r, o.accumulations = [], o.m = On(o.momentum), o;
19816  }
19817
19818  return e(o, t), o.prototype.applyGradients = function (t) {
19819    var e = this;
19820    (Array.isArray(t) ? t.map(function (t) {
19821      return t.name;
19822    }) : Object.keys(t)).forEach(function (n, r) {
19823      var o = Lt.registeredVariables[n];
19824
19825      if (null == e.accumulations[r]) {
19826        e.accumulations[r] = {
19827          originalName: n + "/momentum",
19828          variable: Ze(function () {
19829            return Xn(o).variable(!1);
19830          })
19831        };
19832      }
19833
19834      var a = e.accumulations[r].variable,
19835          i = Array.isArray(t) ? t[r].tensor : t[n];
19836      null != i && Ze(function () {
19837        var t,
19838            n = e.m.mul(a).add(i);
19839        t = e.useNesterov ? e.c.mul(i.add(n.mul(e.m))).add(o) : e.c.mul(n).add(o), a.assign(n), o.assign(t);
19840      });
19841    }), this.incrementIterations();
19842  }, o.prototype.dispose = function () {
19843    this.m.dispose(), null != this.accumulations && tn(this.accumulations.map(function (t) {
19844      return t.variable;
19845    }));
19846  }, o.prototype.setMomentum = function (t) {
19847    this.momentum = t;
19848  }, o.prototype.getWeights = function () {
19849    return n(this, void 0, void 0, function () {
19850      return r(this, function (t) {
19851        switch (t.label) {
19852          case 0:
19853            return [4, this.saveIterations()];
19854
19855          case 1:
19856            return [2, [t.sent()].concat(this.accumulations.map(function (t) {
19857              return {
19858                name: t.originalName,
19859                tensor: t.variable
19860              };
19861            }))];
19862        }
19863      });
19864    });
19865  }, o.prototype.setWeights = function (t) {
19866    return n(this, void 0, void 0, function () {
19867      return r(this, function (e) {
19868        switch (e.label) {
19869          case 0:
19870            return [4, this.extractIterations(t)];
19871
19872          case 1:
19873            return t = e.sent(), !1, this.accumulations = t.map(function (t) {
19874              return {
19875                originalName: t.name,
19876                variable: t.tensor.variable(!1)
19877              };
19878            }), [2];
19879        }
19880      });
19881    });
19882  }, o.prototype.getConfig = function () {
19883    return {
19884      learningRate: this.learningRate,
19885      momentum: this.momentum,
19886      useNesterov: this.useNesterov
19887    };
19888  }, o.fromConfig = function (t, e) {
19889    return new t(e.learningRate, e.momentum, e.useNesterov);
19890  }, o.className = "Momentum", o;
19891}(Ld);
19892
19893exports.MomentumOptimizer = Wd;
19894Td(Wd);
19895
19896var Ud = function (t) {
19897  function o(e, n, r, o, a) {
19898    void 0 === n && (n = .9), void 0 === r && (r = 0), void 0 === o && (o = null), void 0 === a && (a = !1);
19899    var i = t.call(this) || this;
19900    if (i.learningRate = e, i.decay = n, i.momentum = r, i.epsilon = o, i.accumulatedMeanSquares = [], i.accumulatedMoments = [], i.accumulatedMeanGrads = [], i.centered = a, null == o && (i.epsilon = Lt.backend.epsilon()), null == e) throw new Error("learningRate for RMSPropOptimizer must be defined.");
19901    return i;
19902  }
19903
19904  return e(o, t), o.prototype.applyGradients = function (t) {
19905    var e = this;
19906    (Array.isArray(t) ? t.map(function (t) {
19907      return t.name;
19908    }
19908) : Object.keys(t)).forEach(function (n, r) {
19909      var o = Lt.registeredVariables[n];
19910      null == e.accumulatedMeanSquares[r] && (e.accumulatedMeanSquares[r] = {
19911        originalName: n + "/rms",
19912        variable: Ze(function () {
19913          return Xn(o).variable(!1);
19914        })
19915      }), null == e.accumulatedMoments[r] && (e.accumulatedMoments[r] = {
19916        originalName: n + "/momentum",
19917        variable: Ze(function () {
19918          return Xn(o).variable(!1);
19919        })
19920      }), null == e.accumulatedMeanGrads[r] && e.centered && (e.accumulatedMeanGrads[r] = {
19921        originalName: n + "/mg",
19922        variable: Ze(function () {
19923          return Xn(o).variable(!1);
19924        })
19925      });
19926      var a = Array.isArray(t) ? t[r].tensor : t[n];
19927
19928      if (null != a) {
19929        var i = e.accumulatedMeanSquares[r].variable,
19930            s = e.accumulatedMoments[r].variable;
19931        Ze(function () {
19932          var t = i.mul(e.decay).add(a.square().mul(1 - e.decay));
19933
19934          if (e.centered) {
19935            var n = e.accumulatedMeanGrads[r].variable,
19936                u = n.mul(e.decay).add(a.mul(1 - e.decay)),
19937                c = s.mul(e.momentum).add(a.mul(e.learningRate).div(t.sub(u.square().add(e.epsilon)).sqrt()));
19938            i.assign(t), n.assign(u), s.assign(c);
19939            var l = o.sub(c);
19940            o.assign(l);
19941          } else {
19942            var h = i.mul(e.decay).add(a.square().mul(1 - e.decay));
19943            c = s.mul(e.momentum).add(a.mul(e.learningRate).div(h.add(e.epsilon).sqrt()));
19944            i.assign(h), s.assign(c);
19945            l = o.sub(c);
19946            o.assign(l);
19947          }
19948        });
19949      }
19950    }), this.incrementIterations();
19951  }, o.prototype.dispose = function () {
19952    null != this.accumulatedMeanSquares && tn(this.accumulatedMeanSquares.map(function (t) {
19953      return t.variable;
19954    })), null != this.accumulatedMeanGrads && this.centered && tn(this.accumulatedMeanGrads.map(function (t) {
19955      return t.variable;
19956    })), null != this.accumulatedMoments && tn(this.accumulatedMoments.map(function (t) {
19957      return t.variable;
19958    }));
19959  }, o.prototype.getWeights = function () {
19960    return n(this, void 0, void 0, function () {
19961      var t;
19962      return r(this, function (e) {
19963        switch (e.label) {
19964          case 0:
19965            return t = this.accumulatedMeanSquares.concat(this.accumulatedMoments), this.centered && t.push.apply(t, this.accumulatedMeanGrads), [4, this.saveIterations()];
19966
19967          case 1:
19968            return [2, [e.sent()].concat(t.map(function (t) {
19969              return {
19970                name: t.originalName,
19971                tensor: t.variable
19972              };
19973            }))];
19974        }
19975      });
19976    });
19977  }, o.prototype.setWeights = function (t) {
19978    return n(this, void 0, void 0, function () {
19979      var e;
19980      return r(this, function (n) {
19981        switch (n.label) {
19982          case 0:
19983            return [4, this.extractIterations(t)];
19984
19985          case 1:
19986            return t = n.sent(), e = this.centered ? t.length / 3 : t.length / 2, !1, this.accumulatedMeanSquares = t.slice(0, e).map(function (t) {
19987              return {
19988                originalName: t.name,
19989                variable: t.tensor.variable(!1)
19990              };
19991            }), this.accumulatedMoments = t.slice(e, 2 * e).map(function (t) {
19992              return {
19993                originalName: t.name,
19994                variable: t.tensor.variable(!1)
19995              };
19996            }), this.centered && (this.accumulatedMeanGrads = t.slice(2 * e, 3 * e).map(function (t) {
19997              return {
19998                originalName: t.name,
19999                variable: t.tensor.variable(!1)
20000              };
20001            })), [2];
20002        }
20003      });
20004    });
20005  }, o.prototype.getConfig = function () {
20006    return {
20007      learningRate: this.learningRate,
20008      decay: this.decay,
20009      momentum: this.momentum,
20010      epsilon: this.epsilon,
20011      centered: this.centered
20012    };
20013  }, o.fromConfig = function (t, e) {
20014    return new t(e.learningRate, e.decay, e.momentum, e.epsilon, e.centered);
20015  }, o.className = "RMSProp", o;
20016}(_d);
20017
20018exports.RMSPropOptimizer = Ud;
20019Td(Ud);
20020
20021var Vd = function () {
20022  function t() {}
20023
20024  return t.sgd = function (t) {
20025    return new Ld(t);
20026  }, t.momentum = function (t, e, n) {
20027    return void 0 === n && (n = !1), new Wd(t, e, n);
20028  }, t.rmsprop = function (t, e, n, r, o) {
20029    return void 0 === e && (e = .9), void 0 === n && (n = 0), void 0 === r && (r = null), void 0 === o && (o = !1), new Ud(t, e, n, r, o);
20030  }, t.adam = function (t, e, n, r) {
20031    return void 0 === t && (t = .001), void 0 === e && (e = .9), void 0 === n && (n = .999), void 0 === r && (r = null), new Bd(t, e, n, r);
20032  }, t.adadelta = function (t, e, n) {
20033    return void 0 === t && (t = .001), void 0 === e && (e = .95), void 0 === n && (n = null), new Od(t, e, n);
20034  }, t.adamax = function (t, e, n, r, o) {
20035    return void 0 === t && (t = .002), void 0 === e && (e = .9), void 0 === n && (n = .999), void 0 === r && (r = null), void 0 === o && (o = 0), new Pd(t, e, n, r, o);
20036  }, t.adagrad = function (t, e) {
20037    return void 0 === e && (e = .1), new Md(t, e);
20038  }, t;
20039}(),
20040    zd = {
20041  sgd: Vd.sgd,
20042  momentum: Vd.momentum,
20043  adadelta: Vd.adadelta,
20044  adagrad: Vd.adagrad,
20045  rmsprop: Vd.rmsprop,
20046  adamax: Vd.adamax,
20047  adam: Vd.adam
20048},
20049    Gd = "undefined" != typeof requestAnimationFrame ? requestAnimationFrame : "undefined" != typeof setImmediate ? setImmediate : function (t) {
20050  return t();
20051};
20052
20053exports.train = zd;
20054
20055function Hd() {
20056  return new Promise(function (t) {
20057    return Gd(function () {
20058      return t();
20059    });
20060  });
20061}
20062
20063wt.prototype.broadcastTo = function (t) {
20064  return Xu(this, t);
20065}, wt.prototype.div = function (t) {
20066  return _o(this, t);
20067}, wt.prototype.divNoNan = function (t) {
20068  return nc(this, t);
20069}, wt.prototype.squaredDifference = function (t) {
20070  return wc(this, t);
20071}, wt.prototype.tile = function (t) {
20072  return rc(this, t);
20073}, wt.prototype.oneHot = function (t, e, n) {
20074  return void 0 === e && (e = 1), void 0 === n && (n = 0), ic(this, t, e, n);
20075}, xt = nf;
20076},{"crypto":"node_modules/parcel-bundler/src/builtins/_empty.js","node-fetch":"node_modules/parcel-bundler/src/builtins/_empty.js","util":"node_modules/parcel-bundler/src/builtins/_empty.js","process":"node_modules/process/browser.js","buffer":"node_modules/buffer/index.js"}],"node_modules/@tensorflow/tfjs-converter/dist/tf-converter.esm.js":[function(require,module,exports) {
20077var Buffer = require("buffer").Buffer;
20078"use strict";
20079
20080Object.defineProperty(exports, "__esModule", {
20081  value: true
20082});
20083exports.loadGraphModel = loadGraphModel;
20084exports.deregisterOp = deregisterOp;
20085exports.registerOp = registerOp;
20086exports.version_converter = exports.GraphModel = void 0;
20087
20088var _tfjsCore = require("@tensorflow/tfjs-core");
20089
20090/**
20091 * @license
20092 * Copyright 2020 Google LLC. All Rights Reserved.
20093 * Licensed under the Apache License, Version 2.0 (the "License");
20094 * you may not use this file except in compliance with the License.
20095 * You may obtain a copy of the License at
20096 *
20097 * http://www.apache.org/licenses/LICENSE-2.0
20098 *
20099 * Unless required by applicable law or agreed to in writing, software
20100 * distributed under the License is distributed on an "AS IS" BASIS,
20101 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20102 * See the License for the specific language governing permissions and
20103 * limitations under the License.
20104 * =============================================================================
20105 */
20106var DataType,
20107    SaverDef,
20108    __assign = function () {
20109  return (__assign = Object.assign || function (e) {
20110    for (var t, a = 1, r = arguments.length; a < r; a++) for (var n in t = arguments[a]) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
20111
20112    return e;
20113  }).apply(this, arguments);
20114};
20115
20116function __awaiter(e, t, a, r) {
20117  return new (a || (a = Promise))(function (n, s) {
20118    function o(e) {
20119      try {
20120        u(r.next(e));
20121      } catch (e) {
20122        s(e);
20123      }
20124    }
20125
20126    function p(e) {
20127      try {
20128        u(r.throw(e));
20129      } catch (e) {
20130        s(e);
20131      }
20132    }
20133
20134    function u(e) {
20135      e.done ? n(e.value) : new a(function (t) {
20136        t(e.value);
20137      }).then(o, p);
20138    }
20139
20140    u((r = r.apply(e, t || [])).next());
20141  });
20142}
20143
20144function __generator(e, t) {
20145  var a,
20146      r,
20147      n,
20148      s,
20149      o = {
20150    label: 0,
20151    sent: function () {
20152      if (1 & n[0]) throw n[1];
20153      return n[1];
20154    },
20155    trys: [],
20156    ops: []
20157  };
20158  return s = {
20159    next: p(0),
20160    throw: p(1),
20161    return: p(2)
20162  }, "function" == typeof Symbol && (s[Symbol.iterator] = function () {
20163    return this;
20164  }), s;
20165
20166  function p(s) {
20167    return function (p) {
20168      return function (s) {
20169        if (a) throw new TypeError("Generator is already executing.");
20170
20171        for (; o;) try {
20172          if (a = 1, r && (n = 2 & s[0] ? r.return : s[0] ? r.throw || ((n = r.return) && n.call(r), 0) : r.next) && !(n = n.call(r, s[1])).done) return n;
20173
20174          switch (r = 0, n && (s = [2 & s[0], n.value]), s[0]) {
20175            case 0:
20176            case 1:
20177              n = s;
20178              break;
20179
20180            case 4:
20181              return o.label++, {
20182                value: s[1],
20183                done: !1
20184              };
20185
20186            case 5:
20187              o.label++, r = s[1], s = [0];
20188              continue;
20189
20190            case 7:
20191              s = o.ops.pop(), o.trys.pop();
20192              continue;
20193
20194            default:
20195              if (!(n = (n = o.trys).length > 0 && n[n.length - 1]) && (6 === s[0] || 2 === s[0])) {
20196                o = 0;
20197                continue;
20198              }
20199
20200              if (3 === s[0] && (!n || s[1] > n[0] && s[1] < n[3])) {
20201                o.label = s[1];
20202                break;
20203              }
20204
20205              if (6 === s[0] && o.label < n[1]) {
20206                o.label = n[1], n = s;
20207                break;
20208              }
20209
20210              if (n && o.label < n[2]) {
20211                o.label = n[2], o.ops.push(s);
20212                break;
20213              }
20214
20215              n[2] && o.ops.pop(), o.trys.pop();
20216              continue;
20217          }
20218
20219          s = t.call(e, o);
20220        } catch (e) {
20221          s = [6, e], r = 0;
20222        } finally {
20223          a = n = 0;
20224        }
20225
20226        if (5 & s[0]) throw s[1];
20227        return {
20228          value: s[0] ? s[1] : void 0,
20229          done: !0
20230        };
20231      }([s, p]);
20232    };
20233  }
20234}
20235
20236!function (e) {
20237  e[e.DT_INVALID = 0] = "DT_INVALID", e[e.DT_FLOAT = 1] = "DT_FLOAT", e[e.DT_DOUBLE = 2] = "DT_DOUBLE", e[e.DT_INT32 = 3] = "DT_INT32", e[e.DT_UINT8 = 4] = "DT_UINT8", e[e.DT_INT16 = 5] = "DT_INT16", e[e.DT_INT8 = 6] = "DT_INT8", e[e.DT_STRING = 7] = "DT_STRING", e[e.DT_COMPLEX64 = 8] = "DT_COMPLEX64", e[e.DT_INT64 = 9] = "DT_INT64", e[e.DT_BOOL = 10] = "DT_BOOL", e[e.DT_QINT8 = 11] = "DT_QINT8", e[e.DT_QUINT8 = 12] = "DT_QUINT8", e[e.DT_QINT32 = 13] = "DT_QINT32", e[e.DT_BFLOAT16 = 14] = "DT_BFLOAT16", e[e.DT_FLOAT_REF = 101] = "DT_FLOAT_REF", e[e.DT_DOUBLE_REF = 102] = "DT_DOUBLE_REF", e[e.DT_INT32_REF = 103] = "DT_INT32_REF", e[e.DT_UINT8_REF = 104] = "DT_UINT8_REF", e[e.DT_INT16_REF = 105] = "DT_INT16_REF", e[e.DT_INT8_REF = 106] = "DT_INT8_REF", e[e.DT_STRING_REF = 107] = "DT_STRING_REF", e[e.DT_COMPLEX64_REF = 108] = "DT_COMPLEX64_REF", e[e.DT_INT64_REF = 109] = "DT_INT64_REF", e[e.DT_BOOL_REF = 110] = "DT_BOOL_REF", e[e.DT_QINT8_REF = 111] = "DT_QINT8_REF", e[e.DT_QUINT8_REF = 112] = "DT_QUINT8_REF", e[e.DT_QINT32_REF = 113] = "DT_QINT32_REF", e[e.DT_BFLOAT16_REF = 114] = "DT_BFLOAT16_REF";
20238}(DataType || (DataType = {})), function (e) {
20239  !function (e) {
20240    e[e.LEGACY = 0] = "LEGACY", e[e.V1 = 1] = "V1", e[e.V2 = 2] = "V2";
20241  }(e.CheckpointFormatVersion || (e.CheckpointFormatVersion = {}));
20242}(SaverDef || (SaverDef = {}));
20243var CUSTOM_OPS = {};
20244
20245function registerOp(e, t) {
20246  var a = {
20247    tfOpName: e,
20248    category: "custom",
20249    inputs: [],
20250    attrs: [],
20251    customExecutor: t
20252  };
20253  CUSTOM_OPS[e] = a;
20254}
20255
20256function getRegisteredOp(e) {
20257  return CUSTOM_OPS[e];
20258}
20259
20260function deregisterOp(e) {
20261  delete CUSTOM_OPS[e];
20262}
20263
20264function getParamValue(e, t, a, r) {
20265  var n = t.inputParams[e];
20266
20267  if (n && void 0 !== n.inputIndexStart) {
20268    var s = n.inputIndexStart,
20269        o = 0 === n.inputIndexEnd ? void 0 : void 0 === n.inputIndexEnd ? s + 1 : n.inputIndexEnd;
20270    if ("tensor" === n.type) return getTensor(t.inputNames[n.inputIndexStart], a, r);
20271    if ("tensors" === n.type) return t.inputNames.slice(s, o).map(function (e) {
20272      return getTensor(e, a, r);
20273    });
20274    var p = Array.prototype.slice.call(getTensor(t.inputNames.slice(s)[0], a, r).dataSync());
20275    return "number" === n.type ? p[0] : p;
20276  }
20277
20278  var u = t.attrParams[e];
20279  return u && u.value;
20280}
20281
20282function getTensor(e, t, a) {
20283  var r = parseNodeName(e),
20284      n = r[0],
20285      s = r[1],
20286      o = a.currentContextIds.find(function (e) {
20287    return !!t[getNodeNameWithContextId(n, e)];
20288  });
20289  return void 0 !== o ? t[getNodeNameWithContextId(n, o)][s] : void 0;
20290}
20291
20292function getTensorsForCurrentContenxt(e, t, a) {
20293  return t[getNodeNameWithContextId(e, a.currentContextId)];
20294}
20295
20296function getNodeNameAndIndex(e, t) {
20297  var a = parseNodeName(e),
20298      r = a[0],
20299      n = a[1];
20300  return [getNodeNameWithContextId(r, t && t.currentContextId), n];
20301}
20302
20303function getNodeNameWithContextId(e, t) {
20304  return t ? e + "-" + t : e;
20305}
20306
20307function parseNodeName(e) {
20308  var t = e.lastIndexOf(":");
20309  return -1 === t ? [e, 0] : [e.substring(0, t), Number(e.substring(t + 1))];
20310}
20311
20312function split$1(e, t) {
20313  for (var a = [], r = 0; r < e.length; r += t) a.push(e.slice(r, r + t));
20314
20315  return a;
20316}
20317
20318var json = [{
20319  tfOpName: "Add",
20320  category: "arithmetic",
20321  inputs: [{
20322    start: 0,
20323    name: "a",
20324    type: "tensor"
20325  }, {
20326    start: 1,
20327    name: "b",
20328    type: "tensor"
20329  }],
20330  attrs: [{
20331    tfName: "T",
20332    name: "dtype",
20333    type: "dtype",
20334    notSupported: !0
20335  }]
20336}, {
20337  tfOpName: "AddV2",
20338  category: "arithmetic",
20339  inputs: [{
20340    start: 0,
20341    name: "a",
20342    type: "tensor"
20343  }, {
20344    start: 1,
20345    name: "b",
20346    type: "tensor"
20347  }],
20348  attrs: [{
20349    tfName: "T",
20350    name: "dtype",
20351    type: "dtype",
20352    notSupported: !0
20353  }]
20354}, {
20355  tfOpName: "AddN",
20356  category: "arithmetic",
20357  inputs: [{
20358    start: 0,
20359    end: 0,
20360    name: "tensors",
20361    type: "tensors"
20362  }]
20363}, {
20364  tfOpName: "BiasAdd",
20365  category: "arithmetic",
20366  inputs: [{
20367    start: 0,
20368    name: "a",
20369    type: "tensor"
20370  }, {
20371    start: 1,
20372    name: "b",
20373    type: "tensor"
20374  }],
20375  attrs: [{
20376    tfName: "T",
20377    name: "dtype",
20378    type: "dtype",
20379    notSupported: !0
20380  }]
20381}, {
20382  tfOpName: "Sub",
20383  category: "arithmetic",
20384  inputs: [{
20385    start: 0,
20386    name: "a",
20387    type: "tensor"
20388  }, {
20389    start: 1,
20390    name: "b",
20391    type: "tensor"
20392  }],
20393  attrs: [{
20394    tfName: "T",
20395    name: "dtype",
20396    type: "dtype",
20397    notSupported: !0
20398  }]
20399}, {
20400  tfOpName: "RealDiv",
20401  category: "arithmetic",
20402  inputs: [{
20403    start: 0,
20404    name: "a",
20405    type: "tensor"
20406  }, {
20407    start: 1,
20408    name: "b",
20409    type: "tensor"
20410  }],
20411  attrs: [{
20412    tfName: "T",
20413    name: "dtype",
20414    type: "dtype",
20415    notSupported: !0
20416  }]
20417}, {
20418  tfOpName: "Div",
20419  category: "arithmetic",
20420  inputs: [{
20421    start: 0,
20422    name: "a",
20423    type: "tensor"
20424  }, {
20425    start: 1,
20426    name: "b",
20427    type: "tensor"
20428  }],
20429  attrs: [{
20430    tfName: "T",
20431    name: "dtype",
20432    type: "dtype",
20433    notSupported: !0
20434  }]
20435}, {
20436  tfOpName: "DivNoNan",
20437  category: "arithmetic",
20438  inputs: [{
20439    start: 0,
20440    name: "a",
20441    type: "tensor"
20442  }, {
20443    start: 1,
20444    name: "b",
20445    type: "tensor"
20446  }],
20447  attrs: [{
20448    tfName: "T",
20449    name: "dtype",
20450    type: "dtype",
20451    notSupported: !0
20452  }]
20453}, {
20454  tfOpName: "FloorDiv",
20455  category: "arithmetic",
20456  inputs: [{
20457    start: 0,
20458    name: "a",
20459    type: "tensor"
20460  }, {
20461    start: 1,
20462    name: "b",
20463    type: "tensor"
20464  }],
20465  attrs: [{
20466    tfName: "T",
20467    name: "dtype",
20468    type: "dtype",
20469    notSupported: !0
20470  }]
20471}, {
20472  tfOpName: "Mul",
20473  category: "arithmetic",
20474  inputs: [{
20475    start: 0,
20476    name: "a",
20477    type: "tensor"
20478  }, {
20479    start: 1,
20480    name: "b",
20481    type: "tensor"
20482  }],
20483  attrs: [{
20484    tfName: "T",
20485    name: "dtype",
20486    type: "dtype",
20487    notSupported: !0
20488  }]
20489}, {
20490  tfOpName: "Maximum",
20491  category: "arithmetic",
20492  inputs: [{
20493    start: 0,
20494    name: "a",
20495    type: "tensor"
20496  }, {
20497    start: 1,
20498    name: "b",
20499    type: "tensor"
20500  }]
20501}, {
20502  tfOpName: "Minimum",
20503  category: "arithmetic",
20504  inputs: [{
20505    start: 0,
20506    name: "a",
20507    type: "tensor"
20508  }, {
20509    start: 1,
20510    name: "b",
20511    type: "tensor"
20512  }]
20513}, {
20514  tfOpName: "Pow",
20515  category: "arithmetic",
20516  inputs: [{
20517    start: 0,
20518    name: "a",
20519    type: "tensor"
20520  }, {
20521    start: 1,
20522    name: "b",
20523    type: "tensor"
20524  }],
20525  attrs: [{
20526    tfName: "T",
20527    name: "dtype",
20528    type: "dtype",
20529    notSupported: !0
20530  }]
20531}, {
20532  tfOpName: "SquaredDifference",
20533  category: "arithmetic",
20534  inputs: [{
20535    start: 0,
20536    name: "a",
20537    type: "tensor"
20538  }, {
20539    start: 1,
20540    name: "b",
20541    type: "tensor"
20542  }],
20543  attrs: [{
20544    tfName: "T",
20545    name: "dtype",
20546    type: "dtype",
20547    notSupported: !0
20548  }]
20549}, {
20550  tfOpName: "Mod",
20551  category: "arithmetic",
20552  inputs: [{
20553    start: 0,
20554    name: "a",
20555    type: "tensor"
20556  }, {
20557    start: 1,
20558    name: "b",
20559    type: "tensor"
20560  }],
20561  attrs: [{
20562    tfName: "T",
20563    name: "dtype",
20564    type: "dtype",
20565    notSupported: !0
20566  }]
20567}, {
20568  tfOpName: "FloorMod",
20569  category: "arithmetic",
20570  inputs: [{
20571    start: 0,
20572    name: "a",
20573    type: "tensor"
20574  }, {
20575    start: 1,
20576    name: "b",
20577    type: "tensor"
20578  }],
20579  attrs: [{
20580    tfName: "T",
20581    name: "dtype",
20582    type: "dtype",
20583    notSupported: !0
20584  }]
20585}],
20586    arithmetic = Object.freeze({
20587  json: json
20588}),
20589    json$1 = [{
20590  tfOpName: "Abs",
20591  category: "basic_math",
20592  inputs: [{
20593    start: 0,
20594    name: "x",
20595    type: "tensor"
20596  }],
20597  attrs: [{
20598    tfName: "T",
20599    name: "dtype",
20600    type: "dtype",
20601    notSupported: !0
20602  }]
20603}, {
20604  tfOpName: "Acos",
20605  category: "basic_math",
20606  inputs: [{
20607    start: 0,
20608    name: "x",
20609    type: "tensor"
20610  }],
20611  attrs: [{
20612    tfName: "T",
20613    name: "dtype",
20614    type: "dtype",
20615    notSupported: !0
20616  }]
20617}, {
20618  tfOpName: "Asin",
20619  category: "basic_math",
20620  inputs: [{
20621    start: 0,
20622    name: "x",
20623    type: "tensor"
20624  }],
20625  attrs: [{
20626    tfName: "T",
20627    name: "dtype",
20628    type: "dtype",
20629    notSupported: !0
20630  }]
20631}, {
20632  tfOpName: "Atan",
20633  category: "basic_math",
20634  inputs: [{
20635    start: 0,
20636    name: "x",
20637    type: "tensor"
20638  }],
20639  attrs: [{
20640    tfName: "T",
20641    name: "dtype",
20642    type: "dtype",
20643    notSupported: !0
20644  }]
20645}, {
20646  tfOpName: "Atan2",
20647  category: "basic_math",
20648  inputs: [{
20649    start: 0,
20650    name: "x",
20651    type: "tensor"
20652  }, {
20653    start: 1,
20654    name: "y",
20655    type: "tensor"
20656  }],
20657  attrs: [{
20658    tfName: "T",
20659    name: "dtype",
20660    type: "dtype",
20661    notSupported: !0
20662  }]
20663}, {
20664  tfOpName: "Ceil",
20665  category: "basic_math",
20666  inputs: [{
20667    start: 0,
20668    name: "x",
20669    type: "tensor"
20670  }],
20671  attrs: [{
20672    tfName: "T",
20673    name: "dtype",
20674    type: "dtype",
20675    notSupported: !0
20676  }]
20677}, {
20678  tfOpName: "ClipByValue",
20679  category: "basic_math",
20680  inputs: [{
20681    start: 0,
20682    name: "x",
20683    type: "tensor"
20684  }],
20685  attrs: [{
20686    tfName: "clip_value_min",
20687    name: "clipValueMin",
20688    type: "number"
20689  }, {
20690    tfName: "clip_value_max",
20691    name: "clipValueMax",
20692    type: "number"
20693  }]
20694}, {
20695  tfOpName: "Complex",
20696  category: "basic_math",
20697  inputs: [{
20698    start: 0,
20699    name: "real",
20700    type: "tensor"
20701  }, {
20702    start: 1,
20703    name: "imag",
20704    type: "tensor"
20705  }],
20706  attrs: [{
20707    tfName: "T",
20708    name: "dtype",
20709    type: "dtype",
20710    notSupported: !0
20711  }]
20712}, {
20713  tfOpName: "ComplexAbs",
20714  category: "basic_math",
20715  inputs: [{
20716    start: 0,
20717    name: "x",
20718    type: "tensor"
20719  }],
20720  attrs: [{
20721    tfName: "T",
20722    name: "dtype",
20723    type: "dtype",
20724    notSupported: !0
20725  }]
20726}, {
20727  tfOpName: "Cos",
20728  category: "basic_math",
20729  inputs: [{
20730    start: 0,
20731    name: "x",
20732    type: "tensor"
20733  }],
20734  attrs: [{
20735    tfName: "T",
20736    name: "dtype",
20737    type: "dtype",
20738    notSupported: !0
20739  }]
20740}, {
20741  tfOpName: "Cosh",
20742  category: "basic_math",
20743  inputs: [{
20744    start: 0,
20745    name: "x",
20746    type: "tensor"
20747  }],
20748  attrs: [{
20749    tfName: "T",
20750    name: "dtype",
20751    type: "dtype",
20752    notSupported: !0
20753  }]
20754}, {
20755  tfOpName: "Elu",
20756  category: "basic_math",
20757  inputs: [{
20758    start: 0,
20759    name: "x",
20760    type: "tensor"
20761  }],
20762  attrs: [{
20763    tfName: "T",
20764    name: "dtype",
20765    type: "dtype",
20766    notSupported: !0
20767  }]
20768}, {
20769  tfOpName: "Exp",
20770  category: "basic_math",
20771  inputs: [{
20772    start: 0,
20773    name: "x",
20774    type: "tensor"
20775  }],
20776  attrs: [{
20777    tfName: "T",
20778    name: "dtype",
20779    type: "dtype",
20780    notSupported: !0
20781  }]
20782}, {
20783  tfOpName: "Floor",
20784  category: "basic_math",
20785  inputs: [{
20786    start: 0,
20787    name: "x",
20788    type: "tensor"
20789  }],
20790  attrs: [{
20791    tfName: "T",
20792    name: "dtype",
20793    type: "dtype",
20794    notSupported: !0
20795  }]
20796}, {
20797  tfOpName: "Log",
20798  category: "basic_math",
20799  inputs: [{
20800    start: 0,
20801    name: "x",
20802    type: "tensor"
20803  }],
20804  attrs: [{
20805    tfName: "T",
20806    name: "dtype",
20807    type: "dtype",
20808    notSupported: !0
20809  }]
20810}, {
20811  tfOpName: "Imag",
20812  category: "basic_math",
20813  inputs: [{
20814    start: 0,
20815    name: "x",
20816    type: "tensor"
20817  }],
20818  attrs: [{
20819    tfName: "T",
20820    name: "dtype",
20821    type: "dtype",
20822    notSupported: !0
20823  }, {
20824    tfName: "Tout",
20825    name: "outputType",
20826    type: "dtype",
20827    notSupported: !0
20828  }]
20829}, {
20830  tfOpName: "Neg",
20831  category: "basic_math",
20832  inputs: [{
20833    start: 0,
20834    name: "x",
20835    type: "tensor"
20836  }],
20837  attrs: [{
20838    tfName: "T",
20839    name: "dtype",
20840    type: "dtype",
20841    notSupported: !0
20842  }]
20843}, {
20844  tfOpName: "Real",
20845  category: "basic_math",
20846  inputs: [{
20847    start: 0,
20848    name: "x",
20849    type: "tensor"
20850  }],
20851  attrs: [{
20852    tfName: "T",
20853    name: "dtype",
20854    type: "dtype",
20855    notSupported: !0
20856  }, {
20857    tfName: "Tout",
20858    name: "outputType",
20859    type: "dtype",
20860    notSupported: !0
20861  }]
20862}, {
20863  tfOpName: "Prelu",
20864  category: "basic_math",
20865  inputs: [{
20866    start: 0,
20867    name: "x",
20868    type: "tensor"
20869  }, {
20870    start: 1,
20871    name: "alpha",
20872    type: "tensor"
20873  }],
20874  attrs: [{
20875    tfName: "T",
20876    name: "dtype",
20877    type: "dtype",
20878    notSupported: !0
20879  }]
20880}, {
20881  tfOpName: "Relu",
20882  category: "basic_math",
20883  inputs: [{
20884    start: 0,
20885    name: "x",
20886    type: "tensor"
20887  }],
20888  attrs: [{
20889    tfName: "T",
20890    name: "dtype",
20891    type: "dtype",
20892    notSupported: !0
20893  }]
20894}, {
20895  tfOpName: "Relu6",
20896  category: "basic_math",
20897  inputs: [{
20898    start: 0,
20899    name: "x",
20900    type: "tensor"
20901  }],
20902  attrs: [{
20903    tfName: "T",
20904    name: "dtype",
20905    type: "dtype",
20906    notSupported: !0
20907  }, {
20908    tfName: "clipValueMin",
20909    name: "clipValueMin",
20910    type: "number",
20911    defaultValue: 0
20912  }, {
20913    tfName: "clipValueMax",
20914    name: "clipValueMax",
20915    type: "number",
20916    defaultValue: 6
20917  }]
20918}, {
20919  tfOpName: "Selu",
20920  category: "basic_math",
20921  inputs: [{
20922    start: 0,
20923    name: "x",
20924    type: "tensor"
20925  }],
20926  attrs: [{
20927    tfName: "T",
20928    name: "dtype",
20929    type: "dtype",
20930    notSupported: !0
20931  }]
20932}, {
20933  tfOpName: "Sigmoid",
20934  category: "basic_math",
20935  inputs: [{
20936    start: 0,
20937    name: "x",
20938    type: "tensor"
20939  }],
20940  attrs: [{
20941    tfName: "T",
20942    name: "dtype",
20943    type: "dtype",
20944    notSupported: !0
20945  }]
20946}, {
20947  tfOpName: "Sin",
20948  category: "basic_math",
20949  inputs: [{
20950    start: 0,
20951    name: "x",
20952    type: "tensor"
20953  }],
20954  attrs: [{
20955    tfName: "T",
20956    name: "dtype",
20957    type: "dtype",
20958    notSupported: !0
20959  }]
20960}, {
20961  tfOpName: "Sinh",
20962  category: "basic_math",
20963  inputs: [{
20964    start: 0,
20965    name: "x",
20966    type: "tensor"
20967  }],
20968  attrs: [{
20969    tfName: "T",
20970    name: "dtype",
20971    type: "dtype",
20972    notSupported: !0
20973  }]
20974}, {
20975  tfOpName: "Sqrt",
20976  category: "basic_math",
20977  inputs: [{
20978    start: 0,
20979    name: "x",
20980    type: "tensor"
20981  }],
20982  attrs: [{
20983    tfName: "T",
20984    name: "dtype",
20985    type: "dtype",
20986    notSupported: !0
20987  }]
20988}, {
20989  tfOpName: "Rsqrt",
20990  category: "basic_math",
20991  inputs: [{
20992    start: 0,
20993    name: "x",
20994    type: "tensor"
20995  }],
20996  attrs: [{
20997    tfName: "T",
20998    name: "dtype",
20999    type: "dtype",
21000    notSupported: !0
21001  }]
21002}, {
21003  tfOpName: "Square",
21004  category: "basic_math",
21005  inputs: [{
21006    start: 0,
21007    name: "x",
21008    type: "tensor"
21009  }],
21010  attrs: [{
21011    tfName: "T",
21012    name: "dtype",
21013    type: "dtype",
21014    notSupported: !0
21015  }]
21016}, {
21017  tfOpName: "Tan",
21018  category: "basic_math",
21019  inputs: [{
21020    start: 0,
21021    name: "x",
21022    type: "tensor"
21023  }],
21024  attrs: [{
21025    tfName: "T",
21026    name: "dtype",
21027    type: "dtype",
21028    notSupported: !0
21029  }]
21030}, {
21031  tfOpName: "Tanh",
21032  category: "basic_math",
21033  inputs: [{
21034    start: 0,
21035    name: "x",
21036    type: "tensor"
21037  }],
21038  attrs: [{
21039    tfName: "T",
21040    name: "dtype",
21041    type: "dtype",
21042    notSupported: !0
21043  }]
21044}, {
21045  tfOpName: "Sign",
21046  category: "basic_math",
21047  inputs: [{
21048    start: 0,
21049    name: "x",
21050    type: "tensor"
21051  }],
21052  attrs: [{
21053    tfName: "T",
21054    name: "dtype",
21055    type: "dtype",
21056    notSupported: !0
21057  }]
21058}, {
21059  tfOpName: "Round",
21060  category: "basic_math",
21061  inputs: [{
21062    start: 0,
21063    name: "x",
21064    type: "tensor"
21065  }],
21066  attrs: [{
21067    tfName: "T",
21068    name: "dtype",
21069    type: "dtype",
21070    notSupported: !0
21071  }]
21072}, {
21073  tfOpName: "Expm1",
21074  category: "basic_math",
21075  inputs: [{
21076    start: 0,
21077    name: "x",
21078    type: "tensor"
21079  }],
21080  attrs: [{
21081    tfName: "T",
21082    name: "dtype",
21083    type: "dtype",
21084    notSupported: !0
21085  }]
21086}, {
21087  tfOpName: "Log1p",
21088  category: "basic_math",
21089  inputs: [{
21090    start: 0,
21091    name: "x",
21092    type: "tensor"
21093  }],
21094  attrs: [{
21095    tfName: "T",
21096    name: "dtype",
21097    type: "dtype",
21098    notSupported: !0
21099  }]
21100}, {
21101  tfOpName: "Reciprocal",
21102  category: "basic_math",
21103  inputs: [{
21104    start: 0,
21105    name: "x",
21106    type: "tensor"
21107  }],
21108  attrs: [{
21109    tfName: "T",
21110    name: "dtype",
21111    type: "dtype",
21112    notSupported: !0
21113  }]
21114}, {
21115  tfOpName: "Softplus",
21116  category: "basic_math",
21117  inputs: [{
21118    start: 0,
21119    name: "x",
21120    type: "tensor"
21121  }],
21122  attrs: [{
21123    tfName: "T",
21124    name: "dtype",
21125    type: "dtype",
21126    notSupported: !0
21127  }]
21128}, {
21129  tfOpName: "Asinh",
21130  category: "basic_math",
21131  inputs: [{
21132    start: 0,
21133    name: "x",
21134    type: "tensor"
21135  }],
21136  attrs: [{
21137    tfName: "T",
21138    name: "dtype",
21139    type: "dtype",
21140    notSupported: !0
21141  }]
21142}, {
21143  tfOpName: "Acosh",
21144  category: "basic_math",
21145  inputs: [{
21146    start: 0,
21147    name: "x",
21148    type: "tensor"
21149  }],
21150  attrs: [{
21151    tfName: "T",
21152    name: "dtype",
21153    type: "dtype",
21154    notSupported: !0
21155  }]
21156}, {
21157  tfOpName: "Atanh",
21158  category: "basic_math",
21159  inputs: [{
21160    start: 0,
21161    name: "x",
21162    type: "tensor"
21163  }],
21164  attrs: [{
21165    tfName: "T",
21166    name: "dtype",
21167    type: "dtype",
21168    notSupported: !0
21169  }]
21170}, {
21171  tfOpName: "Erf",
21172  category: "basic_math",
21173  inputs: [{
21174    start: 0,
21175    name: "x",
21176    type: "tensor"
21177  }],
21178  attrs: [{
21179    tfName: "T",
21180    name: "dtype",
21181    type: "dtype",
21182    notSupported: !0
21183  }]
21184}, {
21185  tfOpName: "Prod",
21186  category: "basic_math",
21187  inputs: [{
21188    start: 0,
21189    name: "x",
21190    type: "tensor"
21191  }, {
21192    start: 1,
21193    name: "axes",
21194    type: "number[]"
21195  }],
21196  attrs: [{
21197    tfName: "keep_dims",
21198    name: "keepDims",
21199    type: "bool",
21200    notSupported: !0
21201  }, {
21202    tfName: "T",
21203    name: "dtype",
21204    type: "dtype",
21205    notSupported: !0
21206  }]
21207}, {
21208  tfOpName: "LeakyRelu",
21209  category: "basic_math",
21210  inputs: [{
21211    start: 0,
21212    name: "x",
21213    type: "tensor"
21214  }],
21215  attrs: [{
21216    tfName: "alpha",
21217    name: "alpha",
21218    type: "number",
21219    defaultValue: .2
21220  }, {
21221    tfName: "T",
21222    name: "dtype",
21223    type: "dtype",
21224    notSupported: !0
21225  }]
21226}],
21227    basicMath = Object.freeze({
21228  json: json$1
21229}),
21230    json$2 = [{
21231  tfOpName: "LoopCond",
21232  category: "control",
21233  inputs: [{
21234    start: 0,
21235    name: "pred",
21236    type: "tensor"
21237  }]
21238}, {
21239  tfOpName: "Switch",
21240  category: "control",
21241  inputs: [{
21242    start: 0,
21243    name: "data",
21244    type: "tensor"
21245  }, {
21246    start: 1,
21247    name: "pred",
21248    type: "tensor"
21249  }]
21250}, {
21251  tfOpName: "Merge",
21252  category: "control",
21253  inputs: [{
21254    start: 0,
21255    end: 0,
21256    name: "tensors",
21257    type: "tensors"
21258  }]
21259}, {
21260  tfOpName: "Enter",
21261  category: "control",
21262  inputs: [{
21263    start: 0,
21264    name: "tensor",
21265    type: "tensor"
21266  }],
21267  attrs: [{
21268    tfName: "T",
21269    name: "dtype",
21270    type: "dtype",
21271    notSupported: !0
21272  }, {
21273    tfName: "frame_name",
21274    name: "frameName",
21275    type: "string"
21276  }, {
21277    tfName: "is_constant",
21278    name: "isConstant",
21279    type: "bool"
21280  }]
21281}, {
21282  tfOpName: "Exit",
21283  category: "control",
21284  inputs: [{
21285    start: 0,
21286    name: "tensor",
21287    type: "tensor"
21288  }],
21289  attrs: [{
21290    tfName: "T",
21291    name: "dtype",
21292    type: "dtype",
21293    notSupported: !0
21294  }]
21295}, {
21296  tfOpName: "NextIteration",
21297  category: "control",
21298  inputs: [{
21299    start: 0,
21300    name: "tensor",
21301    type: "tensor"
21302  }],
21303  attrs: [{
21304    tfName: "T",
21305    name: "dtype",
21306    type: "dtype",
21307    notSupported: !0
21308  }]
21309}, {
21310  tfOpName: "TensorArrayV3",
21311  category: "control",
21312  inputs: [{
21313    start: 0,
21314    name: "size",
21315    type: "number"
21316  }],
21317  attrs: [{
21318    tfName: "dtype",
21319    name: "dtype",
21320    type: "dtype"
21321  }, {
21322    tfName: "element_shape",
21323    name: "elementShape",
21324    type: "shape"
21325  }, {
21326    tfName: "dynamic_size",
21327    name: "dynamicSize",
21328    type: "bool"
21329  }, {
21330    tfName: "clear_after_read",
21331    name: "clearAfterRead",
21332    type: "bool"
21333  }, {
21334    tfName: "identical_element_shapes",
21335    name: "identicalElementShapes",
21336    type: "bool"
21337  }, {
21338    tfName: "tensor_array_name",
21339    name: "name",
21340    type: "string"
21341  }]
21342}, {
21343  tfOpName: "TensorArrayWriteV3",
21344  category: "control",
21345  inputs: [{
21346    start: 0,
21347    name: "tensorArrayId",
21348    type: "number"
21349  }, {
21350    start: 1,
21351    name: "index",
21352    type: "number"
21353  }, {
21354    start: 2,
21355    name: "tensor",
21356    type: "tensor"
21357  }, {
21358    start: 3,
21359    name: "flowIn",
21360    type: "number"
21361  }],
21362  attrs: [{
21363    tfName: "T",
21364    name: "dtype",
21365    type: "dtype",
21366    notSupported: !0
21367  }]
21368}, {
21369  tfOpName: "TensorArrayReadV3",
21370  category: "control",
21371  inputs: [{
21372    start: 0,
21373    name: "tensorArrayId",
21374    type: "number"
21375  }, {
21376    start: 1,
21377    name: "index",
21378    type: "number"
21379  }, {
21380    start: 2,
21381    name: "flowIn",
21382    type: "number"
21383  }],
21384  attrs: [{
21385    tfName: "dtype",
21386    name: "dtype",
21387    type: "dtype",
21388    notSupported: !0
21389  }]
21390}, {
21391  tfOpName: "TensorArrayGatherV3",
21392  category: "control",
21393  inputs: [{
21394    start: 0,
21395    name: "tensorArrayId",
21396    type: "number"
21397  }, {
21398    start: 1,
21399    name: "indices",
21400    type: "number[]"
21401  }, {
21402    start: 2,
21403    name: "flowIn",
21404    type: "number"
21405  }],
21406  attrs: [{
21407    tfName: "dtype",
21408    name: "dtype",
21409    type: "dtype"
21410  }, {
21411    tfName: "element_shape",
21412    name: "elementShape",
21413    type: "shape"
21414  }]
21415}, {
21416  tfOpName: "TensorArrayScatterV3",
21417  category: "control",
21418  inputs: [{
21419    start: 0,
21420    name: "tensorArrayId",
21421    type: "number"
21422  }, {
21423    start: 1,
21424    name: "indices",
21425    type: "number[]"
21426  }, {
21427    start: 2,
21428    name: "tensor",
21429    type: "tensor"
21430  }, {
21431    start: 3,
21432    name: "flowIn",
21433    type: "number"
21434  }],
21435  attrs: [{
21436    tfName: "T",
21437    name: "dtype",
21438    type: "dtype"
21439  }]
21440}, {
21441  tfOpName: "TensorArrayConcatV3",
21442  category: "control",
21443  inputs: [{
21444    start: 0,
21445    name: "tensorArrayId",
21446    type: "number"
21447  }, {
21448    start: 1,
21449    name: "flowIn",
21450    type: "number"
21451  }],
21452  attrs: [{
21453    tfName: "dtype",
21454    name: "dtype",
21455    type: "dtype"
21456  }, {
21457    tfName: "element_shape_except0",
21458    name: "elementShapeExcept0",
21459    type: "shape",
21460    notSupported: !0
21461  }]
21462}, {
21463  tfOpName: "TensorArraySplitV3",
21464  category: "control",
21465  inputs: [{
21466    start: 0,
21467    name: "tensorArrayId",
21468    type: "number"
21469  }, {
21470    start: 1,
21471    name: "tensor",
21472    type: "tensor"
21473  }, {
21474    start: 2,
21475    name: "lengths",
21476    type: "number[]"
21477  }, {
21478    start: 3,
21479    name: "flowIn",
21480    type: "number"
21481  }],
21482  attrs: [{
21483    tfName: "T",
21484    name: "dtype",
21485    type: "dtype"
21486  }]
21487}, {
21488  tfOpName: "TensorArraySizeV3",
21489  category: "control",
21490  inputs: [{
21491    start: 0,
21492    name: "tensorArrayId",
21493    type: "number"
21494  }, {
21495    start: 1,
21496    name: "flowIn",
21497    type: "number"
21498  }]
21499}, {
21500  tfOpName: "TensorArrayCloseV3",
21501  category: "control",
21502  inputs: [{
21503    start: 0,
21504    name: "tensorArrayId",
21505    type: "number"
21506  }]
21507}],
21508    control = Object.freeze({
21509  json: json$2
21510}),
21511    json$3 = [{
21512  tfOpName: "AvgPool",
21513  category: "convolution",
21514  inputs: [{
21515    start: 0,
21516    name: "x",
21517    type: "tensor"
21518  }],
21519  attrs: [{
21520    tfName: "strides",
21521    name: "strides",
21522    type: "number[]"
21523  }, {
21524    tfName: "padding",
21525    name: "pad",
21526    type: "string"
21527  }, {
21528    tfName: "data_format",
21529    name: "dataFormat",
21530    type: "string",
21531    notSupported: !0
21532  }, {
21533    tfName: "ksize",
21534    name: "kernelSize",
21535    type: "number[]"
21536  }, {
21537    tfName: "T",
21538    name: "dtype",
21539    type: "dtype",
21540    notSupported: !0
21541  }]
21542}, {
21543  tfOpName: "MaxPool",
21544  category: "convolution",
21545  inputs: [{
21546    start: 0,
21547    name: "x",
21548    type: "tensor"
21549  }],
21550  attrs: [{
21551    tfName: "strides",
21552    name: "strides",
21553    type: "number[]"
21554  }, {
21555    tfName: "padding",
21556    name: "pad",
21557    type: "string"
21558  }, {
21559    tfName: "data_format",
21560    name: "dataFormat",
21561    type: "string",
21562    notSupported: !0
21563  }, {
21564    tfName: "ksize",
21565    name: "kernelSize",
21566    type: "number[]"
21567  }, {
21568    tfName: "T",
21569    name: "dtype",
21570    type: "dtype",
21571    notSupported: !0
21572  }]
21573}, {
21574  tfOpName: "AvgPool3D",
21575  category: "convolution",
21576  inputs: [{
21577    start: 0,
21578    name: "x",
21579    type: "tensor"
21580  }],
21581  attrs: [{
21582    tfName: "strides",
21583    name: "strides",
21584    type: "number[]"
21585  }, {
21586    tfName: "padding",
21587    name: "pad",
21588    type: "string"
21589  }, {
21590    tfName: "data_format",
21591    name: "dataFormat",
21592    type: "string",
21593    notSupported: !0
21594  }, {
21595    tfName: "ksize",
21596    name: "kernelSize",
21597    type: "number[]"
21598  }, {
21599    tfName: "T",
21600    name: "dtype",
21601    type: "dtype",
21602    notSupported: !0
21603  }]
21604}, {
21605  tfOpName: "MaxPool3D",
21606  category: "convolution",
21607  inputs: [{
21608    start: 0,
21609    name: "x",
21610    type: "tensor"
21611  }],
21612  attrs: [{
21613    tfName: "strides",
21614    name: "strides",
21615    type: "number[]"
21616  }, {
21617    tfName: "padding",
21618    name: "pad",
21619    type: "string"
21620  }, {
21621    tfName: "data_format",
21622    name: "dataFormat",
21623    type: "string",
21624    notSupported: !0
21625  }, {
21626    tfName: "ksize",
21627    name: "kernelSize",
21628    type: "number[]"
21629  }, {
21630    tfName: "T",
21631    name: "dtype",
21632    type: "dtype",
21633    notSupported: !0
21634  }]
21635}, {
21636  tfOpName: "Conv1D",
21637  category: "convolution",
21638  inputs: [{
21639    start: 0,
21640    name: "x",
21641    type: "tensor"
21642  }, {
21643    start: 1,
21644    name: "filter",
21645    type: "tensor"
21646  }],
21647  attrs: [{
21648    tfName: "stride",
21649    name: "stride",
21650    type: "number"
21651  }, {
21652    tfName: "padding",
21653    name: "pad",
21654    type: "string"
21655  }, {
21656    tfName: "data_format",
21657    name: "dataFormat",
21658    type: "string",
21659    defaultValue: "NWC"
21660  }, {
21661    tfName: "T",
21662    name: "dtype",
21663    type: "dtype",
21664    notSupported: !0
21665  }, {
21666    tfName: "dilation",
21667    name: "dilation",
21668    type: "number",
21669    defaultValue: 1
21670  }]
21671}, {
21672  tfOpName: "Conv2D",
21673  category: "convolution",
21674  inputs: [{
21675    start: 0,
21676    name: "x",
21677    type: "tensor"
21678  }, {
21679    start: 1,
21680    name: "filter",
21681    type: "tensor"
21682  }],
21683  attrs: [{
21684    tfName: "T",
21685    name: "dtype",
21686    type: "dtype",
21687    notSupported: !0
21688  }, {
21689    tfName: "strides",
21690    name: "strides",
21691    type: "number[]"
21692  }, {
21693    tfName: "padding",
21694    name: "pad",
21695    type: "string"
21696  }, {
21697    tfName: "useCudnnOnGpu",
21698    name: "useCudnnOnGpu",
21699    type: "bool"
21700  }, {
21701    tfName: "data_format",
21702    name: "dataFormat",
21703    type: "string",
21704    defaultValue: "NHWC"
21705  }, {
21706    tfName: "dilations",
21707    name: "dilations",
21708    type: "number[]"
21709  }]
21710}, {
21711  tfOpName: "_FusedConv2D",
21712  category: "convolution",
21713  inputs: [{
21714    start: 0,
21715    name: "x",
21716    type: "tensor"
21717  }, {
21718    start: 1,
21719    name: "filter",
21720    type: "tensor"
21721  }, {
21722    start: 2,
21723    end: 0,
21724    name: "args",
21725    type: "tensors"
21726  }],
21727  attrs: [{
21728    tfName: "num_args",
21729    name: "numArgs",
21730    type: "number"
21731  }, {
21732    tfName: "T",
21733    name: "dtype",
21734    type: "dtype",
21735    notSupported: !0
21736  }, {
21737    tfName: "strides",
21738    name: "strides",
21739    type: "number[]"
21740  }, {
21741    tfName: "padding",
21742    name: "pad",
21743    type: "string"
21744  }, {
21745    tfName: "explicit_paddings",
21746    name: "explicitPaddings",
21747    type: "number[]",
21748    defaultValue: []
21749  }, {
21750    tfName: "use_cudnn_on_gpu",
21751    name: "useCudnnOnGpu",
21752    type: "bool",
21753    defaultValue: !0
21754  }, {
21755    tfName: "data_format",
21756    name: "dataFormat",
21757    type: "string",
21758    defaultValue: "NHWC"
21759  }, {
21760    tfName: "dilations",
21761    name: "dilations",
21762    type: "number[]",
21763    defaultValue: [1, 1, 1, 1]
21764  }, {
21765    tfName: "fused_ops",
21766    name: "fusedOps",
21767    type: "string[]",
21768    defaultValue: []
21769  }, {
21770    tfName: "epsilon",
21771    name: "epsilon",
21772    type: "number",
21773    defaultValue: 1e-4
21774  }]
21775}, {
21776  tfOpName: "Conv2DBackpropInput",
21777  category: "convolution",
21778  inputs: [{
21779    start: 2,
21780    name: "x",
21781    type: "tensor"
21782  }, {
21783    start: 1,
21784    name: "filter",
21785    type: "tensor"
21786  }, {
21787    start: 0,
21788    name: "outputShape",
21789    type: "number[]"
21790  }],
21791  attrs: [{
21792    tfName: "strides",
21793    name: "strides",
21794    type: "number[]"
21795  }, {
21796    tfName: "padding",
21797    name: "pad",
21798    type: "string"
21799  }, {
21800    tfName: "data_format",
21801    name: "dataFormat",
21802    type: "string",
21803    notSupported: !0
21804  }]
21805}, {
21806  tfOpName: "DepthwiseConv2d",
21807  category: "convolution",
21808  inputs: [{
21809    start: 0,
21810    name: "input",
21811    type: "tensor"
21812  }, {
21813    start: 1,
21814    name: "filter",
21815    type: "tensor"
21816  }],
21817  attrs: [{
21818    tfName: "strides",
21819    name: "strides",
21820    type: "number[]"
21821  }, {
21822    tfName: "padding",
21823    name: "pad",
21824    type: "string"
21825  }, {
21826    tfName: "data_format",
21827    name: "dataFormat",
21828    type: "string",
21829    defaultValue: "NHWC"
21830  }, {
21831    tfName: "dilations",
21832    name: "dilations",
21833    type: "number[]"
21834  }]
21835}, {
21836  tfOpName: "DepthwiseConv2dNative",
21837  category: "convolution",
21838  inputs: [{
21839    start: 0,
21840    name: "input",
21841    type: "tensor"
21842  }, {
21843    start: 1,
21844    name: "filter",
21845    type: "tensor"
21846  }],
21847  attrs: [{
21848    tfName: "strides",
21849    name: "strides",
21850    type: "number[]"
21851  }, {
21852    tfName: "padding",
21853    name: "pad",
21854    type: "string"
21855  }, {
21856    tfName: "data_format",
21857    name: "dataFormat",
21858    type: "string",
21859    defaultValue: "NHWC"
21860  }, {
21861    tfName: "dilations",
21862    name: "dilations",
21863    type: "number[]"
21864  }]
21865}, {
21866  tfOpName: "FusedDepthwiseConv2dNative",
21867  category: "convolution",
21868  inputs: [{
21869    start: 0,
21870    name: "x",
21871    type: "tensor"
21872  }, {
21873    start: 1,
21874    name: "filter",
21875    type: "tensor"
21876  }, {
21877    start: 2,
21878    end: 0,
21879    name: "args",
21880    type: "tensors"
21881  }],
21882  attrs: [{
21883    tfName: "num_args",
21884    name: "numArgs",
21885    type: "number"
21886  }, {
21887    tfName: "T",
21888    name: "dtype",
21889    type: "dtype",
21890    notSupported: !0
21891  }, {
21892    tfName: "strides",
21893    name: "strides",
21894    type: "number[]"
21895  }, {
21896    tfName: "padding",
21897    name: "pad",
21898    type: "string"
21899  }, {
21900    tfName: "data_format",
21901    name: "dataFormat",
21902    type: "string",
21903    defaultValue: "NHWC"
21904  }, {
21905    tfName: "dilations",
21906    name: "dilations",
21907    type: "number[]",
21908    defaultValue: [1, 1, 1, 1]
21909  }, {
21910    tfName: "fused_ops",
21911    name: "fusedOps",
21912    type: "string[]",
21913    defaultValue: []
21914  }]
21915}, {
21916  tfOpName: "Conv3D",
21917  category: "convolution",
21918  inputs: [{
21919    start: 0,
21920    name: "x",
21921    type: "tensor"
21922  }, {
21923    start: 1,
21924    name: "filter",
21925    type: "tensor"
21926  }],
21927  attrs: [{
21928    tfName: "strides",
21929    name: "strides",
21930    type: "number[]"
21931  }, {
21932    tfName: "padding",
21933    name: "pad",
21934    type: "string"
21935  }, {
21936    tfName: "data_format",
21937    name: "dataFormat",
21938    type: "string",
21939    defaultValue: "NHWC"
21940  }, {
21941    tfName: "dilations",
21942    name: "dilations",
21943    type: "number[]"
21944  }]
21945}],
21946    convolution = Object.freeze({
21947  json: json$3
21948}),
21949    json$4 = [{
21950  tfOpName: "Fill",
21951  category: "creation",
21952  inputs: [{
21953    start: 0,
21954    name: "shape",
21955    type: "number[]"
21956  }, {
21957    start: 1,
21958    name: "value",
21959    type: "number"
21960  }],
21961  attrs: [{
21962    tfName: "T",
21963    name: "dtype",
21964    type: "dtype"
21965  }]
21966}, {
21967  tfOpName: "LinSpace",
21968  category: "creation",
21969  inputs: [{
21970    start: 0,
21971    name: "start",
21972    type: "number"
21973  }, {
21974    start: 1,
21975    name: "stop",
21976    type: "number"
21977  }, {
21978    start: 2,
21979    name: "num",
21980    type: "number"
21981  }],
21982  attrs: [{
21983    tfName: "T",
21984    name: "dtype",
21985    type: "dtype",
21986    notSupported: !0
21987  }]
21988}, {
21989  tfOpName: "OneHot",
21990  category: "creation",
21991  inputs: [{
21992    start: 0,
21993    name: "indices",
21994    type: "tensor"
21995  }, {
21996    start: 1,
21997    name: "depth",
21998    type: "number"
21999  }, {
22000    start: 2,
22001    name: "onValue",
22002    type: "number",
22003    defaultValue: 1
22004  }, {
22005    start: 3,
22006    name: "offValue",
22007    type: "number",
22008    defaultValue: 0
22009  }],
22010  attrs: [{
22011    tfName: "axis",
22012    name: "axis",
22013    type: "number",
22014    notSupported: !0
22015  }, {
22016    tfName: "T",
22017    name: "dtype",
22018    type: "dtype",
22019    notSupported: !0
22020  }]
22021}, {
22022  tfOpName: "Ones",
22023  category: "creation",
22024  inputs: [{
22025    start: 0,
22026    name: "shape",
22027    type: "number[]"
22028  }],
22029  attrs: [{
22030    tfName: "T",
22031    name: "dtype",
22032    type: "dtype"
22033  }]
22034}, {
22035  tfOpName: "OnesLike",
22036  category: "creation",
22037  inputs: [{
22038    start: 0,
22039    name: "x",
22040    type: "tensor"
22041  }],
22042  attrs: [{
22043    tfName: "dtype",
22044    name: "dtype",
22045    type: "dtype"
22046  }]
22047}, {
22048  tfOpName: "RandomUniform",
22049  category: "creation",
22050  inputs: [{
22051    start: 0,
22052    name: "shape",
22053    type: "number[]"
22054  }],
22055  attrs: [{
22056    tfName: "minval",
22057    name: "minval",
22058    type: "number",
22059    defaultValue: 0
22060  }, {
22061    tfName: "maxval",
22062    name: "maxval",
22063    type: "number",
22064    defaultValue: 1
22065  }, {
22066    tfName: "dtype",
22067    name: "dtype",
22068    type: "dtype"
22069  }, {
22070    tfName: "seed",
22071    name: "seed",
22072    type: "number",
22073    defaultValue: 0
22074  }, {
22075    tfName: "seed2",
22076    name: "seed2",
22077    type: "number",
22078    defaultValue: 0,
22079    notSupported: !0
22080  }, {
22081    tfName: "T",
22082    name: "T",
22083    type: "number",
22084    notSupported: !0
22085  }]
22086}, {
22087  tfOpName: "Range",
22088  category: "creation",
22089  inputs: [{
22090    start: 0,
22091    name: "start",
22092    type: "number"
22093  }, {
22094    start: 1,
22095    name: "stop",
22096    type: "number"
22097  }, {
22098    start: 2,
22099    name: "step",
22100    type: "number",
22101    defaultValue: 0
22102  }],
22103  attrs: [{
22104    tfName: "Tidx",
22105    name: "dtype",
22106    type: "dtype"
22107  }]
22108}, {
22109  tfOpName: "TruncatedNormal",
22110  category: "creation",
22111  inputs: [{
22112    start: 0,
22113    name: "shape",
22114    type: "number[]"
22115  }],
22116  attrs: [{
22117    tfName: "means",
22118    name: "mean",
22119    type: "number",
22120    defaultValue: 0
22121  }, {
22122    tfName: "stddev",
22123    name: "stdDev",
22124    type: "number",
22125    defaultValue: 1
22126  }, {
22127    tfName: "seed",
22128    name: "seed",
22129    type: "number"
22130  }, {
22131    tfName: "seed2",
22132    name: "seed2",
22133    type: "number",
22134    defaultValue: 0,
22135    notSupported: !0
22136  }, {
22137    tfName: "dtype",
22138    name: "dtype",
22139    type: "dtype"
22140  }, {
22141    tfName: "T",
22142    name: "T",
22143    type: "number",
22144    notSupported: !0
22145  }]
22146}, {
22147  tfOpName: "Zeros",
22148  category: "creation",
22149  inputs: [{
22150    start: 0,
22151    name: "shape",
22152    type: "number[]"
22153  }],
22154  attrs: [{
22155    tfName: "T",
22156    name: "dtype",
22157    type: "dtype"
22158  }]
22159}, {
22160  tfOpName: "ZerosLike",
22161  category: "creation",
22162  inputs: [{
22163    start: 0,
22164    name: "x",
22165    type: "tensor"
22166  }],
22167  attrs: [{
22168    tfName: "T",
22169    name: "dtype",
22170    type: "dtype"
22171  }]
22172}, {
22173  tfOpName: "Multinomial",
22174  category: "creation",
22175  inputs: [{
22176    start: 0,
22177    name: "logits",
22178    type: "tensor"
22179  }, {
22180    start: 1,
22181    name: "numSamples",
22182    type: "number"
22183  }],
22184  attrs: [{
22185    tfName: "seed",
22186    name: "seed",
22187    type: "number"
22188  }, {
22189    tfName: "seed2",
22190    name: "seed2",
22191    type: "number"
22192  }, {
22193    tfName: "T",
22194    name: "dtype",
22195    type: "dtype"
22196  }, {
22197    tfName: "output_dtype",
22198    name: "output_dtype",
22199    type: "dtype"
22200  }]
22201}],
22202    creation = Object.freeze({
22203  json: json$4
22204}),
22205    json$5 = [{
22206  tfOpName: "NonMaxSuppressionV2",
22207  category: "dynamic",
22208  inputs: [{
22209    start: 0,
22210    name: "boxes",
22211    type: "tensor"
22212  }, {
22213    start: 1,
22214    name: "scores",
22215    type: "tensor"
22216  }, {
22217    start: 2,
22218    name: "maxOutputSize",
22219    type: "number"
22220  }, {
22221    start: 3,
22222    name: "iouThreshold",
22223    type: "number"
22224  }]
22225}, {
22226  tfOpName: "NonMaxSuppressionV3",
22227  category: "dynamic",
22228  inputs: [{
22229    start: 0,
22230    name: "boxes",
22231    type: "tensor"
22232  }, {
22233    start: 1,
22234    name: "scores",
22235    type: "tensor"
22236  }, {
22237    start: 2,
22238    name: "maxOutputSize",
22239    type: "number"
22240  }, {
22241    start: 3,
22242    name: "iouThreshold",
22243    type: "number"
22244  }, {
22245    start: 4,
22246    name: "scoreThreshold",
22247    type: "number"
22248  }]
22249}, {
22250  tfOpName: "NonMaxSuppressionV5",
22251  category: "dynamic",
22252  inputs: [{
22253    start: 0,
22254    name: "boxes",
22255    type: "tensor"
22256  }, {
22257    start: 1,
22258    name: "scores",
22259    type: "tensor"
22260  }, {
22261    start: 2,
22262    name: "maxOutputSize",
22263    type: "number"
22264  }, {
22265    start: 3,
22266    name: "iouThreshold",
22267    type: "number"
22268  }, {
22269    start: 4,
22270    name: "scoreThreshold",
22271    type: "number"
22272  }, {
22273    start: 5,
22274    name: "softNmsSigma",
22275    type: "number"
22276  }]
22277}, {
22278  tfOpName: "Where",
22279  category: "dynamic",
22280  inputs: [{
22281    start: 0,
22282    name: "condition",
22283    type: "tensor"
22284  }],
22285  attrs: [{
22286    tfName: "T",
22287    name: "dtype",
22288    type: "dtype",
22289    notSupported: !0
22290  }]
22291}, {
22292  tfOpName: "ListDiff",
22293  category: "dynamic",
22294  inputs: [{
22295    start: 0,
22296    name: "x",
22297    type: "tensor"
22298  }, {
22299    start: 1,
22300    name: "y",
22301    type: "tensor"
22302  }],
22303  attrs: [{
22304    tfName: "T",
22305    name: "dtype",
22306    type: "dtype",
22307    notSupported: !0
22308  }]
22309}],
22310    dynamic = Object.freeze({
22311  json: json$5
22312}),
22313    json$6 = [{
22314  tfOpName: "TopKV2",
22315  category: "evaluation",
22316  inputs: [{
22317    start: 0,
22318    name: "x",
22319    type: "tensor"
22320  }, {
22321    start: 1,
22322    name: "k",
22323    type: "number"
22324  }],
22325  attrs: [{
22326    tfName: "sorted",
22327    name: "sorted",
22328    type: "bool"
22329  }]
22330}],
22331    evaluation = Object.freeze({
22332  json: json$6
22333}),
22334    json$7 = [{
22335  tfOpName: "PlaceholderWithDefault",
22336  category: "graph",
22337  inputs: [{
22338    start: 0,
22339    name: "default",
22340    type: "tensor"
22341  }],
22342  attrs: [{
22343    tfName: "shape",
22344    name: "shape",
22345    type: "shape"
22346  }, {
22347    tfName: "dtype",
22348    name: "dtype",
22349    type: "dtype"
22350  }]
22351}, {
22352  tfOpName: "Placeholder",
22353  category: "graph",
22354  attrs: [{
22355    tfName: "shape",
22356    name: "shape",
22357    type: "shape"
22358  }, {
22359    tfName: "dtype",
22360    name: "dtype",
22361    type: "dtype"
22362  }]
22363}, {
22364  tfOpName: "Const",
22365  category: "graph"
22366}, {
22367  tfOpName: "Identity",
22368  category: "graph",
22369  inputs: [{
22370    start: 0,
22371    name: "x",
22372    type: "tensor"
22373  }]
22374}, {
22375  tfOpName: "IdentityN",
22376  category: "graph",
22377  inputs: [{
22378    start: 0,
22379    end: 0,
22380    name: "x",
22381    type: "tensors"
22382  }]
22383}, {
22384  tfOpName: "Snapshot",
22385  category: "graph",
22386  inputs: [{
22387    start: 0,
22388    name: "x",
22389    type: "tensor"
22390  }]
22391}, {
22392  tfOpName: "Rank",
22393  category: "graph",
22394  inputs: [{
22395    start: 0,
22396    name: "x",
22397    type: "tensor"
22398  }]
22399}, {
22400  tfOpName: "Size",
22401  category: "graph",
22402  inputs: [{
22403    start: 0,
22404    name: "x",
22405    type: "tensor"
22406  }]
22407}, {
22408  tfOpName: "Shape",
22409  category: "graph",
22410  inputs: [{
22411    start: 0,
22412    name: "x",
22413    type: "tensor"
22414  }]
22415}, {
22416  tfOpName: "ShapeN",
22417  category: "graph",
22418  inputs: [{
22419    start: 0,
22420    end: 0,
22421    name: "x",
22422    type: "tensors"
22423  }]
22424}, {
22425  tfOpName: "Print",
22426  category: "graph",
22427  inputs: [{
22428    start: 0,
22429    name: "x",
22430    type: "tensor"
22431  }, {
22432    start: 1,
22433    name: "data",
22434    type: "tensors"
22435  }],
22436  attrs: [{
22437    tfName: "message",
22438    name: "message",
22439    type: "string"
22440  }, {
22441    tfName: "first_n",
22442    name: "firstN",
22443    type: "number",
22444    notSupported: !0
22445  }, {
22446    tfName: "summarize",
22447    name: "summarize",
22448    type: "number",
22449    defaultValue: 3
22450  }]
22451}, {
22452  tfOpName: "NoOp",
22453  category: "graph",
22454  inputs: []
22455}, {
22456  tfOpName: "StopGradient",
22457  category: "graph",
22458  inputs: [{
22459    start: 0,
22460    name: "x",
22461    type: "tensor"
22462  }]
22463}, {
22464  tfOpName: "FakeQuantWithMinMaxVars",
22465  category: "graph",
22466  inputs: [{
22467    start: 0,
22468    name: "x",
22469    type: "tensor"
22470  }],
22471  attrs: [{
22472    tfName: "min",
22473    name: "min",
22474    type: "number"
22475  }, {
22476    tfName: "max",
22477    name: "max",
22478    type: "number"
22479  }]
22480}],
22481    graph = Object.freeze({
22482  json: json$7
22483}),
22484    json$8 = [{
22485  tfOpName: "ResizeBilinear",
22486  category: "image",
22487  inputs: [{
22488    start: 0,
22489    name: "images",
22490    type: "tensor"
22491  }, {
22492    start: 1,
22493    name: "size",
22494    type: "number[]"
22495  }],
22496  attrs: [{
22497    tfName: "align_corners",
22498    name: "alignCorners",
22499    type: "bool"
22500  }, {
22501    tfName: "T",
22502    name: "dtype",
22503    type: "dtype",
22504    notSupported: !0
22505  }]
22506}, {
22507  tfOpName: "ResizeNearestNeighbor",
22508  category: "image",
22509  inputs: [{
22510    start: 0,
22511    name: "images",
22512    type: "tensor"
22513  }, {
22514    start: 1,
22515    name: "size",
22516    type: "number[]"
22517  }],
22518  attrs: [{
22519    tfName: "align_corners",
22520    name: "alignCorners",
22521    type: "bool"
22522  }, {
22523    tfName: "T",
22524    name: "dtype",
22525    type: "dtype",
22526    notSupported: !0
22527  }]
22528}, {
22529  tfOpName: "CropAndResize",
22530  category: "image",
22531  inputs: [{
22532    start: 0,
22533    name: "image",
22534    type: "tensor"
22535  }, {
22536    start: 1,
22537    name: "boxes",
22538    type: "tensor"
22539  }, {
22540    start: 2,
22541    name: "boxInd",
22542    type: "tensor"
22543  }, {
22544    start: 3,
22545    name: "cropSize",
22546    type: "number[]"
22547  }],
22548  attrs: [{
22549    tfName: "method",
22550    name: "method",
22551    type: "string"
22552  }, {
22553    tfName: "extrapolation_value",
22554    name: "extrapolationValue",
22555    type: "number"
22556  }]
22557}],
22558    image$1 = Object.freeze({
22559  json: json$8
22560}),
22561    json$9 = [{
22562  tfOpName: "Equal",
22563  category: "logical",
22564  inputs: [{
22565    start: 0,
22566    name: "a",
22567    type: "tensor"
22568  }, {
22569    start: 1,
22570    name: "b",
22571    type: "tensor"
22572  }],
22573  attrs: [{
22574    tfName: "T",
22575    name: "dtype",
22576    type: "dtype",
22577    notSupported: !0
22578  }]
22579}, {
22580  tfOpName: "NotEqual",
22581  category: "logical",
22582  inputs: [{
22583    start: 0,
22584    name: "a",
22585    type: "tensor"
22586  }, {
22587    start: 1,
22588    name: "b",
22589    type: "tensor"
22590  }],
22591  attrs: [{
22592    tfName: "T",
22593    name: "dtype",
22594    type: "dtype",
22595    notSupported: !0
22596  }]
22597}, {
22598  tfOpName: "Greater",
22599  category: "logical",
22600  inputs: [{
22601    start: 0,
22602    name: "a",
22603    type: "tensor"
22604  }, {
22605    start: 1,
22606    name: "b",
22607    type: "tensor"
22608  }],
22609  attrs: [{
22610    tfName: "T",
22611    name: "dtype",
22612    type: "dtype",
22613    notSupported: !0
22614  }]
22615}, {
22616  tfOpName: "GreaterEqual",
22617  category: "logical",
22618  inputs: [{
22619    start: 0,
22620    name: "a",
22621    type: "tensor"
22622  }, {
22623    start: 1,
22624    name: "b",
22625    type: "tensor"
22626  }],
22627  attrs: [{
22628    tfName: "T",
22629    name: "dtype",
22630    type: "dtype",
22631    notSupported: !0
22632  }]
22633}, {
22634  tfOpName: "Less",
22635  category: "logical",
22636  inputs: [{
22637    start: 0,
22638    name: "a",
22639    type: "tensor"
22640  }, {
22641    start: 1,
22642    name: "b",
22643    type: "tensor"
22644  }],
22645  attrs: [{
22646    tfName: "T",
22647    name: "dtype",
22648    type: "dtype",
22649    notSupported: !0
22650  }]
22651}, {
22652  tfOpName: "LessEqual",
22653  category: "logical",
22654  inputs: [{
22655    start: 0,
22656    name: "a",
22657    type: "tensor"
22658  }, {
22659    start: 1,
22660    name: "b",
22661    type: "tensor"
22662  }],
22663  attrs: [{
22664    tfName: "T",
22665    name: "dtype",
22666    type: "dtype",
22667    notSupported: !0
22668  }]
22669}, {
22670  tfOpName: "LogicalAnd",
22671  category: "logical",
22672  inputs: [{
22673    start: 0,
22674    name: "a",
22675    type: "tensor"
22676  }, {
22677    start: 1,
22678    name: "b",
22679    type: "tensor"
22680  }],
22681  attrs: [{
22682    tfName: "T",
22683    name: "dtype",
22684    type: "dtype",
22685    notSupported: !0
22686  }]
22687}, {
22688  tfOpName: "LogicalNot",
22689  category: "logical",
22690  inputs: [{
22691    start: 0,
22692    name: "a",
22693    type: "tensor"
22694  }],
22695  attrs: [{
22696    tfName: "T",
22697    name: "dtype",
22698    type: "dtype",
22699    notSupported: !0
22700  }]
22701}, {
22702  tfOpName: "LogicalOr",
22703  category: "logical",
22704  inputs: [{
22705    start: 0,
22706    name: "a",
22707    type: "tensor"
22708  }, {
22709    start: 1,
22710    name: "b",
22711    type: "tensor"
22712  }],
22713  attrs: [{
22714    tfName: "T",
22715    name: "dtype",
22716    type: "dtype",
22717    notSupported: !0
22718  }]
22719}, {
22720  tfOpName: "Select",
22721  category: "logical",
22722  inputs: [{
22723    start: 0,
22724    name: "condition",
22725    type: "tensor"
22726  }, {
22727    start: 1,
22728    name: "a",
22729    type: "tensor"
22730  }, {
22731    start: 2,
22732    name: "b",
22733    type: "tensor"
22734  }],
22735  attrs: [{
22736    tfName: "T",
22737    name: "dtype",
22738    type: "dtype",
22739    notSupported: !0
22740  }]
22741}],
22742    logical = Object.freeze({
22743  json: json$9
22744}),
22745    json$10 = [{
22746  tfOpName: "_FusedMatMul",
22747  category: "matrices",
22748  inputs: [{
22749    start: 0,
22750    name: "a",
22751    type: "tensor"
22752  }, {
22753    start: 1,
22754    name: "b",
22755    type: "tensor"
22756  }, {
22757    start: 2,
22758    end: 0,
22759    name: "args",
22760    type: "tensors"
22761  }],
22762  attrs: [{
22763    tfName: "num_args",
22764    name: "numArgs",
22765    type: "number"
22766  }, {
22767    tfName: "fused_ops",
22768    name: "fusedOps",
22769    type: "string[]",
22770    defaultValue: []
22771  }, {
22772    tfName: "epsilon",
22773    name: "epsilon",
22774    type: "number",
22775    defaultValue: 1e-4
22776  }, {
22777    tfName: "transpose_a",
22778    name: "transposeA",
22779    type: "bool",
22780    defaultValue: !1
22781  }, {
22782    tfName: "transpose_b",
22783    name: "transposeB",
22784    type: "bool",
22785    defaultValue: !1
22786  }, {
22787    tfName: "T",
22788    name: "dtype",
22789    type: "dtype",
22790    notSupported: !0
22791  }]
22792}, {
22793  tfOpName: "MatMul",
22794  category: "matrices",
22795  inputs: [{
22796    start: 0,
22797    name: "a",
22798    type: "tensor"
22799  }, {
22800    start: 1,
22801    name: "b",
22802    type: "tensor"
22803  }],
22804  attrs: [{
22805    tfName: "transpose_a",
22806    name: "transposeA",
22807    type: "bool",
22808    defaultValue: !1
22809  }, {
22810    tfName: "transpose_b",
22811    name: "transposeB",
22812    type: "bool",
22813    defaultValue: !1
22814  }, {
22815    tfName: "T",
22816    name: "dtype",
22817    type: "dtype",
22818    notSupported: !0
22819  }]
22820}, {
22821  tfOpName: "BatchMatMul",
22822  category: "matrices",
22823  inputs: [{
22824    start: 0,
22825    name: "a",
22826    type: "tensor"
22827  }, {
22828    start: 1,
22829    name: "b",
22830    type: "tensor"
22831  }],
22832  attrs: [{
22833    tfName: "adj_x",
22834    name: "transposeA",
22835    type: "bool",
22836    defaultValue: !1
22837  }, {
22838    tfName: "adj_y",
22839    name: "transposeB",
22840    type: "bool",
22841    defaultValue: !1
22842  }, {
22843    tfName: "T",
22844    name: "dtype",
22845    type: "dtype",
22846    notSupported: !0
22847  }]
22848}, {
22849  tfOpName: "BatchMatMulV2",
22850  category: "matrices",
22851  inputs: [{
22852    start: 0,
22853    name: "a",
22854    type: "tensor"
22855  }, {
22856    start: 1,
22857    name: "b",
22858    type: "tensor"
22859  }],
22860  attrs: [{
22861    tfName: "adj_x",
22862    name: "transposeA",
22863    type: "bool",
22864    defaultValue: !1
22865  }, {
22866    tfName: "adj_y",
22867    name: "transposeB",
22868    type: "bool",
22869    defaultValue: !1
22870  }, {
22871    tfName: "T",
22872    name: "dtype",
22873    type: "dtype",
22874    notSupported: !0
22875  }]
22876}, {
22877  tfOpName: "Transpose",
22878  category: "matrices",
22879  inputs: [{
22880    start: 0,
22881    name: "x",
22882    type: "tensor"
22883  }, {
22884    start: 1,
22885    name: "perm",
22886    type: "number[]"
22887  }],
22888  attrs: [{
22889    tfName: "T",
22890    name: "dtype",
22891    type: "dtype",
22892    notSupported: !0
22893  }]
22894}],
22895    matrices = Object.freeze({
22896  json: json$10
22897}),
22898    json$11 = [{
22899  tfOpName: "FusedBatchNorm",
22900  category: "normalization",
22901  inputs: [{
22902    start: 0,
22903    name: "x",
22904    type: "tensor"
22905  }, {
22906    start: 1,
22907    name: "scale",
22908    type: "tensor"
22909  }, {
22910    start: 2,
22911    name: "offset",
22912    type: "tensor"
22913  }, {
22914    start: 3,
22915    name: "mean",
22916    type: "tensor"
22917  }, {
22918    start: 4,
22919    name: "variance",
22920    type: "tensor"
22921  }],
22922  attrs: [{
22923    tfName: "epsilon",
22924    name: "epsilon",
22925    type: "number",
22926    defaultValue: .001
22927  }, {
22928    tfName: "data_format",
22929    name: "dataFormat",
22930    type: "string",
22931    notSupported: !0
22932  }]
22933}, {
22934  tfOpName: "FusedBatchNormV2",
22935  category: "normalization",
22936  inputs: [{
22937    start: 0,
22938    name: "x",
22939    type: "tensor"
22940  }, {
22941    start: 1,
22942    name: "scale",
22943    type: "tensor"
22944  }, {
22945    start: 2,
22946    name: "offset",
22947    type: "tensor"
22948  }, {
22949    start: 3,
22950    name: "mean",
22951    type: "tensor"
22952  }, {
22953    start: 4,
22954    name: "variance",
22955    type: "tensor"
22956  }],
22957  attrs: [{
22958    tfName: "epsilon",
22959    name: "epsilon",
22960    type: "number",
22961    defaultValue: .001
22962  }, {
22963    tfName: "data_format",
22964    name: "dataFormat",
22965    type: "string",
22966    notSupported: !0
22967  }]
22968}, {
22969  tfOpName: "FusedBatchNormV3",
22970  category: "normalization",
22971  inputs: [{
22972    start: 0,
22973    name: "x",
22974    type: "tensor"
22975  }, {
22976    start: 1,
22977    name: "scale",
22978    type: "tensor"
22979  }, {
22980    start: 2,
22981    name: "offset",
22982    type: "tensor"
22983  }, {
22984    start: 3,
22985    name: "mean",
22986    type: "tensor"
22987  }, {
22988    start: 4,
22989    name: "variance",
22990    type: "tensor"
22991  }],
22992  attrs: [{
22993    tfName: "epsilon",
22994    name: "epsilon",
22995    type: "number",
22996    defaultValue: .001
22997  }, {
vendor: 4,101 bytes, lines 22998-23258
22998    tfName: "data_format",
22999    name: "dataFormat",
23000    type: "string",
23001    notSupported: !0
23002  }]
23003}, {
23004  tfOpName: "LRN",
23005  category: "normalization",
23006  inputs: [{
23007    start: 0,
23008    name: "x",
23009    type: "tensor"
23010  }],
23011  attrs: [{
23012    tfName: "depth_radius",
23013    name: "radius",
23014    type: "number",
23015    defaultValue: 5
23016  }, {
23017    tfName: "bias",
23018    name: "bias",
23019    type: "number",
23020    defaultValue: 1
23021  }, {
23022    tfName: "alpha",
23023    name: "alpha",
23024    type: "number",
23025    defaultValue: 1
23026  }, {
23027    tfName: "beta",
23028    name: "beta",
23029    type: "number",
23030    defaultValue: .5
23031  }]
23032}, {
23033  tfOpName: "Softmax",
23034  category: "normalization",
23035  inputs: [{
23036    start: 0,
23037    name: "x",
23038    type: "tensor"
23039  }]
23040}, {
23041  tfOpName: "LogSoftmax",
23042  category: "normalization",
23043  inputs: [{
23044    start: 0,
23045    name: "x",
23046    type: "tensor"
23047  }]
23048}, {
23049  tfOpName: "SparseToDense",
23050  category: "normalization",
23051  inputs: [{
23052    start: 0,
23053    name: "sparseIndices",
23054    type: "tensor"
23055  }, {
23056    start: 1,
23057    name: "outputShape",
23058    type: "number[]"
23059  }, {
23060    start: 2,
23061    name: "sparseValues",
23062    type: "tensor"
23063  }, {
23064    start: 3,
23065    name: "defaultValue",
23066    type: "tensor"
23067  }],
23068  attrs: [{
23069    tfName: "validate_indices",
23070    name: "validateIndices",
23071    type: "bool",
23072    defaultValue: !0,
23073    notSupported: !0
23074  }]
23075}],
23076    normalization = Object.freeze({
23077  json: json$11
23078}),
23079    json$12 = [{
23080  tfOpName: "Max",
23081  category: "reduction",
23082  inputs: [{
23083    start: 0,
23084    name: "x",
23085    type: "tensor"
23086  }, {
23087    start: 1,
23088    name: "axis",
23089    type: "number[]"
23090  }],
23091  attrs: [{
23092    tfName: "keep_dims",
23093    name: "keepDims",
23094    type: "bool"
23095  }]
23096}, {
23097  tfOpName: "Mean",
23098  category: "reduction",
23099  inputs: [{
23100    start: 0,
23101    name: "x",
23102    type: "tensor"
23103  }, {
23104    start: 1,
23105    name: "axis",
23106    type: "number[]"
23107  }],
23108  attrs: [{
23109    tfName: "keep_dims",
23110    name: "keepDims",
23111    type: "bool"
23112  }]
23113}, {
23114  tfOpName: "Min",
23115  category: "reduction",
23116  inputs: [{
23117    start: 0,
23118    name: "x",
23119    type: "tensor"
23120  }, {
23121    start: 1,
23122    name: "axis",
23123    type: "number[]"
23124  }],
23125  attrs: [{
23126    tfName: "keep_dims",
23127    name: "keepDims",
23128    type: "bool"
23129  }]
23130}, {
23131  tfOpName: "Sum",
23132  category: "reduction",
23133  inputs: [{
23134    start: 0,
23135    name: "x",
23136    type: "tensor"
23137  }, {
23138    start: 1,
23139    name: "axis",
23140    type: "number[]"
23141  }],
23142  attrs: [{
23143    tfName: "keep_dims",
23144    name: "keepDims",
23145    type: "bool"
23146  }]
23147}, {
23148  tfOpName: "All",
23149  category: "reduction",
23150  inputs: [{
23151    start: 0,
23152    name: "x",
23153    type: "tensor"
23154  }, {
23155    start: 1,
23156    name: "axis",
23157    type: "number[]"
23158  }],
23159  attrs: [{
23160    tfName: "keep_dims",
23161    name: "keepDims",
23162    type: "bool"
23163  }]
23164}, {
23165  tfOpName: "Any",
23166  category: "reduction",
23167  inputs: [{
23168    start: 0,
23169    name: "x",
23170    type: "tensor"
23171  }, {
23172    start: 1,
23173    name: "axis",
23174    type: "number[]"
23175  }],
23176  attrs: [{
23177    tfName: "keep_dims",
23178    name: "keepDims",
23179    type: "bool"
23180  }]
23181}, {
23182  tfOpName: "ArgMax",
23183  category: "reduction",
23184  inputs: [{
23185    start: 0,
23186    name: "x",
23187    type: "tensor"
23188  }, {
23189    start: 1,
23190    name: "axis",
23191    type: "number"
23192  }]
23193}, {
23194  tfOpName: "ArgMin",
23195  category: "reduction",
23196  inputs: [{
23197    start: 0,
23198    name: "x",
23199    type: "tensor"
23200  }, {
23201    start: 1,
23202    name: "axis",
23203    type: "number"
23204  }]
23205}, {
23206  tfOpName: "Prod",
23207  category: "reduction",
23208  inputs: [{
23209    start: 0,
23210    name: "x",
23211    type: "tensor"
23212  }, {
23213    start: 1,
23214    name: "axis",
23215    type: "number[]"
23216  }],
23217  attrs: [{
23218    tfName: "keep_dims",
23219    name: "keepDims",
23220    type: "bool"
23221  }]
23222}],
23223    reduction = Object.freeze({
23224  json: json$12
23225}),
23226    json$13 = [{
23227  tfOpName: "ConcatV2",
23228  category: "slice_join",
23229  inputs: [{
23230    start: 0,
23231    end: -1,
23232    name: "tensors",
23233    type: "tensors"
23234  }, {
23235    start: -1,
23236    name: "axis",
23237    type: "number"
23238  }],
23239  attrs: [{
23240    tfName: "N",
23241    name: "n",
23242    type: "number",
23243    defaultValue: 2
23244  }]
23245}, {
23246  tfOpName: "Concat",
23247  category: "slice_join",
23248  inputs: [{
23249    start: 1,
23250    end: 0,
23251    name: "tensors",
23252    type: "tensors"
23253  }, {
23254    start: 0,
23255    name: "axis",
23256    type: "number"
23257  }],
23258  attrs: [{
23259    tfName: "N",
23260    name: "n",
23261    type: "number",
23262    defaultValue: 2
23263  }]
23264}, {
23265  tfOpName: "GatherV2",
23266  category: "slice_join",
23267  inputs: [{
23268    start: 0,
23269    name: "x",
23270    type: "tensor"
23271  }, {
23272    start: 1,
23273    name: "indices",
23274    type: "tensor"
23275  }, {
23276    start: 2,
23277    name: "axis",
23278    type: "number",
23279    defaultValue: 0
23280  }]
23281}, {
23282  tfOpName: "Gather",
23283  category: "slice_join",
23284  inputs: [{
23285    start: 0,
23286    name: "x",
23287    type: "tensor"
23288  }, {
23289    start: 1,
23290    name: "indices",
23291    type: "tensor"
23292  }],
23293  attrs: [{
23294    tfName: "axis",
23295    name: "axis",
23296    type: "number",
23297    defaultValue: 0
23298  }, {
23299    tfName: "validate_indices",
23300    name: "validateIndices",
23301    type: "bool",
23302    notSupported: !0
23303  }]
23304}, {
23305  tfOpName: "Reverse",
23306  category: "slice_join",
23307  inputs: [{
23308    start: 0,
23309    name: "x",
23310    type: "tensor"
23311  }, {
23312    start: 1,
23313    name: "dims",
23314    type: "bool",
23315    notSupported: !0
23316  }]
23317}, {
23318  tfOpName: "ReverseV2",
23319  category: "slice_join",
23320  inputs: [{
23321    start: 0,
23322    name: "x",
23323    type: "tensor"
23324  }, {
23325    start: 1,
23326    name: "axis",
23327    type: "number[]"
23328  }]
23329}, {
23330  tfOpName: "Slice",
23331  category: "slice_join",
23332  inputs: [{
23333    start: 0,
23334    name: "x",
23335    type: "tensor"
23336  }, {
23337    start: 1,
23338    name: "begin",
23339    type: "number[]"
23340  }, {
23341    start: 2,
23342    name: "size",
23343    type: "number[]"
23344  }]
23345}, {
23346  tfOpName: "StridedSlice",
23347  category: "slice_join",
23348  inputs: [{
23349    start: 0,
23350    name: "x",
23351    type: "tensor"
23352  }, {
23353    start: 1,
23354    name: "begin",
23355    type: "number[]"
23356  }, {
23357    start: 2,
23358    name: "end",
23359    type: "number[]"
23360  }, {
23361    start: 3,
23362    name: "strides",
23363    type: "number[]"
23364  }],
23365  attrs: [{
23366    tfName: "begin_mask",
23367    name: "beginMask",
23368    type: "number",
23369    defaultValue: 0
23370  }, {
23371    tfName: "end_mask",
23372    name: "endMask",
23373    type: "number",
23374    defaultValue: 0
23375  }, {
23376    tfName: "new_axis_mask",
23377    name: "newAxisMask",
23378    type: "number",
23379    defaultValue: 0
23380  }, {
23381    tfName: "ellipsis_mask",
23382    name: "ellipsisMask",
23383    type: "number",
23384    defaultValue: 0
23385  }, {
23386    tfName: "shrink_axis_mask",
23387    name: "shrinkAxisMask",
23388    type: "number",
23389    defaultValue: 0
23390  }]
23391}, {
23392  tfOpName: "Pack",
23393  category: "slice_join",
23394  inputs: [{
23395    start: 0,
23396    end: 0,
23397    name: "tensors",
23398    type: "tensors"
23399  }],
23400  attrs: [{
23401    tfName: "axis",
23402    name: "axis",
23403    type: "number",
23404    defaultValue: 0
23405  }]
23406}, {
23407  tfOpName: "Unpack",
23408  category: "slice_join",
23409  inputs: [{
23410    start: 0,
23411    name: "tensor",
23412    type: "tensor"
23413  }],
23414  attrs: [{
23415    tfName: "axis",
23416    name: "axis",
23417    type: "number",
23418    defaultValue: 0
23419  }, {
23420    tfName: "num",
23421    name: "num",
23422    type: "number",
23423    defaultValue: 0,
23424    notSupported: !0
23425  }]
23426}, {
23427  tfOpName: "Tile",
23428  category: "slice_join",
23429  inputs: [{
23430    start: 0,
23431    name: "x",
23432    type: "tensor"
23433  }, {
23434    start: 1,
23435    name: "reps",
23436    type: "number[]"
23437  }]
23438}, {
23439  tfOpName: "Split",
23440  category: "slice_join",
23441  inputs: [{
23442    start: 0,
23443    name: "axis",
23444    type: "number",
23445    defaultValue: 0
23446  }, {
23447    start: 1,
23448    name: "x",
23449    type: "tensor"
23450  }],
23451  attrs: [{
23452    tfName: "num_split",
23453    name: "numOrSizeSplits",
23454    type: "number",
23455    defaultValue: 1
23456  }]
23457}, {
23458  tfOpName: "SplitV",
23459  category: "slice_join",
23460  inputs: [{
23461    start: 0,
23462    name: "x",
23463    type: "tensor"
23464  }, {
23465    start: 1,
23466    name: "numOrSizeSplits",
23467    type: "number[]"
23468  }, {
23469    start: 2,
23470    name: "axis",
23471    type: "number",
23472    defaultValue: 0
23473  }]
23474}, {
23475  tfOpName: "ScatterNd",
23476  category: "slice_join",
23477  inputs: [{
23478    start: 0,
23479    name: "indices",
23480    type: "tensor"
23481  }, {
23482    start: 1,
23483    name: "values",
23484    type: "tensor"
23485  }, {
23486    start: 2,
23487    name: "shape",
23488    type: "number[]"
23489  }]
23490}, {
23491  tfOpName: "GatherNd",
23492  category: "slice_join",
23493  inputs: [{
23494    start: 0,
23495    name: "x",
23496    type: "tensor"
23497  }, {
23498    start: 1,
23499    name: "indices",
23500    type: "tensor"
23501  }]
23502}, {
23503  tfOpName: "SparseToDense",
23504  category: "slice_join",
23505  inputs: [{
23506    start: 0,
23507    name: "sparseIndices",
23508    type: "tensor"
23509  }, {
23510    start: 1,
23511    name: "outputShape",
23512    type: "number[]"
23513  }, {
23514    start: 2,
23515    name: "sparseValues",
23516    type: "tensor"
23517  }, {
23518    start: 3,
23519    name: "defaultValue",
23520    type: "tensor"
23521  }],
23522  attrs: [{
23523    tfName: "validate_indices",
23524    name: "validateIndices",
23525    type: "bool",
23526    defaultValue: !1,
23527    notSupported: !0
23528  }]
23529}],
23530    sliceJoin = Object.freeze({
23531  json: json$13
23532}),
23533    json$14 = [{
23534  tfOpName: "FFT",
23535  category: "spectral",
23536  inputs: [{
23537    start: 0,
23538    name: "x",
23539    type: "tensor"
23540  }]
23541}, {
23542  tfOpName: "IFFT",
23543  category: "spectral",
23544  inputs: [{
23545    start: 0,
23546    name: "x",
23547    type: "tensor"
23548  }]
23549}, {
23550  tfOpName: "RFFT",
23551  category: "spectral",
23552  inputs: [{
23553    start: 0,
23554    name: "x",
23555    type: "tensor"
23556  }, {
23557    start: 1,
23558    name: "fft_length",
23559    type: "number",
23560    notSupported: !0
23561  }]
23562}, {
23563  tfOpName: "IRFFT",
23564  category: "spectral",
23565  inputs: [{
23566    start: 0,
23567    name: "x",
23568    type: "tensor"
23569  }, {
23570    start: 1,
23571    name: "fft_length",
23572    type: "number",
23573    notSupported: !0
23574  }]
23575}],
23576    spectral = Object.freeze({
23577  json: json$14
23578}),
23579    json$15 = [{
23580  tfOpName: "Cast",
23581  category: "transformation",
23582  inputs: [{
23583    start: 0,
23584    name: "x",
23585    type: "tensor"
23586  }],
23587  attrs: [{
23588    tfName: "SrcT",
23589    name: "sdtype",
23590    type: "dtype",
23591    notSupported: !0
23592  }, {
23593    tfName: "DstT",
23594    name: "dtype",
23595    type: "dtype"
23596  }]
23597}, {
23598  tfOpName: "ExpandDims",
23599  category: "transformation",
23600  inputs: [{
23601    start: 0,
23602    name: "x",
23603    type: "tensor"
23604  }, {
23605    start: 1,
23606    name: "axis",
23607    type: "number"
23608  }]
23609}, {
23610  tfOpName: "Pad",
23611  category: "transformation",
23612  inputs: [{
23613    start: 0,
23614    name: "x",
23615    type: "tensor"
23616  }, {
23617    start: 1,
23618    name: "padding",
23619    type: "number[]"
23620  }],
23621  attrs: [{
23622    tfName: "constant_value",
23623    name: "constantValue",
23624    type: "number",
23625    defaultValue: 0
23626  }]
23627}, {
23628  tfOpName: "PadV2",
23629  category: "transformation",
23630  inputs: [{
23631    start: 0,
23632    name: "x",
23633    type: "tensor"
23634  }, {
23635    start: 1,
23636    name: "padding",
23637    type: "number[]"
23638  }, {
23639    start: 2,
23640    name: "constantValue",
23641    type: "number",
23642    defaultValue: 0
23643  }]
23644}, {
23645  tfOpName: "Reshape",
23646  category: "transformation",
23647  inputs: [{
23648    start: 0,
23649    name: "x",
23650    type: "tensor"
23651  }, {
23652    start: 1,
23653    name: "shape",
23654    type: "number[]"
23655  }]
23656}, {
23657  tfOpName: "Squeeze",
23658  category: "transformation",
23659  inputs: [{
23660    start: 0,
23661    name: "x",
23662    type: "tensor"
23663  }],
23664  attrs: [{
23665    tfName: "axis",
23666    tfDeprecatedName: "squeeze_dims",
23667    name: "axis",
23668    type: "number[]"
23669  }]
23670}, {
23671  tfOpName: "SpaceToBatchND",
23672  category: "transformation",
23673  inputs: [{
23674    start: 0,
23675    name: "x",
23676    type: "tensor"
23677  }, {
23678    start: 1,
23679    name: "blockShape",
23680    type: "number[]"
23681  }, {
23682    start: 2,
23683    name: "paddings",
23684    type: "number[]"
23685  }]
23686}, {
23687  tfOpName: "BatchToSpaceND",
23688  category: "transformation",
23689  inputs: [{
23690    start: 0,
23691    name: "x",
23692    type: "tensor"
23693  }, {
23694    start: 1,
23695    name: "blockShape",
23696    type: "number[]"
23697  }, {
23698    start: 2,
23699    name: "crops",
23700    type: "number[]"
23701  }]
23702}, {
23703  tfOpName: "DepthToSpace",
23704  category: "transformation",
23705  inputs: [{
23706    start: 0,
23707    name: "x",
23708    type: "tensor"
23709  }],
23710  attrs: [{
23711    tfName: "block_size",
23712    name: "blockSize",
23713    type: "number"
23714  }, {
23715    tfName: "data_format",
23716    name: "dataFormat",
23717    type: "string"
23718  }]
23719}],
23720    transformation = Object.freeze({
23721  json: json$15
23722}),
23723    OperationMapper = function () {
23724  function e() {
23725    var e = [arithmetic, basicMath, control, convolution, creation, dynamic, evaluation, logical, image$1, graph, matrices, normalization, reduction, sliceJoin, spectral, transformation],
23726        t = [].concat.apply([], e.map(function (e) {
23727      return e.json;
23728    }));
23729    this.opMappers = t.reduce(function (e, t) {
23730      return e[t.tfOpName] = t, e;
23731    }, {});
23732  }
23733
23734  return Object.defineProperty(e, "Instance", {
23735    get: function () {
23736      return this._instance || (this._instance = new this());
23737    },
23738    enumerable: !0,
23739    configurable: !0
23740  }), e.prototype.transformGraph = function (e, t) {
23741    var a = this;
23742    void 0 === t && (t = {});
23743    var r = [],
23744        n = [],
23745        s = e.node.reduce(function (e, t) {
23746      return e[t.name] = a.mapNode(t), t.op.startsWith("Placeholder") && r.push(e[t.name]), "Const" === t.op && n.push(e[t.name]), e;
23747    }, {}),
23748        o = [],
23749        p = [],
23750        u = {},
23751        i = {};
23752    null != t && (u = this.mapSignatureEntries(t.inputs), i = this.mapSignatureEntries(t.outputs));
23753    var m = Object.keys(s);
23754    return m.forEach(function (e) {
23755      var t = s[e];
23756      t.inputNames.forEach(function (e) {
23757        var a = getNodeNameAndIndex(e)[0];
23758        t.inputs.push(s[a]), s[a].children.push(t);
23759      });
23760    }), 0 === Object.keys(i).length ? m.forEach(function (e) {
23761      var t = s[e];
23762      0 === t.children.length && p.push(t);
23763    }
23763) : Object.keys(i).forEach(function (e) {
23764      var t = getNodeNameAndIndex(e)[0],
23765          a = s[t];
23766      null != a && (a.signatureKey = i[e], p.push(a));
23767    }), Object.keys(u).length > 0 ? Object.keys(u).forEach(function (e) {
23768      var t = getNodeNameAndIndex(e)[0],
23769          a = s[t];
23770      a && (a.signatureKey = u[e], o.push(a));
23771    }) : o = r, {
23772      nodes: s,
23773      inputs: o,
23774      outputs: p,
23775      weights: n,
23776      placeholders: r,
23777      signature: t
23778    };
23779  }, e.prototype.mapSignatureEntries = function (e) {
23780    return Object.keys(e || {}).reduce(function (t, a) {
23781      return t[e[a].name] = a, t;
23782    }, {});
23783  }, e.prototype.mapNode = function (e) {
23784    var t = getRegisteredOp(e.op) || this.opMappers[e.op] || {};
23785    null == e.attr && (e.attr = {});
23786    var a = {
23787      name: e.name,
23788      op: e.op,
23789      category: t.category,
23790      inputNames: (e.input || []).map(function (e) {
23791        return e.startsWith("^") ? e.substr(1) : e;
23792      }),
23793      inputs: [],
23794      children: [],
23795      inputParams: {},
23796      attrParams: {},
23797      rawAttrs: e.attr
23798    };
23799    return null != t.inputs && (a.inputParams = t.inputs.reduce(function (e, t) {
23800      return e[t.name] = {
23801        type: t.type,
23802        inputIndexStart: t.start,
23803        inputIndexEnd: t.end
23804      }, e;
23805    }, {})), null != t.attrs && (a.attrParams = t.attrs.reduce(function (t, a) {
23806      var r = a.type,
23807          n = void 0;
23808
23809      switch (a.type) {
23810        case "string":
23811          void 0 === (n = getStringParam(e.attr, a.tfName, a.defaultValue)) && a.tfDeprecatedName && (n = getStringParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23812          break;
23813
23814        case "string[]":
23815          void 0 === (n = getStringArrayParam(e.attr, a.tfName, a.defaultValue)) && a.tfDeprecatedName && (n = getStringArrayParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23816          break;
23817
23818        case "number":
23819          void 0 === (n = getNumberParam(e.attr, a.tfName, a.defaultValue || 0)) && a.tfDeprecatedName && (n = getNumberParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23820          break;
23821
23822        case "number[]":
23823          void 0 === (n = getNumericArrayParam(e.attr, a.tfName, a.defaultValue)) && a.tfDeprecatedName && (n = getNumericArrayParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23824          break;
23825
23826        case "bool":
23827          void 0 === (n = getBoolParam(e.attr, a.tfName, a.defaultValue)) && a.tfDeprecatedName && (n = getBoolParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23828          break;
23829
23830        case "bool[]":
23831          void 0 === (n = getBoolArrayParam(e.attr, a.tfName, a.defaultValue)) && a.tfDeprecatedName && (n = getBoolArrayParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23832          break;
23833
23834        case "shape":
23835          void 0 === (n = getTensorShapeParam(e.attr, a.tfName, a.defaultValue)) && a.tfDeprecatedName && (n = getTensorShapeParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23836          break;
23837
23838        case "shape[]":
23839          void 0 === (n = getTensorShapeArrayParam(e.attr, a.tfName, a.defaultValue)) && a.tfDeprecatedName && (n = getTensorShapeArrayParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23840          break;
23841
23842        case "dtype":
23843          void 0 === (n = getDtypeParam(e.attr, a.tfName, a.defaultValue)) && a.tfDeprecatedName && (n = getDtypeParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23844          break;
23845
23846        case "dtype[]":
23847          void 0 === (n = getDtypeArrayParam(e.attr, a.tfName, a.defaultValue)) && a.tfDeprecatedName && (n = getDtypeArrayParam(e.attr, a.tfDeprecatedName, a.defaultValue));
23848          break;
23849
23850        case "tensor":
23851        case "tensors":
23852          break;
23853
23854        default:
23855          throw new Error("Unsupported param type: " + a.type + " for op: " + e.op);
23856      }
23857
23858      return t[a.name] = {
23859        value: n,
23860        type: r
23861      }, t;
23862    }, {})), a;
23863  }, e;
23864}();
23865
23866function decodeBase64(e) {
23867  var t = (0, _tfjsCore.env)().global;
23868  if (void 0 !== t.atob) return t.atob(e);
23869  if ("undefined" != typeof Buffer) return new Buffer(e, "base64").toString();
23870  throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()");
23871}
23872
23873function parseStringParam(e, t) {
23874  var a = Array.isArray(e) ? String.fromCharCode.apply(null, e) : decodeBase64(e);
23875  return t ? a : a.toLowerCase();
23876}
23877
23878function getStringParam(e, t, a, r) {
23879  void 0 === r && (r = !1);
23880  var n = e[t];
23881  return null != n ? parseStringParam(n.s, r) : a;
23882}
23883
23884function getBoolParam(e, t, a) {
23885  var r = e[t];
23886  return r ? r.b : a;
23887}
23888
23889function getNumberParam(e, t, a) {
23890  var r = e[t] || {},
23891      n = null != r.i ? r.i : null != r.f ? r.f : a;
23892  return "number" == typeof n ? n : parseInt(n, 10);
23893}
23894
23895function parseDtypeParam(e) {
23896  switch ("string" == typeof e && (e = DataType[e]), e) {
23897    case DataType.DT_FLOAT:
23898      return "float32";
23899
23900    case DataType.DT_INT32:
23901    case DataType.DT_INT64:
23902      return "int32";
23903
23904    case DataType.DT_BOOL:
23905      return "bool";
23906
23907    case DataType.DT_DOUBLE:
23908      return "float32";
23909
23910    case DataType.DT_STRING:
23911      return "string";
23912
23913    default:
23914      return null;
23915  }
23916}
23917
23918function getDtypeParam(e, t, a) {
23919  var r = e[t];
23920  return r && r.type ? parseDtypeParam(r.type) : a;
23921}
23922
23923function getDtypeArrayParam(e, t, a) {
23924  var r = e[t];
23925  return r && r.list && r.list.type ? r.list.type.map(function (e) {
23926    return parseDtypeParam(e);
23927  }) : a;
23928}
23929
23930function parseTensorShapeParam(e) {
23931  if (!e.unknownRank) return null != e.dim ? e.dim.map(function (e) {
23932    return "number" == typeof e.size ? e.size : parseInt(e.size, 10);
23933  }) : [];
23934}
23935
23936function getTensorShapeParam(e, t, a) {
23937  var r = e[t];
23938  return r && r.shape ? parseTensorShapeParam(r.shape) : a;
23939}
23940
23941function getNumericArrayParam(e, t, a) {
23942  var r = e[t];
23943  return r ? ((r.list.f && r.list.f.length ? r.list.f : r.list.i) || []).map(function (e) {
23944    return "number" == typeof e ? e : parseInt(e, 10);
23945  }) : a;
23946}
23947
23948function getStringArrayParam(e, t, a, r) {
23949  void 0 === r && (r = !1);
23950  var n = e[t];
23951  return n && n.list && n.list.s ? n.list.s.map(function (e) {
23952    return parseStringParam(e, r);
23953  }) : a;
23954}
23955
23956function getTensorShapeArrayParam(e, t, a) {
23957  var r = e[t];
23958  return r && r.list && r.list.shape ? r.list.shape.map(function (e) {
23959    return parseTensorShapeParam(e);
23960  }) : a;
23961}
23962
23963function getBoolArrayParam(e, t, a) {
23964  var r = e[t];
23965  return r && r.list && r.list.b ? r.list.b : a;
23966}
23967
23968var NodeValueImpl = function () {
23969  function e(e, t, a) {
23970    var r = this;
23971    this.node = e, this.tensorMap = t, this.context = a, this.inputs = [], this.attrs = {}, this.inputs = e.inputNames.map(function (e) {
23972      return r.getInput(e);
23973    }), null != e.rawAttrs && (this.attrs = Object.keys(e.rawAttrs).reduce(function (e, t) {
23974      return e[t] = r.getAttr(t), e;
23975    }, {}));
23976  }
23977
23978  return e.prototype.getInput = function (e) {
23979    return getTensor(e, this.tensorMap, this.context);
23980  }, e.prototype.getAttr = function (e, t) {
23981    var a = this.node.rawAttrs[e];
23982    if (null != a.tensor) return getTensor(e, this.tensorMap, this.context);
23983    if (null != a.i || null != a.f) return getNumberParam(this.node.rawAttrs, e, t);
23984    if (null != a.s) return getStringParam(this.node.rawAttrs, e, t);
23985    if (null != a.b) return getBoolParam(this.node.rawAttrs, e, t);
23986    if (null != a.shape) return getTensorShapeParam(this.node.rawAttrs, e, t);
23987    if (null != a.type) return getDtypeParam(this.node.rawAttrs, e, t);
23988
23989    if (null != a.list) {
23990      if (null != a.list.i || null != a.list.f) return getNumericArrayParam(this.node.rawAttrs, e, t);
23991      if (null != a.list.s) return getStringArrayParam(this.node.rawAttrs, e, t);
23992      if (null != a.list.shape) return getTensorShapeArrayParam(this.node.rawAttrs, e, t);
23993      if (null != a.list.b) return getBoolArrayParam(this.node.rawAttrs, e, t);
23994      if (null != a.list.type) return getDtypeArrayParam(this.node.rawAttrs, e, t);
23995    }
23996
23997    return t;
23998  }, e;
23999}(),
24000    executeOp = function (e, t, a) {
24001  switch (e.op) {
24002    case "BiasAdd":
24003    case "AddV2":
24004    case "Add":
24005      return [(0, _tfjsCore.add)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24006
24007    case "AddN":
24008      return [(0, _tfjsCore.addN)(getParamValue("tensors", e, t, a))];
24009
24010    case "FloorMod":
24011    case "Mod":
24012      return [(0, _tfjsCore.mod)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24013
24014    case "Mul":
24015      return [(0, _tfjsCore.mul)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24016
24017    case "RealDiv":
24018    case "Div":
24019      return [(0, _tfjsCore.div)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24020
24021    case "DivNoNan":
24022      return [(0, _tfjsCore.divNoNan)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24023
24024    case "FloorDiv":
24025      return [(0, _tfjsCore.floorDiv)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24026
24027    case "Sub":
24028      return [(0, _tfjsCore.sub)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24029
24030    case "Minimum":
24031      return [(0, _tfjsCore.minimum)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24032
24033    case "Maximum":
24034      return [(0, _tfjsCore.maximum)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24035
24036    case "Pow":
24037      return [(0, _tfjsCore.pow)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24038
24039    case "SquaredDifference":
24040      return [(0, _tfjsCore.squaredDifference)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24041
24042    default:
24043      throw TypeError("Node type " + e.op + " is not implemented");
24044  }
24045},
24046    executeOp$1 = function (e, t, a) {
24047  switch (e.op) {
24048    case "Abs":
24049    case "ComplexAbs":
24050      return [(0, _tfjsCore.abs)(getParamValue("x", e, t, a))];
24051
24052    case "Acos":
24053      return [(0, _tfjsCore.acos)(getParamValue("x", e, t, a))];
24054
24055    case "Acosh":
24056      return [(0, _tfjsCore.acosh)(getParamValue("x", e, t, a))];
24057
24058    case "Asin":
24059      return [(0, _tfjsCore.asin)(getParamValue("x", e, t, a))];
24060
24061    case "Asinh":
24062      return [(0, _tfjsCore.asinh)(getParamValue("x", e, t, a))];
24063
24064    case "Atan":
24065      return [(0, _tfjsCore.atan)(getParamValue("x", e, t, a))];
24066
24067    case "Atan2":
24068      return [(0, _tfjsCore.atan2)(getParamValue("x", e, t, a), getParamValue("y", e, t, a))];
24069
24070    case "Atanh":
24071      return [(0, _tfjsCore.atanh)(getParamValue("x", e, t, a))];
24072
24073    case "Ceil":
24074      return [(0, _tfjsCore.ceil)(getParamValue("x", e, t, a))];
24075
24076    case "Complex":
24077      return [(0, _tfjsCore.complex)(getParamValue("real", e, t, a), getParamValue("imag", e, t, a))];
24078
24079    case "Cos":
24080      return [(0, _tfjsCore.cos)(getParamValue("x", e, t, a))];
24081
24082    case "Cosh":
24083      return [(0, _tfjsCore.cosh)(getParamValue("x", e, t, a))];
24084
24085    case "Elu":
24086      return [(0, _tfjsCore.elu)(getParamValue("x", e, t, a))];
24087
24088    case "Erf":
24089      return [(0, _tfjsCore.erf)(getParamValue("x", e, t, a))];
24090
24091    case "Exp":
24092      return [(0, _tfjsCore.exp)(getParamValue("x", e, t, a))];
24093
24094    case "Expm1":
24095      return [(0, _tfjsCore.expm1)(getParamValue("x", e, t, a))];
24096
24097    case "Floor":
24098      return [(0, _tfjsCore.floor)(getParamValue("x", e, t, a))];
24099
24100    case "Log":
24101      return [(0, _tfjsCore.log)(getParamValue("x", e, t, a))];
24102
24103    case "Log1p":
24104      return [(0, _tfjsCore.log1p)(getParamValue("x", e, t, a))];
24105
24106    case "Imag":
24107      return [(0, _tfjsCore.imag)(getParamValue("x", e, t, a))];
24108
24109    case "Neg":
24110      return [(0, _tfjsCore.neg)(getParamValue("x", e, t, a))];
24111
24112    case "Reciprocal":
24113      return [(0, _tfjsCore.reciprocal)(getParamValue("x", e, t, a))];
24114
24115    case "Real":
24116      return [(0, _tfjsCore.real)(getParamValue("x", e, t, a))];
24117
24118    case "Relu":
24119      return [(0, _tfjsCore.relu)(getParamValue("x", e, t, a))];
24120
24121    case "Round":
24122      return [(0, _tfjsCore.round)(getParamValue("x", e, t, a))];
24123
24124    case "Selu":
24125      return [(0, _tfjsCore.selu)(getParamValue("x", e, t, a))];
24126
24127    case "Sigmoid":
24128      return [(0, _tfjsCore.sigmoid)(getParamValue("x", e, t, a))];
24129
24130    case "Sin":
24131      return [(0, _tfjsCore.sin)(getParamValue("x", e, t, a))];
24132
24133    case "Sign":
24134      return [(0, _tfjsCore.sign)(getParamValue("x", e, t, a))];
24135
24136    case "Sinh":
24137      return [(0, _tfjsCore.sinh)(getParamValue("x", e, t, a))];
24138
24139    case "Softplus":
24140      return [(0, _tfjsCore.softplus)(getParamValue("x", e, t, a))];
24141
24142    case "Sqrt":
24143      return [(0, _tfjsCore.sqrt)(getParamValue("x", e, t, a))];
24144
24145    case "Square":
24146      return [(0, _tfjsCore.square)(getParamValue("x", e, t, a))];
24147
24148    case "Tanh":
24149      return [(0, _tfjsCore.tanh)(getParamValue("x", e, t, a))];
24150
24151    case "Tan":
24152      return [(0, _tfjsCore.tan)(getParamValue("x", e, t, a))];
24153
24154    case "Relu6":
24155    case "ClipByValue":
24156      return [(0, _tfjsCore.clipByValue)(getParamValue("x", e, t, a), getParamValue("clipValueMin", e, t, a), getParamValue("clipValueMax", e, t, a))];
24157
24158    case "Rsqrt":
24159      return [(0, _tfjsCore.rsqrt)(getTensor(e.inputNames[0], t, a))];
24160
24161    case "Prod":
24162      return [(0, _tfjsCore.prod)(getParamValue("x", e, t, a), getParamValue("axes", e, t, a))];
24163
24164    case "LeakyRelu":
24165      return [(0, _tfjsCore.leakyRelu)(getParamValue("x", e, t, a), getParamValue("alpha", e, t, a))];
24166
24167    case "Prelu":
24168      return [(0, _tfjsCore.prelu)(getParamValue("x", e, t, a), getParamValue("alpha", e, t, a))];
24169
24170    default:
24171      throw TypeError("Node type " + e.op + " is not implemented");
24172  }
24173},
24174    TensorArray = function () {
24175  function e(t, a, r, n, s, o, p) {
24176    this.name = t, this.dtype = a, this.maxSize = r, this.elementShape = n, this.identicalElementShapes = s, this.dynamicSize = o, this.clearAfterRead = p, this.tensors = [], this.closed_ = !1, this.id = e.nextId++;
24177  }
24178
24179  return Object.defineProperty(e.prototype, "closed", {
24180    get: function () {
24181      return this.closed_;
24182    },
24183    enumerable: !0,
24184    configurable: !0
24185  }), e.prototype.clearAndClose = function () {
24186    this.tensors.forEach(function (e) {
24187      return e.tensor.dispose();
24188    }), this.tensors = [], this.closed_ = !0;
24189  }, e.prototype.size = function () {
24190    return this.tensors.length;
24191  }, e.prototype.read = function (e) {
24192    if (this.closed_) throw new Error("TensorArray " + this.name + " has already been closed.");
24193    if (e < 0 || e >= this.tensors.length) throw new Error("Tried to read from index " + e + ", but array size is: " + this.tensors.length);
24194    var t = this.tensors[e];
24195    if (t.cleared) throw new Error("TensorArray " + this.name + ": Could not read index " + e + " twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).");
24196    return this.clearAfterRead && (t.cleared = !0), t.read = !0, t.tensor;
24197  }, e.prototype.readMany = function (e) {
24198    var t = this;
24199    return e.map(function (e) {
24200      return t.read(e);
24201    });
24202  }, e.prototype.write = function (e, t) {
24203    if (this.closed_) throw new Error("TensorArray " + this.name + " has already been closed.");
24204    if (e < 0 || !this.dynamicSize && e >= this.maxSize) throw new Error("Tried to write to index " + e + ", but array is not resizeable and size is: " + this.maxSize);
24205    var a = this.tensors[e] || {};
24206    if (t.dtype !== this.dtype) throw new Error("TensorArray " + this.name + ": Could not write to TensorArray index " + e + ",\n          because the value dtype is " + t.dtype + ", but TensorArray dtype is " + this.dtype + ".");
24207    if (0 !== this.size() || null != this.elementShape && 0 !== this.elementShape.length || (this.elementShape = t.shape), this.assertShapesMatchAllowUndefinedSize(this.elementShape, t.shape, "TensorArray " + this.name + ": Could not write to TensorArray index " + e + "."), a && a.read) throw new Error("TensorArray " + this.name + ": Could not write to TensorArray index " + e + ", because it has already been read.");
24208    if (a && a.written) throw new Error("TensorArray " + this.name + ": Could not write to TensorArray index " + e + ", because it has already been written.");
24209    a.tensor = t, a.written = !0, this.tensors[e] = a;
24210  }, e.prototype.writeMany = function (e, t) {
24211    var a = this;
24212    if (e.length !== t.length) throw new Error("TensorArray " + this.name + ": could not write multiple tensors,because the index size: " + e.length + " is not the same as tensors size: " + t.length + ".");
24213    e.forEach(function (e, r) {
24214      return a.write(e, t[r]);
24215    });
24216  }, e.prototype.gather = function (e, t) {
24217    if (t && t !== this.dtype) throw new Error("TensorArray dtype is " + this.dtype + " but gather requested dtype " + t);
24218
24219    if (!e) {
24220      e = [];
24221
24222      for (var a = 0; a < this.size(); a++) e.push(a);
24223    }
24224
24225    if (0 === e.length) return (0, _tfjsCore.tensor)([], [0].concat(this.elementShape));
24226    var r = this.readMany(e);
24227    return this.assertShapesMatchAllowUndefinedSize(this.elementShape, r[0].shape, "TensorArray shape mismatch: "), (0, _tfjsCore.stack)(r, 0);
24228  }, e.prototype.concat = function (e) {
24229    if (e && e !== this.dtype) throw new Error("TensorArray dtype is " + this.dtype + " but concat requested dtype " + e);
24230    if (0 === this.size()) return (0, _tfjsCore.tensor)([], [0].concat(this.elementShape));
24231
24232    for (var t = [], a = 0; a < this.size(); a++) t.push(a);
24233
24234    var r = this.readMany(t);
24235    return this.assertShapesMatchAllowUndefinedSize(this.elementShape, r[0].shape, "TensorArray shape mismatch: tensor array shape (" + this.elementShape + ") vs first tensor shape (" + r[0].shape + ")"), (0, _tfjsCore.concat)(r, 0);
24236  }, e.prototype.scatter = function (e, t) {
24237    if (t.dtype !== this.dtype) throw new Error("TensorArray dtype is " + this.dtype + " but tensor has dtype " + t.dtype);
24238    if (e.length !== t.shape[0]) throw new Error("Expected len(indices) == tensor.shape[0], but saw: " + e.length + " vs. " + t.shape[0]);
24239    var a = Math.max.apply(Math, e);
24240    if (!this.dynamicSize && a >= this.maxSize) throw new Error("Max index must be < array size (" + a + "  vs. " + this.maxSize + ")");
24241    this.writeMany(e, (0, _tfjsCore.unstack)(t, 0));
24242  }, e.prototype.split = function (e, t) {
24243    var a = this;
24244    if (t.dtype !== this.dtype) throw new Error("TensorArray dtype is " + this.dtype + " but tensor has dtype " + t.dtype);
24245    var r = 0,
24246        n = e.map(function (e) {
24247      return r += e;
24248    });
24249    if (r !== t.shape[0]) throw new Error("Expected sum of lengths to be equal to\n          tensor.shape[0], but sum of lengths is\n        " + r + ", and tensor's shape is: " + t.shape);
24250    if (!this.dynamicSize && e.length !== this.maxSize) throw new Error("TensorArray's size is not equal to the size of lengths (" + this.maxSize + " vs. " + e.length + "), and the TensorArray is not marked as dynamically resizeable");
24251    var s = 0 === r ? 0 : t.size / r,
24252        o = [];
24253    (0, _tfjsCore.tidy)(function () {
24254      t = t.reshape([1, r, s]);
24255
24256      for (var p = 0; p < e.length; ++p) {
24257        var u = [0, 0 === p ? 0 : n[p - 1], 0],
24258            i = [1, e[p], s];
24259        o[p] = (0, _tfjsCore.slice)(t, u, i).reshape(a.elementShape);
24260      }
24261
24262      return o;
24263    });
24264
24265    for (var p = [], u = 0; u < e.length; u++) p[u] = u;
24266
24267    this.writeMany(p, o);
24268  }, e.prototype.assertShapesMatchAllowUndefinedSize = function (e, t, a) {
24269    void 0 === a && (a = ""), _tfjsCore.util.assert(this.shapesEqualAllowUndefinedSize(e, t), function () {
24270      return a + " Shapes " + e + " and " + t + " must match";
24271    });
24272  }, e.prototype.shapesEqualAllowUndefinedSize = function (e, t) {
24273    if (e.length !== t.length) return !1;
24274
24275    for (var a = 0; a < e.length; a++) if (-1 !== e[a] && -1 !== t[a] && e[a] !== t[a]) return !1;
24276
24277    return !0;
24278  }, e.nextId = 0, e;
24279}(),
24280    _this = void 0,
24281    executeOp$2 = function (e, t, a) {
24282  return __awaiter(_this, void 0, void 0, function () {
24283    var r, n, s, o, p, u, i, m, l, c, d, y, f, g, h, N, x, V, b, P, T, v, O, S, _, w, A, D, E, I, C, M, k, F, z;
24284
24285    return __generator(this, function (j) {
24286      switch (j.label) {
24287        case 0:
24288          switch (e.op) {
24289            case "LoopCond":
24290              return [3, 1];
24291
24292            case "Switch":
24293              return [3, 2];
24294
24295            case "Merge":
24296              return [3, 4];
24297
24298            case "Enter":
24299              return [3, 5];
24300
24301            case "Exit":
24302              return [3, 6];
24303
24304            case "NextIteration":
24305              return [3, 7];
24306
24307            case "TensorArrayV3":
24308              return [3, 8];
24309
24310            case "TensorArrayWriteV3":
24311              return [3, 9];
24312
24313            case "TensorArrayReadV3":
24314              return [3, 10];
24315
24316            case "TensorArrayGatherV3":
24317              return [3, 11];
24318
24319            case "TensorArrayScatterV3":
24320              return [3, 12];
24321
24322            case "TensorArrayConcatV3":
24323              return [3, 13];
24324
24325            case "TensorArraySplitV3":
24326              return [3, 14];
24327
24328            case "TensorArraySizeV3":
24329              return [3, 15];
24330
24331            case "TensorArrayCloseV3":
24332              return [3, 16];
24333          }
24334
24335          return [3, 17];
24336
24337        case 1:
24338          return [2, [getParamValue("pred", e, t, a).clone()]];
24339
24340        case 2:
24341          return r = getParamValue("pred", e, t, a), n = getParamValue("data", e, t, a), [4, r.data()];
24342
24343        case 3:
24344          return [2, j.sent()[0] ? [void 0, n.clone()] : [n.clone(), void 0]];
24345
24346        case 4:
24347          return [2, (s = e.inputNames.find(function (e) {
24348            return void 0 !== getTensor(e, t, a);
24349          })) ? [getTensor(s, t, a).clone()] : void 0];
24350
24351        case 5:
24352          return o = getParamValue("frameName", e, t, a), p = getParamValue("tensor", e, t, a), a.enterFrame
24352(o), [2, [p.clone()]];
24353
24354        case 6:
24355          return u = getParamValue("tensor", e, t, a), a.exitFrame(), [2, [u.clone()]];
24356
24357        case 7:
24358          return i = getParamValue("tensor", e, t, a), a.nextIteration(), [2, [i.clone()]];
24359
24360        case 8:
24361          return m = getParamValue("size", e, t, a), l = getParamValue("dtype", e, t, a), c = getParamValue("elementShape", e, t, a), d = getParamValue("dynamicSize", e, t, a), y = getParamValue("clearAfterRead", e, t, a), f = getParamValue("identicalElementShapes", e, t, a), g = getParamValue("name", e, t, a), h = new TensorArray(g, l, m, c, f, d, y), a.addTensorArray(h), [2, [(0, _tfjsCore.scalar)(h.id), (0, _tfjsCore.scalar)(1)]];
24362
24363        case 9:
24364          return N = getParamValue("tensorArrayId", e, t, a), x = getParamValue("index", e, t, a), V = getParamValue("tensor", e, t, a), a.getTensorArray(N).write(x, V), [2, [(0, _tfjsCore.scalar)(1)]];
24365
24366        case 10:
24367          return b = getParamValue("tensorArrayId", e, t, a), P = getParamValue("index", e, t, a), [2, [a.getTensorArray(b).read(P)]];
24368
24369        case 11:
24370          return T = getParamValue("tensorArrayId", e, t, a), v = getParamValue("indices", e, t, a), O = getParamValue("dtype", e, t, a), [2, [a.getTensorArray(T).gather(v, O)]];
24371
24372        case 12:
24373          return S = getParamValue("tensorArrayId", e, t, a), _ = getParamValue("indices", e, t, a), w = getParamValue("tensor", e, t, a), a.getTensorArray(S).scatter(_, w), [2, [(0, _tfjsCore.scalar)(1)]];
24374
24375        case 13:
24376          return A = getParamValue("tensorArrayId", e, t, a), D = a.getTensorArray(A), E = getParamValue("dtype", e, t, a), [2, [D.concat(E)]];
24377
24378        case 14:
24379          return I = getParamValue("tensorArrayId", e, t, a), C = getParamValue("tensor", e, t, a), M = getParamValue("lengths", e, t, a), a.getTensorArray(I).split(M, C), [2, [(0, _tfjsCore.scalar)(1)]];
24380
24381        case 15:
24382          return k = getParamValue("tensorArrayId", e, t, a), F = a.getTensorArray(k), [2, [(0, _tfjsCore.scalar)(F.size(), "int32")]];
24383
24384        case 16:
24385          return z = getParamValue("tensorArrayId", e, t, a), a.getTensorArray(z).clearAndClose(), [2, [(0, _tfjsCore.scalar)(0)]];
24386
24387        case 17:
24388          throw TypeError("Node type " + e.op + " is not implemented");
24389      }
24390    });
24391  });
24392},
24393    executeOp$3 = function (e, t, a) {
24394  switch (e.op) {
24395    case "Conv1D":
24396      var r = getParamValue("stride", e, t, a),
24397          n = getParamValue("pad", e, t, a),
24398          s = getParamValue("dataFormat", e, t, a).toUpperCase(),
24399          o = getParamValue("dilation", e, t, a);
24400      return [(0, _tfjsCore.conv1d)(getParamValue("x", e, t, a), getParamValue("filter", e, t, a), r, n, s, o)];
24401
24402    case "Conv2D":
24403      r = getParamValue("strides", e, t, a), n = getParamValue("pad", e, t, a), s = getParamValue("dataFormat", e, t, a).toUpperCase();
24404      var p = getParamValue("dilations", e, t, a);
24405      return [(0, _tfjsCore.conv2d)(getParamValue("x", e, t, a), getParamValue("filter", e, t, a), [r[1], r[2]], n, s, [p[1], p[2]])];
24406
24407    case "_FusedConv2D":
24408    case "FusedDepthwiseConv2dNative":
24409      var u = getParamValue("fusedOps", e, t, a),
24410          i = u[0],
24411          m = u[1],
24412          l = "biasadd" === i,
24413          c = "prelu" === m,
24414          d = "fusedbatchnorm" === i,
24415          y = getParamValue("numArgs", e, t, a);
24416
24417      if (l) {
24418        if (c && 2 !== y) throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");
24419        if (!c && 1 !== y) throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.");
24420      }
24421
24422      if (d) throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported.");
24423      r = getParamValue("strides", e, t, a), n = getParamValue("pad", e, t, a), s = getParamValue("dataFormat", e, t, a).toUpperCase(), p = getParamValue("dilations", e, t, a);
24424      var f = getParamValue("args", e, t, a),
24425          g = f[0],
24426          h = f[1];
24427      return [("_FusedConv2D" === e.op ? _tfjsCore.fused.conv2d : _tfjsCore.fused.depthwiseConv2d)({
24428        x: getParamValue("x", e, t, a),
24429        filter: getParamValue("filter", e, t, a),
24430        strides: [r[1], r[2]],
24431        pad: n,
24432        dataFormat: s,
24433        dilations: [p[1], p[2]],
24434        bias: g,
24435        activation: m,
24436        preluActivationWeights: h
24437      })];
24438
24439    case "Conv2DBackpropInput":
24440    case "Conv2dTranspose":
24441      var N = getParamValue("outputShape", e, t, a);
24442      r = getParamValue("strides", e, t, a), n = getParamValue("pad", e, t, a);
24443      return [(0, _tfjsCore.conv2dTranspose)(getParamValue("x", e, t, a), getParamValue("filter", e, t, a), N, [r[1], r[2]], n)];
24444
24445    case "DepthwiseConv2dNative":
24446    case "DepthwiseConv2d":
24447      r = getParamValue("strides", e, t, a), n = getParamValue("pad", e, t, a), p = getParamValue("dilations", e, t, a), s = getParamValue("dataFormat", e, t, a).toUpperCase();
24448      return [(0, _tfjsCore.depthwiseConv2d)(getParamValue("input", e, t, a), getParamValue("filter", e, t, a), [r[1], r[2]], n, s, [p[1], p[2]])];
24449
24450    case "Conv3D":
24451      r = getParamValue("strides", e, t, a), n = getParamValue("pad", e, t, a), s = getParamValue("dataFormat", e, t, a).toUpperCase(), p = getParamValue("dilations", e, t, a);
24452      return [(0, _tfjsCore.conv3d)(getParamValue("x", e, t, a), getParamValue("filter", e, t, a), [r[1], r[2], r[3]], n, s, [p[1], p[2], p[3]])];
24453
24454    case "AvgPool":
24455      r = getParamValue("strides", e, t, a), n = getParamValue("pad", e, t, a);
24456      var x = getParamValue("kernelSize", e, t, a);
24457      return [(0, _tfjsCore.avgPool)(getParamValue("x", e, t, a), [x[1], x[2]], [r[1], r[2]], n)];
24458
24459    case "MaxPool":
24460      r = getParamValue("strides", e, t, a), n = getParamValue("pad", e, t, a), x = getParamValue("kernelSize", e, t, a);
24461      return [(0, _tfjsCore.maxPool)(getParamValue("x", e, t, a), [x[1], x[2]], [r[1], r[2]], n)];
24462
24463    case "AvgPool3D":
24464      r = getParamValue("strides", e, t, a), n = getParamValue("pad", e, t, a), x = getParamValue("kernelSize", e, t, a);
24465      return [(0, _tfjsCore.avgPool3d)(getParamValue("x", e, t, a), [x[1], x[2], x[3]], [r[1], r[2], r[3]], n)];
24466
24467    case "MaxPool3D":
24468      r = getParamValue("strides", e, t, a), n = getParamValue("pad", e, t, a), x = getParamValue("kernelSize", e, t, a);
24469      return [(0, _tfjsCore.maxPool3d)(getParamValue("x", e, t, a), [x[1], x[2], x[3]], [r[1], r[2], r[3]], n)];
24470
24471    default:
24472      throw TypeError("Node type " + e.op + " is not implemented");
24473  }
24474},
24475    executeOp$4 = function (e, t, a) {
24476  switch (e.op) {
24477    case "Fill":
24478      var r = getParamValue("shape", e, t, a),
24479          n = getParamValue("dtype", e, t, a),
24480          s = getParamValue("value", e, t, a);
24481      return [(0, _tfjsCore.fill)(r, s, n)];
24482
24483    case "LinSpace":
24484      var o = getParamValue("start", e, t, a),
24485          p = getParamValue("stop", e, t, a),
24486          u = getParamValue("num", e, t, a);
24487      return [(0, _tfjsCore.linspace)(o, p, u)];
24488
24489    case "Multinomial":
24490      var i = getParamValue("logits", e, t, a),
24491          m = getParamValue("numSamples", e, t, a),
24492          l = getParamValue("seed", e, t, a);
24493      return [(0, _tfjsCore.multinomial)(i, m, l)];
24494
24495    case "OneHot":
24496      var c = getParamValue("indices", e, t, a),
24497          d = getParamValue("depth", e, t, a),
24498          y = getParamValue("onValue", e, t, a),
24499          f = getParamValue("offValue", e, t, a);
24500      return [(0, _tfjsCore.oneHot)(c, d, y, f)];
24501
24502    case "Ones":
24503      return [(0, _tfjsCore.ones)(getParamValue("shape", e, t, a), getParamValue("dtype", e, t, a))];
24504
24505    case "OnesLike":
24506      return [(0, _tfjsCore.onesLike)(getParamValue("x", e, t, a))];
24507
24508    case "RandomUniform":
24509      return [(0, _tfjsCore.randomUniform)(getParamValue("shape", e, t, a), getParamValue("minval", e, t, a), getParamValue("maxval", e, t, a), getParamValue("dtype", e, t, a))];
24510
24511    case "Range":
24512      o = getParamValue("start", e, t, a);
24513      var g = getParamValue("stop", e, t, a),
24514          h = getParamValue("step", e, t, a);
24515      return [(0, _tfjsCore.range)(o, g, h, getParamValue("dtype", e, t, a))];
24516
24517    case "TruncatedNormal":
24518      r = getParamValue("shape", e, t, a);
24519      var N = getParamValue("mean", e, t, a),
24520          x = getParamValue("stdDev", e, t, a);
24521      l = getParamValue("seed", e, t, a);
24522      return [(0, _tfjsCore.truncatedNormal)(r, N, x, getParamValue("dtype", e, t, a), l)];
24523
24524    case "Zeros":
24525      return [(0, _tfjsCore.zeros)(getParamValue("shape", e, t, a), getParamValue("dtype", e, t, a))];
24526
24527    case "ZerosLike":
24528      return [(0, _tfjsCore.zerosLike)(getParamValue("x", e, t, a))];
24529
24530    default:
24531      throw TypeError("Node type " + e.op + " is not implemented");
24532  }
24533},
24534    _this$1 = void 0,
24535    executeOp$5 = function (e, t, a) {
24536  return __awaiter(_this$1, void 0, void 0, function () {
24537    var r, n, s, o, p, u, i, m;
24538    return __generator(this, function (l) {
24539      switch (l.label) {
24540        case 0:
24541          switch (e.op) {
24542            case "NonMaxSuppressionV5":
24543            case "NonMaxSuppressionV3":
24544            case "NonMaxSuppressionV2":
24545              return [3, 1];
24546
24547            case "Where":
24548              return [3, 5];
24549
24550            case "ListDiff":
24551              return [3, 7];
24552          }
24553
24554          return [3, 8];
24555
24556        case 1:
24557          return r = getParamValue("boxes", e, t, a), n = getParamValue("scores", e, t, a), s = getParamValue("maxOutputSize", e, t, a), o = getParamValue("iouThreshold", e, t, a), p = getParamValue("scoreThreshold", e, t, a), "NonMaxSuppressionV5" !== e.op ? [3, 3] : (u = getParamValue("softNmsSigma", e, t, a), [4, _tfjsCore.image.nonMaxSuppressionWithScoreAsync(r, n, s, o, p, u)]);
24558
24559        case 2:
24560          return [2, [(m = l.sent()).selectedIndices, m.selectedScores]];
24561
24562        case 3:
24563          return [4, _tfjsCore.image.nonMaxSuppressionAsync(r, n, s, o, p)];
24564
24565        case 4:
24566          return [2, [l.sent()]];
24567
24568        case 5:
24569          return i = getParamValue("condition", e, t, a).asType("bool"), [4, (0, _tfjsCore.whereAsync)(i)];
24570
24571        case 6:
24572          return m = [l.sent()], i.dispose(), [2, m];
24573
24574        case 7:
24575          return [2, (0, _tfjsCore.setdiff1dAsync)(getParamValue("x", e, t, a), getParamValue("y", e, t, a))];
24576
24577        case 8:
24578          throw TypeError("Node type " + e.op + " is not implemented");
24579      }
24580    });
24581  });
24582},
24583    executeOp$6 = function (e, t, a) {
24584  switch (e.op) {
24585    case "TopKV2":
24586      var r = getParamValue("x", e, t, a),
24587          n = getParamValue("k", e, t, a),
24588          s = getParamValue("sorted", e, t, a),
24589          o = (0, _tfjsCore.topk)(r, n, s);
24590      return [o.values, o.indices];
24591
24592    default:
24593      throw TypeError("Node type " + e.op + " is not implemented");
24594  }
24595},
24596    executeOp$7 = function (e, t, a) {
24597  switch (e.op) {
24598    case "Const":
24599      return t[e.name];
24600
24601    case "PlaceholderWithDefault":
24602      var r = getParamValue("default", e, t, a);
24603      return [getTensor(e.name, t, a) || r];
24604
24605    case "Placeholder":
24606      return [getTensor(e.name, t, a)];
24607
24608    case "Identity":
24609    case "StopGradient":
24610    case "FakeQuantWithMinMaxVars":
24611      return [getParamValue("x", e, t, a).clone()];
24612
24613    case "IdentityN":
24614      return getParamValue("x", e, t, a).map(function (e) {
24615        return e.clone();
24616      });
24617
24618    case "Snapshot":
24619      return [getParamValue("x", e, t, a).clone()];
24620
24621    case "Shape":
24622      return [(0, _tfjsCore.tensor1d)(getParamValue("x", e, t, a).shape, "int32")];
24623
24624    case "ShapeN":
24625      return getParamValue("x", e, t, a).map(function (e) {
24626        return (0, _tfjsCore.tensor1d)(e.shape);
24627      });
24628
24629    case "Size":
24630      return [(0, _tfjsCore.scalar)(getParamValue("x", e, t, a).size, "int32")];
24631
24632    case "Rank":
24633      return [(0, _tfjsCore.scalar)(getParamValue("x", e, t, a).rank, "int32")];
24634
24635    case "NoOp":
24636      return [(0, _tfjsCore.scalar)(1)];
24637
24638    case "Print":
24639      var n = getParamValue("x", e, t, a),
24640          s = getParamValue("data", e, t, a),
24641          o = getParamValue("message", e, t, a),
24642          p = getParamValue("summarize", e, t, a);
24643      console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."), console.log(o);
24644
24645      for (var u = 0; u < s.length; u++) console.log(Array.prototype.slice.call(s[u].dataSync()).slice(0, p));
24646
24647      return [n];
24648
24649    default:
24650      throw TypeError("Node type " + e.op + " is not implemented");
24651  }
24652},
24653    executeOp$8 = function (e, t, a) {
24654  switch (e.op) {
24655    case "ResizeBilinear":
24656      var r = getParamValue("images", e, t, a),
24657          n = getParamValue("size", e, t, a),
24658          s = getParamValue("alignCorners", e, t, a);
24659      return [_tfjsCore.image.resizeBilinear(r, [n[0], n[1]], s)];
24660
24661    case "ResizeNearestNeighbor":
24662      r = getParamValue("images", e, t, a), n = getParamValue("size", e, t, a), s = getParamValue("alignCorners", e, t, a);
24663      return [_tfjsCore.image.resizeNearestNeighbor(r, [n[0], n[1]], s)];
24664
24665    case "CropAndResize":
24666      var o = getParamValue("image", e, t, a),
24667          p = getParamValue("boxes", e, t, a),
24668          u = getParamValue("boxInd", e, t, a),
24669          i = getParamValue("cropSize", e, t, a),
24670          m = getParamValue("method", e, t, a),
24671          l = getParamValue("extrapolationValue", e, t, a);
24672      return [_tfjsCore.image.cropAndResize(o, p, u, i, m, l)];
24673
24674    default:
24675      throw TypeError("Node type " + e.op + " is not implemented");
24676  }
24677},
24678    executeOp$9 = function (e, t, a) {
24679  switch (e.op) {
24680    case "Equal":
24681      return [(0, _tfjsCore.equal)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24682
24683    case "NotEqual":
24684      return [(0, _tfjsCore.notEqual)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24685
24686    case "Greater":
24687      return [(0, _tfjsCore.greater)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24688
24689    case "GreaterEqual":
24690      return [(0, _tfjsCore.greaterEqual)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24691
24692    case "Less":
24693      return [(0, _tfjsCore.less)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24694
24695    case "LessEqual":
24696      return [(0, _tfjsCore.lessEqual)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24697
24698    case "LogicalAnd":
24699      return [(0, _tfjsCore.logicalAnd)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24700
24701    case "LogicalNot":
24702      return [(0, _tfjsCore.logicalNot)(getParamValue("a", e, t, a))];
24703
24704    case "LogicalOr":
24705      return [(0, _tfjsCore.logicalOr)(getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24706
24707    case "Select":
24708      return [(0, _tfjsCore.where)(getParamValue("condition", e, t, a), getParamValue("a", e, t, a), getParamValue("b", e, t, a))];
24709
24710    default:
24711      throw TypeError("Node type " + e.op + " is not implemented");
24712  }
24713},
24714    executeOp$10 = function (e, t, a) {
24715  switch (e.op) {
24716    case "BatchMatMul":
24717    case "BatchMatMulV2":
24718    case "MatMul":
24719      return [(0, _tfjsCore.matMul)(getParamValue("a", e, t, a), getParamValue("b", e, t, a), getParamValue("transposeA", e, t, a), getParamValue("transposeB", e, t, a))];
24720
24721    case "Transpose":
24722      return [(0, _tfjsCore.transpose)(getParamValue("x", e, t, a), getParamValue("perm", e, t, a))];
24723
24724    case "_FusedMatMul":
24725      var r = getParamValue("fusedOps", e, t, a),
24726          n = r[0],
24727          s = r[1],
24728          o = "biasadd" === n,
24729          p = "prelu" === s,
24730          u = getParamValue("numArgs", e, t, a);
24731
24732      if (o) {
24733        if (p && 2 !== u) throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");
24734        if (!p && 1 !== u) throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.");
24735      }
24736
24737      var i = getParamValue("args", e, t, a),
24738          m = i[0],
24739          l = i[1];
24740      return [_tfjsCore.fused.matMul({
24741        a: getParamValue("a", e, t, a),
24742        b: getParamValue("b", e, t, a),
24743        transposeA: getParamValue("transposeA", e, t, a),
24744        transposeB: getParamValue("transposeB", e, t, a),
24745        bias: m,
24746        activation: s,
24747        preluActivationWeights: l
24748      })];
24749
24750    default:
24751      throw TypeError("Node type " + e.op + " is not implemented");
24752  }
24753},
24754    executeOp$11 = function (e, t, a) {
24755  switch (e.op) {
24756    case "FusedBatchNorm":
24757    case "FusedBatchNormV2":
24758    case "FusedBatchNormV3":
24759      return [(0, _tfjsCore.batchNorm)(getParamValue("x", e, t, a), getParamValue("mean", e, t, a), getParamValue("variance", e, t, a), getParamValue("offset", e, t, a), getParamValue("scale", e, t, a), getParamValue("epsilon", e, t, a))];
24760
24761    case "LRN":
24762      return [(0, _tfjsCore.localResponseNormalization)(getParamValue("x", e, t, a), getParamValue("radius", e, t, a), getParamValue("bias", e, t, a), getParamValue("alpha", e, t, a), getParamValue("beta", e, t, a))];
24763
24764    case "Softmax":
24765      return [(0, _tfjsCore.softmax)(getParamValue("x", e, t, a))];
24766
24767    case "LogSoftmax":
24768      return [(0, _tfjsCore.logSoftmax)(getParamValue("x", e, t, a))];
24769
24770    case "SparseToDense":
24771      return [(0, _tfjsCore.sparseToDense)(getParamValue("sparseIndices", e, t, a), getParamValue("outputShape", e, t, a), getParamValue("sparseValues", e, t, a), getParamValue("defaultValue", e, t, a))];
24772
24773    default:
24774      throw TypeError("Node type " + e.op + " is not implemented");
24775  }
24776},
24777    executeOp$12 = function (e, t, a) {
24778  switch (e.op) {
24779    case "Max":
24780      var r = getParamValue("axis", e, t, a),
24781          n = getParamValue("keepDims", e, t, a);
24782      return [(0, _tfjsCore.max)(getParamValue("x", e, t, a), r, n)];
24783
24784    case "Mean":
24785      r = getParamValue("axis", e, t, a), n = getParamValue("keepDims", e, t, a);
24786      return [(0, _tfjsCore.mean)(getParamValue("x", e, t, a), r, n)];
24787
24788    case "Min":
24789      r = getParamValue("axis", e, t, a), n = getParamValue("keepDims", e, t, a);
24790      return [(0, _tfjsCore.min)(getParamValue("x", e, t, a), r, n)];
24791
24792    case "Sum":
24793      r = getParamValue("axis", e, t, a), n = getParamValue("keepDims", e, t, a);
24794      return [(0, _tfjsCore.sum)(getParamValue("x", e, t, a), r, n)];
24795
24796    case "All":
24797      r = getParamValue("axis", e, t, a), n = getParamValue("keepDims", e, t, a);
24798      return [(0, _tfjsCore.all)(getParamValue("x", e, t, a), r, n)];
24799
24800    case "Any":
24801      r = getParamValue("axis", e, t, a), n = getParamValue("keepDims", e, t, a);
24802      return [(0, _tfjsCore.any)(getParamValue("x", e, t, a), r, n)];
24803
24804    case "ArgMax":
24805      r = getParamValue("axis", e, t, a);
24806      return [(0, _tfjsCore.argMax)(getParamValue("x", e, t, a), r)];
24807
24808    case "ArgMin":
24809      r = getParamValue("axis", e, t, a);
24810      return [(0, _tfjsCore.argMin)(getParamValue("x", e, t, a), r)];
24811
24812    case "Prod":
24813      r = getParamValue("axis", e, t, a), n = getParamValue("keepDims", e, t, a);
24814      return [(0, _tfjsCore.prod)(getParamValue("x", e, t, a), r, n)];
24815
24816    default:
24817      throw TypeError("Node type " + e.op + " is not implemented");
24818  }
24819},
24820    executeOp$13 = function (e, t, a) {
24821  switch (e.op) {
24822    case "ConcatV2":
24823    case "Concat":
24824      var r = getParamValue("n", e, t, a),
24825          n = getParamValue("axis", e, t, a),
24826          s = getParamValue("tensors", e, t, a);
24827      return s = s.slice(0, r), [(0, _tfjsCore.concat)(s, n)];
24828
24829    case "GatherV2":
24830    case "Gather":
24831      n = getParamValue("axis", e, t, a);
24832      var o = getParamValue("x", e, t, a),
24833          p = getParamValue("indices", e, t, a);
24834      return [(0, _tfjsCore.gather)(o, p.asType("int32"), n)];
24835
24836    case "ReverseV2":
24837    case "Reverse":
24838      n = getParamValue("axis", e, t, a), o = getParamValue("x", e, t, a);
24839      return [(0, _tfjsCore.reverse)(o, n)];
24840
24841    case "Slice":
24842      var u = getParamValue("begin", e, t, a),
24843          i =
24843 getParamValue("size", e, t, a);
24844      return [(0, _tfjsCore.slice)(getParamValue("x", e, t, a), u, i)];
24845
24846    case "StridedSlice":
24847      u = getParamValue("begin", e, t, a);
24848      var m = getParamValue("end", e, t, a),
24849          l = getParamValue("strides", e, t, a),
24850          c = getParamValue("beginMask", e, t, a),
24851          d = getParamValue("endMask", e, t, a),
24852          y = getParamValue("ellipsisMask", e, t, a),
24853          f = getParamValue("newAxisMask", e, t, a),
24854          g = getParamValue("shrinkAxisMask", e, t, a),
24855          h = getParamValue("x", e, t, a);
24856      if (1 === u.length && h.shape.length > 1) for (var N = 1; N < h.shape.length; N++) u.push(0), m.push(h.shape[N]), l.push(l[0]);
24857      return [(0, _tfjsCore.stridedSlice)(h, u, m, l, c, d, y, f, g)];
24858
24859    case "Pack":
24860      return (0, _tfjsCore.tidy)(function () {
24861        var r = getParamValue("axis", e, t, a),
24862            n = getParamValue("tensors", e, t, a),
24863            s = n[0].shape,
24864            o = n[0].squeeze().shape,
24865            p = n.map(function (e) {
24866          var t = _tfjsCore.util.arraysEqual(e.shape, s);
24867
24868          if (!t && !_tfjsCore.util.arraysEqual(e.squeeze().shape, o)) throw new Error("the input tensors shape does not match");
24869          return t ? e : e.reshape(s);
24870        });
24871        return [(0, _tfjsCore.stack)(p, r)];
24872      });
24873
24874    case "Unpack":
24875      return (0, _tfjsCore.tidy)(function () {
24876        var r = getParamValue("axis", e, t, a),
24877            n = getParamValue("tensor", e, t, a);
24878        return (0, _tfjsCore.unstack)(n, r);
24879      });
24880
24881    case "Tile":
24882      var x = getParamValue("reps", e, t, a);
24883      return [(0, _tfjsCore.tile)(getParamValue("x", e, t, a), x)];
24884
24885    case "Split":
24886    case "SplitV":
24887      n = getParamValue("axis", e, t, a);
24888      var V = getParamValue("numOrSizeSplits", e, t, a);
24889      return (0, _tfjsCore.split)(getParamValue("x", e, t, a), V, n);
24890
24891    case "ScatterNd":
24892      p = getParamValue("indices", e, t, a);
24893      var b = getParamValue("values", e, t, a),
24894          P = getParamValue("shape", e, t, a);
24895      return [(0, _tfjsCore.scatterND)(p, b, P)];
24896
24897    case "GatherNd":
24898      var T = getParamValue("x", e, t, a);
24899      p = getParamValue("indices", e, t, a);
24900      return [(0, _tfjsCore.gatherND)(T, p)];
24901
24902    case "SparseToDense":
24903      p = getParamValue("sparseIndices", e, t, a), P = getParamValue("outputShape", e, t, a);
24904      var v = getParamValue("sparseValues", e, t, a),
24905          O = getParamValue("defaultValue", e, t, a);
24906      return [(0, _tfjsCore.sparseToDense)(p, v, P, v.dtype === O.dtype ? O : O.asType(v.dtype))];
24907
24908    default:
24909      throw TypeError("Node type " + e.op + " is not implemented");
24910  }
24911},
24912    executeOp$14 = function (e, t, a) {
24913  switch (e.op) {
24914    case "FFT":
24915      return [(0, _tfjsCore.fft)(getParamValue("x", e, t, a))];
24916
24917    case "IFFT":
24918      return [(0, _tfjsCore.ifft)(getParamValue("x", e, t, a))];
24919
24920    case "RFFT":
24921      return [(0, _tfjsCore.rfft)(getParamValue("x", e, t, a))];
24922
24923    case "IRFFT":
24924      return [(0, _tfjsCore.irfft)(getParamValue("x", e, t, a))];
24925
24926    default:
24927      throw TypeError("Node type " + e.op + " is not implemented");
24928  }
24929},
24930    executeOp$15 = function (e, t, a) {
24931  switch (e.op) {
24932    case "Cast":
24933      return [(0, _tfjsCore.cast)(getParamValue("x", e, t, a), getParamValue("dtype", e, t, a))];
24934
24935    case "ExpandDims":
24936      var r = getParamValue("axis", e, t, a);
24937      return [(0, _tfjsCore.expandDims)(getParamValue("x", e, t, a), r)];
24938
24939    case "Squeeze":
24940      r = getParamValue("axis", e, t, a);
24941      return [(0, _tfjsCore.squeeze)(getParamValue("x", e, t, a), r)];
24942
24943    case "Reshape":
24944      return [(0, _tfjsCore.reshape)(getParamValue("x", e, t, a), getParamValue("shape", e, t, a))];
24945
24946    case "PadV2":
24947    case "Pad":
24948      return [(0, _tfjsCore.pad)(getParamValue("x", e, t, a), split$1(getParamValue("padding", e, t, a), 2), getParamValue("constantValue", e, t, a))];
24949
24950    case "SpaceToBatchND":
24951      var n = getParamValue("blockShape", e, t, a),
24952          s = split$1(getParamValue("paddings", e, t, a), 2);
24953      return [(0, _tfjsCore.spaceToBatchND)(getParamValue("x", e, t, a), n, s)];
24954
24955    case "BatchToSpaceND":
24956      n = getParamValue("blockShape", e, t, a);
24957      var o = split$1(getParamValue("crops", e, t, a), 2);
24958      return [(0, _tfjsCore.batchToSpaceND)(getParamValue("x", e, t, a), n, o)];
24959
24960    case "DepthToSpace":
24961      var p = getParamValue("blockSize", e, t, a),
24962          u = getParamValue("dataFormat", e, t, a).toUpperCase();
24963      return [(0, _tfjsCore.depthToSpace)(getParamValue("x", e, t, a), p, u)];
24964
24965    default:
24966      throw TypeError("Node type " + e.op + " is not implemented");
24967  }
24968};
24969
24970function executeOp$16(e, t, a) {
24971  var r = function (e, t, a) {
24972    switch (e.category) {
24973      case "arithmetic":
24974        return (0, _tfjsCore.tidy)(function () {
24975          return executeOp(e, t, a);
24976        });
24977
24978      case "basic_math":
24979        return (0, _tfjsCore.tidy)(function () {
24980          return executeOp$1(e, t, a);
24981        });
24982
24983      case "control":
24984        return executeOp$2(e, t, a);
24985
24986      case "convolution":
24987        return (0, _tfjsCore.tidy)(function () {
24988          return executeOp$3(e, t, a);
24989        });
24990
24991      case "creation":
24992        return (0, _tfjsCore.tidy)(function () {
24993          return executeOp$4(e, t, a);
24994        });
24995
24996      case "dynamic":
24997        return executeOp$5(e, t, a);
24998
24999      case "evaluation":
25000        return (0, _tfjsCore.tidy)(function () {
25001          return executeOp$6(e, t, a);
25002        });
25003
25004      case "image":
25005        return (0, _tfjsCore.tidy)(function () {
25006          return executeOp$8(e, t, a);
25007        });
25008
25009      case "graph":
25010        return (0, _tfjsCore.tidy)(function () {
25011          return executeOp$7(e, t, a);
25012        });
25013
25014      case "logical":
25015        return (0, _tfjsCore.tidy)(function () {
25016          return executeOp$9(e, t, a);
25017        });
25018
25019      case "matrices":
25020        return (0, _tfjsCore.tidy)(function () {
25021          return executeOp$10(e, t, a);
25022        });
25023
25024      case "normalization":
25025        return (0, _tfjsCore.tidy)(function () {
25026          return executeOp$11(e, t, a);
25027        });
25028
25029      case "reduction":
25030        return (0, _tfjsCore.tidy)(function () {
25031          return executeOp$12(e, t, a);
25032        });
25033
25034      case "slice_join":
25035        return (0, _tfjsCore.tidy)(function () {
25036          return executeOp$13(e, t, a);
25037        });
25038
25039      case "spectral":
25040        return (0, _tfjsCore.tidy)(function () {
25041          return executeOp$14(e, t, a);
25042        });
25043
25044      case "transformation":
25045        return (0, _tfjsCore.tidy)(function () {
25046          return executeOp$15(e, t, a);
25047        });
25048
25049      case "custom":
25050        var r = getRegisteredOp(e.op);
25051        if (r && r.customExecutor) return r.customExecutor(new NodeValueImpl(e, t, a));
25052        throw TypeError("Custom op " + e.op + " is not registered.");
25053
25054      default:
25055        throw TypeError("Unknown op '" + e.op + "'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()");
25056    }
25057  }(e, t, a);
25058
25059  return r instanceof Promise ? r.then(function (e) {
25060    return [].concat(e);
25061  }) : [].concat(r);
25062}
25063
25064var ExecutionContext = function () {
25065  function e(e, t) {
25066    this.weightMap = e, this.tensorArrayMap = t, this.rootContext = {
25067      id: 0,
25068      frameName: "",
25069      iterationId: 0
25070    }, this.contexts = [this.rootContext], this.lastId = 0, this.generateCurrentContextIds();
25071  }
25072
25073  return e.prototype.newFrame = function (e, t) {
25074    return {
25075      id: e,
25076      frameName: t,
25077      iterationId: 0
25078    };
25079  }, Object.defineProperty(e.prototype, "currentContext", {
25080    get: function () {
25081      return this.contexts;
25082    },
25083    set: function (e) {
25084      this.contexts !== e && (this.contexts = e, this.generateCurrentContextIds());
25085    },
25086    enumerable: !0,
25087    configurable: !0
25088  }), Object.defineProperty(e.prototype, "currentContextId", {
25089    get: function () {
25090      return this._currentContextIds[0];
25091    },
25092    enumerable: !0,
25093    configurable: !0
25094  }), Object.defineProperty(e.prototype, "currentContextIds", {
25095    get: function () {
25096      return this._currentContextIds;
25097    },
25098    enumerable: !0,
25099    configurable: !0
25100  }), e.prototype.generateCurrentContextIds = function () {
25101    for (var e = [], t = 0; t < this.contexts.length - 1; t++) {
25102      var a = this.contexts.slice(0, this.contexts.length - t);
25103      e.push(this.contextIdforContexts(a));
25104    }
25105
25106    e.push(""), this._currentContextIds = e;
25107  }, e.prototype.contextIdforContexts = function (e) {
25108    return e ? e.map(function (e) {
25109      return 0 === e.id && 0 === e.iterationId ? "" : e.frameName + "-" + e.iterationId;
25110    }).join("/") : "";
25111  }, e.prototype.enterFrame = function (e) {
25112    this.contexts && (this.lastId++, this.contexts = this.contexts.slice(), this.contexts.push(this.newFrame(this.lastId, e)), this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)));
25113  }, e.prototype.exitFrame = function () {
25114    if (!(this.contexts && this.contexts.length > 1)) throw new Error("Cannot exit frame, the context is empty");
25115    this.contexts = this.contexts.slice(), this.contexts.splice(-1), this.currentContextIds.shift();
25116  }, e.prototype.nextIteration = function () {
25117    if (!(this.contexts && this.contexts.length > 0)) throw new Error("Cannot increase frame iteration, the context is empty");
25118    this.contexts = this.contexts.slice(), this.lastId++;
25119    var e = Object.assign({}, this.contexts[this.contexts.length - 1]);
25120    e.iterationId += 1, e.id = this.lastId, this.contexts.splice(-1, 1, e), this._currentContextIds.splice(0, 1, this.contextIdforContexts(this.contexts));
25121  }, e.prototype.getWeight = function (e) {
25122    return this.weightMap[e];
25123  }, e.prototype.addTensorArray = function (e) {
25124    this.tensorArrayMap[e.id] = e;
25125  }, e.prototype.getTensorArray = function (e) {
25126    return this.tensorArrayMap[e];
25127  }, e;
25128}();
25129
25130function getExecutionSubgraph(e, t, a) {
25131  for (var r = new Set(), n = [], s = null, o = null, p = new Set(), u = Object.keys(e).map(function (e) {
25132    return parseNodeName(e)[0];
25133  }), i = t.slice(); i.length > 0;) {
25134    var m = i.pop();
25135    (isControlFlow(m) || isDynamicShape(m)) && null == s && (o = (s = m).children.map(function (e) {
25136      return e.name;
25137    }).filter(function (e) {
25138      return r.has(e);
25139    })), r.add(m.name), null == a[m.name] && -1 === u.indexOf(m.name) && (0 !== m.inputs.length ? m.inputs.forEach(function (e) {
25140      p.has(e.name) || (p.add(e.name), i.push(e));
25141    }) : n.push(m.name));
25142  }
25143
25144  return {
25145    inputs: e,
25146    outputs: t,
25147    usedNodes: r,
25148    missingInputs: n,
25149    dynamicNode: s,
25150    syncInputs: o
25151  };
25152}
25153
25154function getNodesInTopologicalOrder(e, t, a) {
25155  var r = a.usedNodes,
25156      n = a.inputs,
25157      s = [];
25158  Object.keys(n).map(function (e) {
25159    return parseNodeName(e)[0];
25160  }).map(function (t) {
25161    return e.nodes[t];
25162  }).forEach(function (e) {
25163    r.has(e.name) && s.push(e);
25164  }), e.weights.forEach(function (e) {
25165    r.has(e.name) && s.push(e);
25166  });
25167
25168  for (var o = new Set(), p = []; s.length > 0;) {
25169    var u = s.pop();
25170    o.add(u.name), t[u.name] || p.push(u), u.children.forEach(function (e) {
25171      !o.has(e.name) && r.has(e.name) && e.inputs.every(function (e) {
25172        return o.has(e.name);
25173      }) && s.push(e);
25174    });
25175  }
25176
25177  return p;
25178}
25179
25180var CONTROL_FLOW_OPS = ["Switch", "Merge", "Enter", "Exit", "NextIteration"],
25181    DYNAMIC_SHAPE_OPS = ["NonMaxSuppressionV2", "NonMaxSuppressionV3", "NonMaxSuppressionV5", "Where"];
25182
25183function isControlFlow(e) {
25184  return CONTROL_FLOW_OPS.indexOf(e.op) >= 0;
25185}
25186
25187function isDynamicShape(e) {
25188  return DYNAMIC_SHAPE_OPS.indexOf(e.op) >= 0;
25189}
25190
25191var GraphExecutor = function () {
25192  function e(e) {
25193    this.graph = e, this.compiledMap = new Map(), this._weightMap = {}, this.SEPERATOR = ",", this._outputs = e.outputs, this._inputs = e.inputs, this._signature = e.signature;
25194  }
25195
25196  return Object.defineProperty(e.prototype, "weightMap", {
25197    get: function () {
25198      return this._weightMap;
25199    },
25200    set: function (e) {
25201      var t = Object.keys(e).map(function (t) {
25202        return e[t].map(function (e) {
25203          return e.id;
25204        });
25205      });
25206      this.weightIds = [].concat.apply([], t), this._weightMap = e;
25207    },
25208    enumerable: !0,
25209    configurable: !0
25210  }), Object.defineProperty(e.prototype, "inputs", {
25211    get: function () {
25212      return this._inputs.map(function (e) {
25213        return {
25214          name: e.name,
25215          shape: e.attrParams.shape ? e.attrParams.shape.value : void 0,
25216          dtype: e.attrParams.dtype ? e.attrParams.dtype.value : void 0
25217        };
25218      });
25219    },
25220    enumerable: !0,
25221    configurable: !0
25222  }), Object.defineProperty(e.prototype, "outputs", {
25223    get: function () {
25224      return this._outputs.map(function (e) {
25225        return {
25226          name: e.name,
25227          shape: e.attrParams.shape ? e.attrParams.shape.value : void 0,
25228          dtype: e.attrParams.dtype ? e.attrParams.dtype.value : void 0
25229        };
25230      });
25231    },
25232    enumerable: !0,
25233    configurable: !0
25234  }), Object.defineProperty(e.prototype, "inputNodes", {
25235    get: function () {
25236      return this._inputs.map(function (e) {
25237        return e.signatureKey || e.name;
25238      });
25239    },
25240    enumerable: !0,
25241    configurable: !0
25242  }), Object.defineProperty(e.prototype, "outputNodes", {
25243    get: function () {
25244      return this._outputs.map(function (e) {
25245        return e.signatureKey || e.name;
25246      });
25247    },
25248    enumerable: !0,
25249    configurable: !0
25250  }), e.prototype.getCompilationKey = function (e, t) {
25251    var a = e.map(function (e) {
25252      return e.name;
25253    }).sort(),
25254        r = t.map(function (e) {
25255      return e.name;
25256    }).sort();
25257    return a.join(this.SEPERATOR) + "--" + r.join(this.SEPERATOR);
25258  }, e.prototype.compile = function (e, t) {
25259    var a = getExecutionSubgraph(e, t, this.weightMap),
25260        r = a.missingInputs,
25261        n = a.dynamicNode,
25262        s = a.syncInputs;
25263    if (null != n) throw new Error("This execution contains the node '" + n.name + "', which has the dynamic op '" + n.op + "'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [" + s + "]");
25264
25265    if (r.length > 0) {
25266      var o = t.map(function (e) {
25267        return e.name;
25268      }),
25269          p = Object.keys(e);
25270      throw new Error("Cannot compute the outputs [" + o + "] from the provided inputs [" + p + "]. Missing the following inputs: [" + r + "]");
25271    }
25272
25273    return getNodesInTopologicalOrder(this.graph, this.weightMap, a);
25274  }, e.prototype.execute = function (e, t) {
25275    var a = this;
25276    e = this.mapInputs(e);
25277    var r = Object.keys(e).sort();
25278    this.checkInputs(e), this.checkInputShapeAndType(e), t = this.mapOutputs(t), this.checkOutputs(t);
25279    var n = r.map(function (e) {
25280      return a.graph.nodes[parseNodeName(e)[0]];
25281    }),
25282        s = t.map(function (e) {
25283      return a.graph.nodes[parseNodeName(e)[0]];
25284    }),
25285        o = this.getCompilationKey(n, s),
25286        p = this.compiledMap.get(o);
25287    null == p && (p = this.compile(e, s), this.compiledMap.set(o, p));
25288    var u = {};
25289    return (0, _tfjsCore.tidy)(function () {
25290      var r = new ExecutionContext(a._weightMap, u),
25291          n = __assign({}, a.weightMap);
25292
25293      Object.keys(e).forEach(function (t) {
25294        var a = parseNodeName(t),
25295            r = a[0],
25296            s = [];
25297        s[a[1]] = e[t], n[r] = s;
25298      });
25299
25300      for (var s = a.getFrozenTensorIds(n), o = {}, i = 0; i < p.length; i++) {
25301        var m = p[i];
25302
25303        if (!n[m.name]) {
25304          var l = executeOp$16(m, n, r);
25305          if (l instanceof Promise) throw new Error("The execution of the op '" + m.op + "' returned a promise. Please use model.executeAsync() instead.");
25306          n[m.name] = l, a.checkTensorForDisposal(m.name, m, n, r, s, t, o);
25307        }
25308      }
25309
25310      return t.map(function (e) {
25311        return getTensor(e, n, r);
25312      });
25313    });
25314  }, e.prototype.getFrozenTensorIds = function (e) {
25315    var t = [].concat.apply([], Object.keys(e).map(function (t) {
25316      return e[t];
25317    }).map(function (e) {
25318      return e.map(function (e) {
25319        return e.id;
25320      });
25321    }));
25322    return new Set(t);
25323  }, e.prototype.checkTensorForDisposal = function (e, t, a, r, n, s, o) {
25324    "control" !== t.category && -1 === s.indexOf(e) && (a[e].forEach(function (e) {
25325      null != e && (o[e.id] = (o[e.id] || 0) + t.children.length);
25326    }
25326), t.inputs.forEach(function (e) {
25327      if ("control" !== e.category) {
25328        var t = getTensorsForCurrentContenxt(e.name, a, r);
25329        null != t && t.forEach(function (e) {
25330          if (e && !n.has(e.id)) {
25331            var t = o[e.id];
25332            1 === t ? (e.dispose(), delete o[e.id]) : null != t && o[e.id]--;
25333          }
25334        });
25335      }
25336    }));
25337  }, e.prototype.executeAsync = function (e, t) {
25338    return __awaiter(this, void 0, void 0, function () {
25339      var a,
25340          r,
25341          n,
25342          s,
25343          o,
25344          p,
25345          u = this;
25346      return __generator(this, function (i) {
25347        switch (i.label) {
25348          case 0:
25349            return e = this.mapInputs(e), this.checkInputs(e), this.checkInputShapeAndType(e), t = this.mapOutputs(t), this.checkOutputs(t), a = {}, r = new ExecutionContext(this._weightMap, a), [4, this.executeWithControlFlow(e, r, t)];
25350
25351          case 1:
25352            return n = i.sent(), s = t.map(function (e) {
25353              return getTensor(e, n, r);
25354            }), o = new Set(s.map(function (e) {
25355              return e.id;
25356            })), p = new Set(Object.keys(e).map(function (t) {
25357              return e[t].id;
25358            })), Object.keys(n).forEach(function (e) {
25359              n[e].forEach(function (e) {
25360                !e || e.isDisposed || o.has(e.id) || p.has(e.id) || -1 !== u.weightIds.indexOf(e.id) || e.dispose();
25361              });
25362            }), [2, s];
25363        }
25364      });
25365    });
25366  }, e.prototype.executeWithControlFlow = function (e, t, a) {
25367    return __awaiter(this, void 0, void 0, function () {
25368      var r,
25369          n,
25370          s,
25371          o,
25372          p,
25373          u,
25374          i,
25375          m,
25376          l,
25377          c,
25378          d,
25379          y,
25380          f,
25381          g,
25382          h,
25383          N,
25384          x = this;
25385      return __generator(this, function (V) {
25386        switch (V.label) {
25387          case 0:
25388            r = Object.keys(e), n = r.map(function (e) {
25389              return x.graph.nodes[parseNodeName(e)[0]];
25390            }), s = a.map(function (e) {
25391              return x.graph.nodes[parseNodeName(e)[0]];
25392            }), o = getExecutionSubgraph(e, s, this.weightMap), p = o.usedNodes, u = o.missingInputs, i = o.dynamicNode, m = o.syncInputs, l = n.concat(this.graph.weights).map(function (e) {
25393              return {
25394                node: e,
25395                contexts: t.currentContext
25396              };
25397            }), c = __assign({}, this.weightMap), Object.keys(e).forEach(function (t) {
25398              var a = parseNodeName(t),
25399                  r = a[0],
25400                  n = [];
25401              n[a[1]] = e[t], c[r] = n;
25402            }), d = {}, y = this.getFrozenTensorIds(c), f = {}, V.label = 1;
25403
25404          case 1:
25405            return l.length > 0 ? (g = this.processStack(n, l, t, c, f, y, a, d, p), [4, Promise.all(g)]) : [3, 3];
25406
25407          case 2:
25408            return V.sent(), [3, 1];
25409
25410          case 3:
25411            if (null == i && console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."), (h = s.filter(function (e) {
25412              return !isControlFlow(e) && !getTensor(e.name, c, t);
25413            }).map(function (e) {
25414              return e.name;
25415            })).length > 0) throw N = "", null != i && (N = "Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [" + m + "]"), new Error("Cannot compute the outputs [" + h + "] from the provided inputs [" + r + "]. Consider providing the following inputs: [" + u + "]. " + 
25415N);
25416            return [2, c];
25417        }
25418      });
25419    });
25420  }, e.prototype.processStack = function (e, t, a, r, n, s, o, p, u) {
25421    for (var i = this, m = [], l = function () {
25422      var l = t.pop();
25423      a.currentContext = l.contexts;
25424      var d = "";
25425
25426      if ("Enter" === l.node.op && getParamValue("isConstant", l.node, r, a) && (d = getNodeNameAndIndex(l.node.name, a)[0]), -1 === e.indexOf(l.node)) {
25427        var y = executeOp$16(l.node, r, a);
25428        d || (d = getNodeNameAndIndex(l.node.name, a)[0]);
25429        var f = a.currentContext;
25430        y instanceof Promise ? m.push(y.then(function (e) {
25431          return r[d] = e, a.currentContext = f, i.checkTensorForDisposal(d, l.node, r, a, s, o, p), i.processChildNodes(l.node, t, a, r, n, u), e;
25432        })) : (r[d] = y, c.checkTensorForDisposal(d, l.node, r, a, s, o, p), c.processChildNodes(l.node, t, a, r, n, u));
25433      } else c.processChildNodes(l.node, t, a, r, n, u);
25434    }, c = this; t.length > 0;) l();
25435
25436    return m;
25437  }, e.prototype.processChildNodes = function (e, t, a, r, n, s) {
25438    e.children.forEach(function (e) {
25439      var o = getNodeNameAndIndex(e.name, a)[0];
25440      !n[o] && s.has(e.name) && ("Merge" === e.op ? e.inputNames.some(function (e) {
25441        return !!getTensor(e, r, a);
25442      }) && (n[o] = !0, t.push({
25443        contexts: a.currentContext,
25444        node: e
25445      })) : e.inputNames.every(function (e) {
25446        return !!getTensor(e, r, a);
25447      }) && (n[o] = !0, t.push({
25448        contexts: a.currentContext,
25449        node: e
25450      })));
25451    });
25452  }, e.prototype.dispose = function () {
25453    var e = this;
25454    Object.keys(this.weightMap).forEach(function (t) {
25455      return e.weightMap[t].forEach(function (e) {
25456        return e.dispose();
25457      });
25458    });
25459  }, e.prototype.checkInputShapeAndType = function (e) {
25460    var t = this;
25461    Object.keys(e).forEach(function (a) {
25462      var r = e[a],
25463          n = parseNodeName(a)[0],
25464          s = t.graph.nodes[n];
25465
25466      if (s.attrParams.shape && s.attrParams.shape.value) {
25467        var o = s.attrParams.shape.value,
25468            p = o.length === r.shape.length && r.shape.every(function (e, t) {
25469          return -1 === o[t] || o[t] === e;
25470        });
25471
25472        _tfjsCore.util.assert(p, function () {
25473          return "The shape of dict['" + s.name + "'] provided in model.execute(dict) must be [" + o + "], but was [" + r.shape + "]";
25474        });
25475      }
25476
25477      s.attrParams.dtype && s.attrParams.dtype.value && _tfjsCore.util.assert(r.dtype === s.attrParams.dtype.value, function () {
25478        return "The dtype of dict['" + s.name + "'] provided in model.execute(dict) must be " + s.attrParams.dtype.value + ", but was " + r.dtype;
25479      });
25480    });
25481  }, e.prototype.mapInputs = function (e) {
25482    var t = {};
25483
25484    for (var a in e) {
25485      if (null != this._signature && null != this._signature.inputs && null != this._signature.inputs[a]) t[this._signature.inputs[a].name] = e[a];else t[a] = e[a];
25486    }
25487
25488    return t;
25489  }, e.prototype.checkInputs = function (e) {
25490    var t = this,
25491        a = Object.keys(e).filter(function (e) {
25492      var a = parseNodeName(e)[0];
25493      return null == t.graph.nodes[a];
25494    });
25495    if (a.length > 0) throw new Error("The dict provided in model.execute(dict) has keys: [" + a + "] that are not part of graph");
25496  }, e.prototype.mapOutputs = function (e) {
25497    var t = this;
25498    return e.map(function (e) {
25499      return null != t._signature && null != t._signature.outputs && null != t._signature.outputs[e] ? t._signature.outputs[e].name : e;
25500    }, {});
25501  }, e.prototype.checkOutputs = function (e) {
25502    var t = this;
25503    e.forEach(function (e) {
25504      var a = parseNodeName(e)[0];
25505      if (!t.graph.nodes[a]) throw new Error("The output '" + e + "' is not found in the graph");
25506    });
25507  }, e;
25508}(),
25509    TFHUB_SEARCH_PARAM = "?tfjs-format=file",
25510    DEFAULT_MODEL_NAME = "model.json",
25511    GraphModel = function () {
25512  function e(e, t) {
25513    void 0 === t && (t = {}), this.modelUrl = e, this.loadOptions = t, this.version = "n/a", null == t && (this.loadOptions = {});
25514  }
25515
25516  return Object.defineProperty(e.prototype, "modelVersion", {
25517    get: function () {
25518      return this.version;
25519    },
25520    enumerable: !0,
25521    configurable: !0
25522  }), Object.defineProperty(e.prototype, "inputNodes", {
25523    get: function () {
25524      return this.executor.inputNodes;
25525    },
25526    enumerable: !0,
25527    configurable: !0
25528  }), Object.defineProperty(e.prototype, "outputNodes", {
25529    get: function () {
25530      return this.executor.outputNodes;
25531    },
25532    enumerable: !0,
25533    configurable: !0
25534  }
25534), Object.defineProperty(e.prototype, "inputs", {
25535    get: function () {
25536      return this.executor.inputs;
25537    },
25538    enumerable: !0,
25539    configurable: !0
25540  }), Object.defineProperty(e.prototype, "outputs", {
25541    get: function () {
25542      return this.executor.outputs;
25543    },
25544    enumerable: !0,
25545    configurable: !0
25546  }), Object.defineProperty(e.prototype, "weights", {
25547    get: function () {
25548      return this.executor.weightMap;
25549    },
25550    enumerable: !0,
25551    configurable: !0
25552  }), e.prototype.findIOHandler = function () {
25553    var e = this.modelUrl;
25554    if (null != e.load) this.handler = e;else if (null != this.loadOptions.requestInit) this.handler = _tfjsCore.io.browserHTTPRequest(e, this.loadOptions);else {
25555      var t = _tfjsCore.io.getLoadHandlers(e, this.loadOptions.onProgress);
25556
25557      if (0 === t.length) t.push(_tfjsCore.io.browserHTTPRequest(e, this.loadOptions));else if (t.length > 1) throw new Error("Found more than one (" + t.length + ") load handlers for URL '" + [e] + "'");
25558      this.handler = t[0];
25559    }
25560  }, e.prototype.load = function () {
25561    return __awaiter(this, void 0, void 0, function () {
25562      var e, t, a, r;
25563      return __generator(this, function (n) {
25564        switch (n.label) {
25565          case 0:
25566            if (this.findIOHandler(), null == this.handler.load) throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");
25567            return e = this, [4, this.handler.load()];
25568
25569          case 1:
25570            return e.artifacts = n.sent(), t = this.artifacts.modelTopology, a = {}, null != this.artifacts.userDefinedMetadata && (a = this.artifacts.userDefinedMetadata.signature), this.version = t.versions.producer + "." + t.versions.minConsumer, r = _tfjsCore.io.decodeWeights(this.artifacts.weightData, this.artifacts.weightSpecs), this.executor = new GraphExecutor(OperationMapper.Instance.transformGraph(t, a)), this.executor.weightMap = this.convertTensorMapToTensorsMap(r), [2, !0];
25571        }
25572      });
25573    });
25574  }, e.prototype.save = function (e, t) {
25575    return __awaiter(this, void 0, void 0, function () {
25576      var t;
25577      return __generator(this, function (a) {
25578        if ("string" == typeof e) {
25579          if (0 === (t = _tfjsCore.io.getSaveHandlers(e)).length) throw new Error("Cannot find any save handlers for URL '" + e + "'");
25580          if (t.length > 1) throw new Error("Found more than one (" + t.length + ") save handlers for URL '" + e + "'");
25581          e = t[0];
25582        }
25583
25584        if (null == e.save) throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");
25585        return [2, e.save(this.artifacts)];
25586      });
25587    });
25588  }, e.prototype.predict = function (e, t) {
25589    return this.execute(e, this.outputNodes);
25590  }, e.prototype.normalizeInputs = function (e) {
25591    if (!(e instanceof _tfjsCore.Tensor || Array.isArray(e))) return e;
25592    if ((e = Array.isArray(e) ? e : [e]).length !== this.inputNodes.length) throw new Error("Input tensor count mismatch,the graph model has " + this.inputNodes.length + " placeholders, while there are " + e.length + " input tensors.");
25593    return this.inputNodes.reduce(function (t, a, r) {
25594      return t[a] = e[r], t;
25595    }, {});
25596  }, e.prototype.normalizeOutputs = function (e) {
25597    return e = e || this.outputNodes, Array.isArray(e) ? e : [e];
25598  }, e.prototype.execute = function (e, t) {
25599    e = this.normalizeInputs(e), t = this.normalizeOutputs(t);
25600    var a = this.executor.execute(e, t);
25601    return a.length > 1 ? a : a[0];
25602  }, e.prototype.executeAsync = function (e, t) {
25603    return __awaiter(this, void 0, void 0, function () {
25604      var a;
25605      return __generator(this, function (r) {
25606        switch (r.label) {
25607          case 0:
25608            return e = this.normalizeInputs(e), t = this.normalizeOutputs(t), [4, this.executor.executeAsync(e, t)];
25609
25610          case 1:
25611            return [2, (a = r.sent()).length > 1 ? a : a[0]];
25612        }
25613      });
25614    });
25615  }, e.prototype.convertTensorMapToTensorsMap = function (e) {
25616    return Object.keys(e).reduce(function (t, a) {
25617      return t[a] = [e[a]], t;
25618    }, {});
25619  }, e.prototype.dispose = function () {
25620    this.executor.dispose();
25621  }, e;
25622}();
25623
25624exports.GraphModel = GraphModel;
25625
25626function loadGraphModel(e, t) {
25627  return void 0 === t && (t = {}), __awaiter(this, void 0, void 0, function () {
25628    var a;
25629    return __generator(this, function (r) {
25630      switch (r.label) {
25631        case 0:
25632          if (null == e) throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");
25633          return null == t && (t = {}), t.fromTFHub && null == e.load && (e.endsWith("/") || (e += "/"), e = "" + e + DEFAULT_MODEL_NAME + TFHUB_SEARCH_PARAM), [4, (a = new GraphModel(e, t)).load()];
25634
25635        case 1:
25636          return r.sent(), [2, a];
25637      }
25638    });
25639  });
25640}
25641
25642var version = "1.7.1";
25643exports.version_converter = version;
25644},{"@tensorflow/tfjs-core":"node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js","buffer":"node_modules/buffer/index.js"}],"node_modules/@tensorflow-models/posenet/dist/posenet.esm.js":[function(require,module,exports) {
25645"use strict";
25646
25647Object.defineProperty(exports, "__esModule", {
25648  value: true
25649});
25650exports.decodeMultiplePoses = decodeMultiplePoses;
25651exports.decodeSinglePose = decodeSinglePose;
25652exports.load = load;
25653exports.getAdjacentKeyPoints = getAdjacentKeyPoints;
25654exports.getBoundingBox = getBoundingBox;
25655exports.getBoundingBoxPoints = getBoundingBoxPoints;
25656exports.scaleAndFlipPoses = scaleAndFlipPoses;
25657exports.scalePose = scalePose;
25658exports.version = exports.PoseNet = exports.poseChain = exports.partNames = exp
25658orts.partIds = exports.partChannels = exports.MobileNet = void 0;
25659
25660var tf = _interopRequireWildcard(require("@tensorflow/tfjs-core"));
25661
25662var _tfjsConverter = require("@tensorflow/tfjs-converter");
25663
25664function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
25665
25666function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25667
25668/**
25669    * @license
25670    * Copyright 2019 Google LLC. All Rights Reserved.
25671    * Licensed under the Apache License, Version 2.0 (the "License");
25672    * you may not use this file except in compliance with the License.
25673    * You may obtain a copy of the License at
25674    *
25675    * http://www.apache.org/licenses/LICENSE-2.0
25676    *
25677    * Unless required by applicable law or agreed to in writing, software
25678    * distributed under the License is distributed on an "AS IS" BASIS,
25679    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25680    * See the License for the specific language governing permissions and
25681    * limitations under the License.
25682    * =============================================================================
25683    */
25684var extendStatics = function (e, t) {
25685  return (extendStatics = Object.setPrototypeOf || {
25686    __proto__: []
25687  } instanceof Array && function (e, t) {
25688    e.__proto__ = t;
25689  } || function (e, t) {
25690    for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
25691  })(e, t);
25692};
25693
25694function __extends(e, t) {
25695  function n() {
25696    this.constructor = e;
25697  }
25698
25699  extendStatics(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, new n());
25700}
25701
25702var __assign = function () {
25703  return (__assign = Object.assign || function (e) {
25704    for (var t, n = 1, r = arguments.length; n < r; n++) for (var o in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
25705
25706    return e;
25707  }).apply(this, arguments);
25708};
25709
25710function __awaiter(e, t, n, r) {
25711  return new (n || (n = Promise))(function (o, i) {
25712    function s(e) {
25713      try {
25714        a(r.next(e));
25715      } catch (e) {
25716        i(e);
25717      }
25718    }
25719
25720    function u(e) {
25721      try {
25722        a(r.throw(e));
25723      } catch (e) {
25724        i(e);
25725      }
25726    }
25727
25728    function a(e) {
25729      e.done ? o(e.value) : new n(function (t) {
25730        t(e.value);
25731      }).then(s, u);
25732    }
25733
25734    a((r = r.apply(e, t || [])).next());
25735  });
25736}
25737
25738function __generator(e, t) {
25739  var n,
25740      r,
25741      o,
25742      i,
25743      s = {
25744    label: 0,
25745    sent: function () {
25746      if (1 & o[0]) throw o[1];
25747      return o[1];
25748    },
25749    trys: [],
25750    ops: []
25751  };
25752  return i = {
25753    next: u(0),
25754    throw: u(1),
25755    return: u(2)
25756  }, "function" == typeof Symbol && (i[Symbol.iterator] = function () {
25757    return this;
25758  }), i;
25759
25760  function u(i) {
25761    return function (u) {
25762      return function (i) {
25763        if (n) throw new TypeError("Generator is already executing.");
25764
25765        for (; s;) try {
25766          if (n = 1, r && (o = 2 & i[0] ? r.return : i[0] ? r.throw || ((o = r.return) && o.call(r), 0) : r.next) && !(o = o.call(r, i[1])).done) return o;
25767
25768          switch (r = 0, o && (i = [2 & i[0], o.value]), i[0]) {
25769            case 0:
25770            case 1:
25771              o = i;
25772              break;
25773
25774            case 4:
25775              return s.label++, {
25776                value: i[1],
25777                done: !1
25778              };
25779
25780            case 5:
25781              s.label++, r = i[1], i = [0];
25782              continue;
25783
25784            case 7:
25785              i = s.ops.pop(), s.trys.pop();
25786              continue;
25787
25788            default:
25789              if (!(o = (o = s.trys).length > 0 && o[o.length - 1]) && (6 === i[0] || 2 === i[0])) {
25790                s = 0;
25791                continue;
25792              }
25793
25794              if (3 === i[0] && (!o || i[1] > o[0] && i[1] < o[3])) {
25795                s.label = i[1];
25796                break;
25797              }
25798
25799              if (6 === i[0] && s.label < o[1]) {
25800                s.label = o[1], o = i;
25801                break;
25802              }
25803
25804              if (o && s.label < o[2]) {
25805                s.label = o[2], s.ops.push(i);
25806                break;
25807              }
25808
25809              o[2] && s.ops.pop(), s.trys.pop();
25810              continue;
25811          }
25812
25813          i = t.call(e, s);
25814        } catch (e) {
25815          i = [6, e], r = 0;
25816        } finally {
25817          n = o = 0;
25818        }
25819
25820        if (5 & i[0]) throw i[1];
25821        return {
25822          value: i[0] ? i[1] : void 0,
25823          done: !0
25824        };
25825      }([i, u]);
25826    };
25827  }
25828}
25829
25830var BaseModel = function () {
25831  function e(e, t) {
25832    this.model = e, this.outputStride = t;
25833    var n = this.model.inputs[0].shape;
25834    tf.util.assert(-1 === n[1] && -1 === n[2], function () {
25835      return "Input shape [" + n[1] + ", " + n[2] + "] must both be equal to or -1";
25836    });
25837  }
25838
25839  return e.prototype.predict = function (e) {
25840    var t = this;
25841    return (0, tf.tidy)(function () {
25842      var n = t.preprocessInput(e.toFloat()).expandDims(0),
25843          r = t.model.predict(n).map(function (e) {
25844        return e.squeeze([0]);
25845      }),
25846          o = t.nameOutputResults(r);
25847      return {
25848        heatmapScores: o.heatmap.sigmoid(),
25849        offsets: o.offsets,
25850        displacementFwd: o.displacementFwd,
25851        displacementBwd: o.displacementBwd
25852      };
25853    });
25854  }, e.prototype.dispose = function () {
25855    this.model.dispose();
25856  }, e;
25857}(),
25858    MobileNet = function (e) {
25859  function t() {
25860    return null !== e && e.apply(this, arguments) || this;
25861  }
25862
25863  return __extends(t, e), t.prototype.preprocessInput = function (e) {
25864    return (0, tf.tidy)(function () {
25865      return (0, tf.div)(e, 127.5).sub(1);
25866    });
25867  }, t.prototype.nameOutputResults = function (e) {
25868    return {
25869      offsets: e[0],
25870      heatmap: e[1],
25871      displacementFwd: e[2],
25872      displacementBwd: e[3]
25873    };
25874  }, t;
25875}(BaseModel);
25876
25877exports.MobileNet = MobileNet;
25878
25879function half(e) {
25880  return Math.floor(e / 2);
25881}
25882
25883var MaxHeap = function () {
25884  function e(e, t) {
25885    this.priorityQueue = new Array(e), this.numberOfElements = -1, this.getElementValue = t;
25886  }
25887
25888  return e.prototype.enqueue = function (e) {
25889    this.priorityQueue[++this.numberOfElements] = e, this.swim(this.numberOfElements);
25890  }, e.prototype.dequeue = function () {
25891    var e = this.priorityQueue[0];
25892    return this.exchange(0, this.numberOfElements--), this.sink(0), this.priorityQueue[this.numberOfElements + 1] = null, e;
25893  }, e.prototype.empty = function () {
25894    return -1 === this.numberOfElements;
25895  }, e.prototype.size = function () {
25896    return this.numberOfElements + 1;
25897  }, e.prototype.all = function () {
25898    return this.priorityQueue.slice(0, this.numberOfElements + 1);
25899  }, e.prototype.max = function () {
25900    return this.priorityQueue[0];
25901  }, e.prototype.swim = function (e) {
25902    for (; e >
25902 0 && this.less(half(e), e);) this.exchange(e, half(e)), e = half(e);
25903  }, e.prototype.sink = function (e) {
25904    for (; 2 * e <= this.numberOfElements;) {
25905      var t = 2 * e;
25906      if (t < this.numberOfElements && this.less(t, t + 1) && t++, !this.less(e, t)) break;
25907      this.exchange(e, t), e = t;
25908    }
25909  }, e.prototype.getValueAt = function (e) {
25910    return this.getElementValue(this.priorityQueue[e]);
25911  }, e.prototype.less = function (e, t) {
25912    return this.getValueAt(e) < this.getValueAt(t);
25913  }, e.prototype.exchange = function (e, t) {
25914    var n = this.priorityQueue[e];
25915    this.priorityQueue[e] = this.priorityQueue[t], this.priorityQueue[t] = n;
25916  }, e;
25917}();
25918
25919function scoreIsMaximumInLocalWindow(e, t, n, r, o, i) {
25920  for (var s = i.shape, u = s[0], a = s[1], l = !0, p = Math.max(n - o, 0), c = Math.min(n + o + 1, u), f = p; f < c; ++f) {
25921    for (var d = Math.max(r - o, 0), h = Math.min(r + o + 1, a), m = d; m < h; ++m) if (i.get(f, m, e) > t) {
25922      l = !1;
25923      break;
25924    }
25925
25926    if (!l) break;
25927  }
25928
25929  return l;
25930}
25931
25932function buildPartWithScoreQueue(e, t, n) {
25933  for (var r = n.shape, o = r[0], i = r[1], s = r[2], u = new MaxHeap(o * i * s, function (e) {
25934    return e.score;
25935  }), a = 0; a < o; ++a) for (var l = 0; l < i; ++l) for (var p = 0; p < s; ++p) {
25936    var c = n.get(a, l, p);
25937    c < e || scoreIsMaximumInLocalWindow(p, c, a, l, t, n) && u.enqueue({
25938      score: c,
25939      part: {
25940        heatmapY: a,
25941        heatmapX: l,
25942        id: p
25943      }
25944    });
25945  }
25946
25947  return u;
25948}
25949
25950var partNames = ["nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle"],
25951    NUM_KEYPOINTS = partNames.length,
25952    partIds = partNames.reduce(function (e, t, n) {
25953  return e[t] = n, e;
25954}, {}),
25955    connectedPartNames = [["leftHip", "leftShoulder"], ["leftElbow", "leftShoulder"], ["leftElbow", "leftWrist"], ["leftHip", "leftKnee"], ["leftKnee", "leftAnkle"], ["rightHip", "rightShoulder"], ["rightElbow", "rightShoulder"], ["rightElbow", "rightWrist"], ["rightHip", "rightKnee"], ["rightKnee", "rightAnkle"], ["leftShoulder", "rightShoulder"], ["leftHip", "rightHip"]],
25956    poseChain = [["nose", "leftEye"], ["leftEye", "leftEar"], ["nose", "rightEye"], ["rightEye", "rightEar"], ["nose", "leftShoulder"], ["leftShoulder", "leftElbow"], ["leftElbow", "leftWrist"], ["leftShoulder", "leftHip"], ["leftHip", "leftKnee"], ["leftKnee", "leftAnkle"], ["nose", "rightShoulder"], ["rightShoulder", "rightElbow"], ["rightElbow", "rightWrist"], ["rightShoulder", "rightHip"], ["rightHip", "rightKnee"], ["rightKnee", "rightAnkle"]],
25957    connectedPartIndices = connectedPartNames.map(function (e) {
25958  var t = e[0],
25959      n = e[1];
25960  return [partIds[t], partIds[n]];
25961}),
25962    partChannels = ["left_face", "right_face", "right_upper_leg_front", "right_lower_leg_back", "right_upper_leg_back", "left_lower_leg_front", "left_upper_leg_front", "left_upper_leg_back", "left_lower_leg_back", "right_feet", "right_lower_leg_front", "left_feet", "torso_front", "torso_back", "right_upper_arm_front", "right_upper_arm_back", "right_lower_arm_back", "left_lower_arm_front", "left_upper_arm_front", "left_upper_arm_back", "left_lower_arm_back", "right_hand", "right_lower_arm_front", "left_hand"];
25963exports.partChannels = partChannels;
25964exports.poseChain = poseChain;
25965exports.partIds = partIds;
25966exports.partNames = partNames;
25967
25968function getOffsetPoint(e, t, n, r) {
25969  return {
25970    y: r.get(e, t, n),
25971    x: r.get(e, t, n + NUM_KEYPOINTS)
25972  };
25973}
25974
25975function getImageCoords(e, t, n) {
25976  var r = getOffsetPoint(e.heatmapY, e.heatmapX, e.id, n),
25977      o = r.y,
25978      i = r.x;
25979  return {
25980    x: e.heatmapX * t + i,
25981    y: e.heatmapY * t + o
25982  };
25983}
25984
25985function clamp(e, t, n) {
25986  return e < t ? t : e > n ? n : e;
25987}
25988
25989function squaredDistance(e, t, n, r) {
25990  var o = n - e,
25991      i = r - t;
25992  return o * o + i * i;
25993}
25994
25995function addVectors(e, t) {
25996  return {
25997    x: e.x + t.x,
25998    y: e.y + t.y
25999  };
26000}
26001
26002var parentChildrenTuples = poseChain.map(function (e) {
26003  var t = e[0],
26004      n = e[1];
26005  return [partIds[t], partIds[n]];
26006}),
26007    parentToChildEdges = parentChildrenTuples.map(function (e) {
26008  return e[1];
26009}),
26010    childToParentEdges = parentChildrenTuples.map(function (e) {
26011  return e[0];
26012});
26013
26014function getDisplacement(e, t, n) {
26015  var r = n.shape[2] / 2;
26016  return {
26017    y: n.get(t.y, t.x, e),
26018    x: n.get(t.y, t.x, r + e)
26019  };
26020}
26021
26022function getStridedIndexNearPoint(e, t, n, r) {
26023  return {
26024    y: clamp(Math.round(e.y / t), 0, n - 1),
26025    x: clamp(Math.round(e.x / t), 0, r - 1)
26026  };
26027}
26028
26029function traverseToTargetKeypoint(e, t, n, r, o, i, s, u) {
26030  void 0 === u && (u = 2);
26031
26032  for (var a = r.shape, l = a[0], p = a[1], c = getDisplacement(e, getStridedIndexNearPoint(t.position, i, l, p), s), f = addVectors(t.position, c), d = 0; d < u; d++) {
26033    var h = getStridedIndexNearPoint(f, i, l, p),
26034        m = getOffsetPoint(h.y, h.x, n, o);
26035    f = addVectors({
26036      x: h.x * i,
26037      y: h.y * i
26038    }, {
26039      x: m.x,
26040      y: m.y
26041    });
26042  }
26043
26044  var g = getStridedIndexNearPoint(f, i, l, p),
26045      _ = r.get(g.y, g.x, n);
26046
26047  return {
26048    position: f,
26049    part: partNames[n],
26050    score: _
26051  };
26052}
26053
26054function decodePose(e, t, n, r, o, i) {
26055  var s = t.shape[2],
26056      u = parentToChildEdges.length,
26057      a = new Array(s),
26058      l = e.part,
26059      p = e.score,
26060      c = getImageCoords(l, r, n);
26061  a[l.id] = {
26062    score: p,
26063    part: partNames[l.id],
26064    position: c
26065  };
26066
26067  for (var f = u - 1; f >= 0; --f) {
26068    var d = parentToChildEdges[f],
26069        h = childToParentEdges[f];
26070    a[d] && !a[h] && (a[h] = traverseToTargetKeypoint(f, a[d], h, t, n, r, i));
26071  }
26072
26073  for (f = 0; f < u; ++f) {
26074    d = childToParentEdges[f], h = parentToChildEdges[f];
26075    a[d] && !a[h] && (a[h] = traverseToTargetKeypoint(f, a[d], h, t, n, r, o));
26076  }
26077
26078  return a;
26079}
26080
26081function withinNmsRadiusOfCorrespondingPoint(e, t, n, r) {
26082  var o = n.x,
26083      i = n.y;
26084  return e.some(function (e) {
26085    var n = e.keypoints[r].position;
26086    return squaredDistance(i, o, n.y, n.x) <= t;
26087  });
26088}
26089
26090function getInstanceScore(e, t, n) {
26091  return n.reduce(function (n, r, o) {
26092    var i = r.position,
26093        s = r.score;
26094    return withinNmsRadiusOfCorrespondingPoint(e, t, i, o) || (n += s), n;
26095  }, 0) / n.length;
26096}
26097
26098var kLocalMaximumRadius = 1;
26099
26100function decodeMultiplePoses(e, t, n, r, o, i, s, u) {
26101  void 0 === s && (s = .5), void 0 === u && (u = 20);
26102
26103  for (var a = [], l = buildPartWithScoreQueue(s, kLocalMaximumRadius, e), p = u * u; a.length < i && !l.empty();) {
26104    var c = l.dequeue();
26105
26106    if (!withinNmsRadiusOfCorrespondingPoint(a, p, getImageCoords(c.part, o, t), c.part.id)) {
26107      var f = decodePose(c, e, t, o, n, r),
26108          d = getInstanceScore(a, p, f);
26109      a.push({
26110        keypoints: f,
26111        score: d
26112      });
26113    }
26114  }
26115
26116  return a;
26117}
26118
26119function mod(e, t) {
26120  return (0, tf.tidy)(function () {
26121    var n = e.div((0, tf.scalar)(t, "int32"));
26122    return e.sub(n.mul((0, tf.scalar)(t, "int32")));
26123  });
26124}
26125
26126function argmax2d(e) {
26127  var t = e.shape,
26128      n = t[0],
26129      r = t[1],
26130      o = t[2];
26131  return (0, tf.tidy)(function () {
26132    var t = e.reshape([n * r, o]).argMax(0),
26133        i = t.div((0, tf.scalar)(r, "int32")).expandDims(1),
26134        s = mod(t, r).expandDims(1);
26135    return (0, tf.concat)([i, s], 1);
26136  });
26137}
26138
26139function getPointsConfidence(e, t) {
26140  for (var n = t.shape[0], r = new Float32Array(n), o = 0; o < n; o++) {
26141    var i = t.get(o, 0),
26142        s = t.get(o, 1);
26143    r[o] = e.get(i, s, o);
26144  }
26145
26146  return r;
26147}
26148
26149function getOffsetPoint$1(e, t, n, r) {
26150  return {
26151    y: r.get(e, t, n),
26152    x: r.get(e, t, n + NUM_KEYPOINTS)
26153  };
26154}
26155
26156function getOffsetVectors(e, t) {
26157  for (var n = [], r = 0; r < NUM_KEYPOINTS; r++) {
26158    var o = getOffsetPoint$1(e.get(r, 0).valueOf(), e.get(r, 1).valueOf(), r, t),
26159        i = o.x,
26160        s = o.y;
26161    n.push(s), n.push(i);
26162  }
26163
26164  return (0, tf.tensor2d)(n, [NUM_KEYPOINTS, 2]);
26165}
26166
26167function getOffsetPoints(e, t, n) {
26168  return (0, tf.tidy)(function () {
26169    var r = getOffsetVectors(e, n);
26170    return e.toTensor().mul((0, tf.scalar)(t, "int32")).toFloat().add(r);
26171  });
26172}
26173
26174function decodeSinglePose(e, t, n) {
26175  return __awaiter(this, void 0, void 0, function () {
26176    var r, o, i, s, u, a, l, p, c, f;
26177    return __generator(this, function (d) {
26178      switch (d.label) {
26179        case 0:
26180          return r = 0, o = argmax2d(e), [4, Promise.all([e.buffer(), t.buffer(), o.buffer()])];
26181
26182        case 1:
26183          return i = d.sent(), s = i[0], u = i[1], a = i[2], [4, (l = getOffsetPoints(a, n, u)).buffer()];
26184
26185        case 2:
26186          return p = d.sent(), c = Array.from(getPointsConfidence(s, a)), f = c.map(function (e, t) {
26187            return r += e, {
26188              position: {
26189                y: p.get(t, 0),
26190                x: p.get(t, 1)
26191              },
26192              part: partNames[t],
26193              score: e
26194            };
26195          }), o.dispose(), l.dispose(), [2, {
26196            keypoints: f,
26197            score: r / f.length
26198          }];
26199      }
26200    });
26201  });
26202}
26203
26204var MOBILENET_BASE_URL = "https://storage.googleapis.com/tfjs-models/savedmodel/posenet/mobilenet/",
26205    RESNET50_BASE_URL = "https://storage.googleapis.com/tfjs-models/savedmodel/posenet/resnet50/";
26206
26207function resNet50Checkpoint(e, t) {
26208  var n = "model-stride" + e + ".json";
26209  return 4 === t ? RESNET50_BASE_URL + "float/" + n : RESNET50_BASE_URL + "quant" + t + "/" 
26209+ n;
26210}
26211
26212function mobileNetCheckpoint(e, t, n) {
26213  var r = {
26214    1: "100",
26215    .75: "075",
26216    .5: "050"
26217  },
26218      o = "model-stride" + e + ".json";
26219  return 4 === n ? MOBILENET_BASE_URL + "float/" + r[t] + "/" + o : MOBILENET_BASE_URL + "quant" + n + "/" + r[t] + "/" + o;
26220}
26221
26222var imageNetMean = [-123.15, -115.9, -103.06],
26223    ResNet = function (e) {
26224  function t() {
26225    return null !== e && e.apply(this, arguments) || this;
26226  }
26227
26228  return __extends(t, e), t.prototype.preprocessInput = function (e) {
26229    return e.add(imageNetMean);
26230  }, t.prototype.nameOutputResults = function (e) {
26231    var t = e[0],
26232        n = e[1];
26233    return {
26234      offsets: e[2],
26235      heatmap: e[3],
26236      displacementFwd: t,
26237      displacementBwd: n
26238    };
26239  }, t;
26240}(BaseModel);
26241
26242function eitherPointDoesntMeetConfidence(e, t, n) {
26243  return e < n || t < n;
26244}
26245
26246function getAdjacentKeyPoints(e, t) {
26247  return connectedPartIndices.reduce(function (n, r) {
26248    var o = r[0],
26249        i = r[1];
26250    return eitherPointDoesntMeetConfidence(e[o].score, e[i].score, t) ? n : (n.push([e[o], e[i]]), n);
26251  }, []);
26252}
26253
26254var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY,
26255    POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
26256
26257function getBoundingBox(e) {
26258  return e.reduce(function (e, t) {
26259    var n = e.maxX,
26260        r = e.maxY,
26261        o = e.minX,
26262        i = e.minY,
26263        s = t.position,
26264        u = s.x,
26265        a = s.y;
26266    return {
26267      maxX: Math.max(n, u),
26268      maxY: Math.max(r, a),
26269      minX: Math.min(o, u),
26270      minY: Math.min(i, a)
26271    };
26272  }, {
26273    maxX: NEGATIVE_INFINITY,
26274    maxY: NEGATIVE_INFINITY,
26275    minX: POSITIVE_INFINITY,
26276    minY: POSITIVE_INFINITY
26277  });
26278}
26279
26280function getBoundingBoxPoints(e) {
26281  var t = getBoundingBox(e),
26282      n = t.minX,
26283      r = t.minY,
26284      o = t.maxX,
26285      i = t.maxY;
26286  return [{
26287    x: n,
26288    y: r
26289  }, {
26290    x: o,
26291    y: r
26292  }, {
26293    x: o,
26294    y: i
26295  }, {
26296    x: n,
26297    y: i
26298  }];
26299}
26300
26301function toTensorBuffers3D(e) {
26302  return __awaiter(this, void 0, void 0, function () {
26303    return __generator(this, function (t) {
26304      return [2, Promise.all(e.map(function (e) {
26305        return e.buffer();
26306      }))];
26307    });
26308  });
26309}
26310
26311function scalePose(e, t, n, r, o) {
26312  return void 0 === r && (r = 0), void 0 === o && (o = 0), {
26313    score: e.score,
26314    keypoints: e.keypoints.map(function (e) {
26315      var i = e.score,
26316          s = e.part,
26317          u = e.position;
26318      return {
26319        score: i,
26320        part: s,
26321        position: {
26322          x: u.x * n + o,
26323          y: u.y * t + r
26324        }
26325      };
26326    })
26327  };
26328}
26329
26330function scalePoses(e, t, n, r, o) {
26331  return void 0 === r && (r = 0), void 0 === o && (o = 0), 1 === n && 1 === t && 0 === r && 0 === o ? e : e.map(function (e) {
26332    return scalePose(e, t, n, r, o);
26333  });
26334}
26335
26336function flipPoseHorizontal(e, t) {
26337  return {
26338    score: e.score,
26339    keypoints: e.keypoints.map(function (e) {
26340      var n = e.score,
26341          r = e.part,
26342          o = e.position;
26343      return {
26344        score: n,
26345        part: r,
26346        position: {
26347          x: t - 1 - o.x,
26348          y: o.y
26349        }
26350      };
26351    })
26352  };
26353}
26354
26355function flipPosesHorizontal(e, t) {
26356  return t <= 0 ? e : e.map(function (e) {
26357    return flipPoseHorizontal(e, t);
26358  });
26359}
26360
26361function toValidInputResolution(e, t) {
26362  return isValidInputResolution(e, t) ? e : Math.floor(e / t) * t + 1;
26363}
26364
26365function validateInputResolution(e) {
26366  tf.util.assert("number" == typeof e || "object" == typeof e, function () {
26367    return "Invalid inputResolution " + e + ". Should be a number or an object with width and height";
26368  }), "object" == typeof e && (tf.util.assert("number" == typeof e.width, function () {
26369    return "inputResolution.width has a value of " + e.width + " which is invalid; it must be a number";
26370  }), tf.util.assert("number" == typeof e.height, function () {
26371    return "inputResolution.height has a value of " + e.height + " which is invalid; it must be a number";
26372  }));
26373}
26374
26375function getValidInputResolutionDimensions(e, t) {
26376  return validateInputResolution(e), "object" == typeof e ? [toValidInputResolution(e.height, t), toValidInputResolution(e.width, t)] : [toValidInputResolution(e, t), toValidInputResolution(e, t)];
26377}
26378
26379var VALID_OUTPUT_STRIDES = [8, 16, 32];
26380
26381function assertValidOutputStride(e) {
26382  tf.util.assert("number" == typeof e, function () {
26383    return "outputStride is not a number";
26384  }), tf.util.assert(VALID_OUTPUT_STRIDES.indexOf(e) >= 0, function () {
26385    return "outputStride of " + e + " is invalid. It must be either 8, 16, or 32";
26386  });
26387}
26388
26389function isValidInputResolution(e, t) {
26390  return (e - 1) % t == 0;
26391}
26392
26393function assertValidResolution(e, t) {
26394  tf.util.assert("number" == typeof e[0] && "number" == typeof e[1], function () {
26395    return "both resolution values must be a number but had values " + e;
26396  }), tf.util.assert(isValidInputResolution(e[0], t), function () {
26397    return "height of " + e[0] + " is invalid for output stride " + t + ".";
26398  }), tf.util.assert(isValidInputResolution(e[1], t), function () {
26399    return "width of " + e[1] + " is invalid for output stride " + t + ".";
26400  });
26401}
26402
26403function getInputTensorDimensions(e) {
26404  return e instanceof tf.Tensor ? [e.shape[0], e.shape[1]] : [e.height, e.width];
26405}
26406
26407function toInputTensor(e) {
26408  return e instanceof tf.Tensor ? e : tf.browser.fromPixels(e);
26409}
26410
26411function padAndResizeTo(e, t) {
26412  var n = t[0],
26413      r = t[1],
26414      o = getInputTensorDimensions(e),
26415      i = o[0],
26416      s = o[1],
26417      u = r / n,
26418      a = [0, 0, 0, 0],
26419      l = a[0],
26420      p = a[1],
26421      c = a[2],
26422      f = a[3];
26423  return s / i < u ? (l = 0, p = 0, c = Math.round(.5 * (u * i - s)), f = Math.round(.5 * (u * i - s))) : (l = Math.round(.5 * (1 / u * s - i)), p = Math.round(.5 * (1 / u * s - i)), c = 0, f = 0), {
26424    resized: (0, tf.tidy)(function () {
26425      var t = toInputTensor(e);
26426      return (t = (0, tf.pad3d)(t, [[l, p], [c, f], [0, 0]])).resizeBilinear([n, r]);
26427    }),
26428    padding: {
26429      top: l,
26430      left: c,
26431      right: f,
26432      bottom: p
26433    }
26434  };
26435}
26436
26437function scaleAndFlipPoses(e, t, n, r, o) {
26438  var i = t[0],
26439      s = t[1],
26440      u = n[0],
26441      a = n[1],
26442      l = scalePoses(e, (i + r.top + r.bottom) / u, (s + r.left + r.right) / a, -r.top, -r.left);
26443  return o ? flipPosesHorizontal(l, s) : l;
26444}
26445
26446var MOBILENET_V1_CONFIG = {
26447  architecture: "MobileNetV1",
26448  outputStride: 16,
26449  multiplier: .75,
26450  inputResolution: 257
26451},
26452    VALID_ARCHITECTURE = ["MobileNetV1", "ResNet50"],
26453    VALID_STRIDE = {
26454  MobileNetV1: [8, 16, 32],
26455  ResNet50: [32, 16]
26456},
26457    VALID_MULTIPLIER = {
26458  MobileNetV1: [.5, .75, 1],
26459  ResNet50: [1]
26460},
26461    VALID_QUANT_BYTES = [1, 2, 4];
26462
26463function validateModelConfig(e) {
26464  if (null == (e = e || MOBILENET_V1_CONFIG).architecture && (e.architecture = "MobileNetV1"), VALID_ARCHITECTURE.indexOf(e.architecture) < 0) throw new Error("Invalid architecture " + e.architecture + ". Should be one of " + VALID_ARCHITECTURE);
26465  if (null == e.inputResolution && (e.inputResolution = 257), validateInputResolution(e.inputResolution), null == e.outputStride && (e.outputStride = 16), VALID_STRIDE[e.architecture].indexOf(e.outputStride) < 0) throw new Error("Invalid outputStride " + e.outputStride + ". Should be one of " + VALID_STRIDE[e.architecture] + " for architecutre " + e.architecture + ".");
26466  if (null == e.multiplier && (e.multiplier = 1), VALID_MULTIPLIER[e.architecture].indexOf(e.multiplier) < 0) throw new Error("Invalid multiplier " + e.multiplier + ". Should be one of " + VALID_MULTIPLIER[e.architecture] + " for architecutre " + e.architecture + ".");
26467  if (null == e.quantBytes && (e.quantBytes = 4), VALID_QUANT_BYTES.indexOf(e.quantBytes) < 0) throw new Error("Invalid quantBytes " + e.quantBytes + ". Should be one of " + VALID_QUANT_BYTES + " for architecutre " + e.architecture + ".");
26468  return e;
26469}
26470
26471var SINGLE_PERSON_INFERENCE_CONFIG = {
26472  flipHorizontal: !1
26473},
26474    MULTI_PERSON_INFERENCE_CONFIG = {
26475  flipHorizontal: !1,
26476  maxDetections: 5,
26477  scoreThreshold: .5,
26478  nmsRadius: 20
26479};
26480
26481function validateMultiPersonInputConfig(e) {
26482  var t = e.maxDetections,
26483      n = e.scoreThreshold,
26484      r = e.nmsRadius;
26485  if (t <= 0) throw new Error("Invalid maxDetections " + t + ". Should be > 0");
26486  if (n < 0 || n > 1) throw new Error("Invalid scoreThreshold " + n + ". Should be in range [0.0, 1.0]");
26487  if (r <= 0) throw new Error("Invalid nmsRadius " + r + ".");
26488}
26489
26490var PoseNet = function () {
26491  function e(e, t) {
26492    assertValidOutputStride(e.outputStride), assertValidResolution(t, e.outputStride), this.baseModel = e, this.inputResolution = t;
26493  }
26494
26495  return e.prototype.estimateMultiplePoses = function (e, t) {
26496    return void 0 === t && (t = MULTI_PERSON_INFERENCE_CONFIG), __awaiter(this, void 0, void 0, function () {
26497      var n, r, o, i, s, u, a, l, p, c, f, d, h, m, g, _, I, v, y, E, b;
26498
26499      return __generator(this, function (N) {
26500        switch (N.label) {
26501          case 0:
26502            return n = __assign({}, MULTI_PERSON_INFERENCE_CONFIG, t), validateMultiPersonInputConfig(t), r = this.baseModel.outputStride, o = this.inputResolution, i = getInputTensorDimensions(e), s = i[0], u = i[1], a = padAndResizeTo(e, o), l = a.resized, p = a.padding, c = this.baseModel.predict(l), f = c.heatmapScores, d = c.offsets, h = c.displacementFwd, m = c.displacementBwd, [4, toTensorBuffers3D([f, d, h, m])];
26503
26504          case 1:
26505            return g = N.sent(), _ = g[0], I = g[1], v = g[2], y = g[3], [4, decodeMultiplePoses(_, I, v, y, r, n.maxDetections, n.scoreThreshold, n.nmsRadius)];
26506
26507          case 2:
26508            return E = N.sent(), b = scaleAndFlipPoses(E, [s, u], o, p, n.flipHorizontal), f.dispose(), d.dispose(), h.dispose(), m.dispose(), l.dispose(), [2, b];
26509        }
26510      });
26511    });
26512  }, e.prototype.estimateSinglePose = function (e, t) {
26513    return void 0 === t && (t = SINGLE_PERSON_INFERENCE_CONFIG), __awaiter(this, void 0, void 0, function () {
26514      var n, r, o, i, s, u, a, l, p, c, f, d, h, m, g, _;
26515
26516      return __generator(this, function (I) {
26517        switch (I.label) {
26518          case 0:
26519            return n = __assign({}, SINGLE_PERSON_INFERENCE_CONFIG, t), r = this.baseModel.outputStride, o = this.inputResolution, i = getInputTensorDimensions(e), s = i[0], u = i[1], a = padAndResizeTo(e, o), l = a.resized, p = a.padding, c = this.baseModel.predict(l), f = c.heatmapScores, d = c.offsets, h = c.displacementFwd, m = c.displacementBwd, [4, decodeSinglePose(f, d, r)];
26520
26521          case 1:
26522            return g = I.sent(), _ = scaleAndFlipPoses([g], [s, u], o, p, n.flipHorizontal), f.dispose(), d.dispose(), h.dispose(), m.dispose(), l.dispose(), [2, _[0]];
26523        }
26524      });
26525    });
26526  }, e.prototype.estimatePoses = function (e, t) {
26527    return __awaiter(this, void 0, void 0, function () {
26528      return __generator(this, function (n) {
26529        switch (n.label) {
26530          case 0:
26531            return "single-person" !== t.decodingMethod ? [3, 2] : [4, this.estimateSinglePose(e, t)];
26532
26533          case 1:
26534            return [2, [n.sent()]];
26535
26536          case 2:
26537            return [2, this.estimateMultiplePoses(e, t)];
26538        }
26539      });
26540    });
26541  }, e.prototype.dispose = function () {
26542    this.baseModel.dispose();
26543  }, e;
26544}();
26545
26546exports.PoseNet = PoseNet;
26547
26548function loadMobileNet(e) {
26549  return __awaiter(this, void 0, void 0, function () {
26550    var t, n, r, o, i, s, u;
26551    return __generator(this, function (a) {
26552      switch (a.label) {
26553        case 0:
26554          if (t = e.outputStride, n = e.quantBytes, r = e.multiplier, null == tf) throw new Error("Cannot find TensorFlow.js. If you are using a <script> tag, please also include @tensorflow/tfjs on the page before using this\n        model.");
26555          return o = mobileNetCheckpoint(t, r, n), [4, (0, _tfjsConverter.loadGraphModel)(e.modelUrl || o)];
26556
26557        case 1:
26558          return i = a.sent(), s = new MobileNet(i, t), u = getValidInputResolutionDimensions(e.inputResolution, s.outputStride), [2, new PoseNet(s, u)];
26559      }
26560    });
26561  });
26562}
26563
26564function loadResNet(e) {
26565  return __awaiter(this, void 0, void 0, function () {
26566    var t, n, r, o, i, s;
26567    return __generator(this, function (u) {
26568      switch (u.label) {
26569        case 0:
26570          if (t = e.outputStride, n = e.quantBytes, null == tf) throw new Error("Cannot find TensorFlow.js. If you are using a <script> tag, please also include @tensorflow/tfjs on the page before using this\n        model.");
26571          return r = resNet50Checkpoint(t, n), [4, (0, _tfjsConverter.loadGraphModel)(e.modelUrl || r)];
26572
26573        case 1:
26574          return o = u.sent(), i = new ResNet(o, t), s = getValidInputResolutionDimensions(e.inputResolution, i.outputStride), [2, new PoseNet(i, s)];
26575      }
26576    });
26577  });
26578}
26579
26580function load(e) {
26581  return void 0 === e && (e = MOBILENET_V1_CONFIG), __awaiter(this, void 0, void 0, function () {
26582    return __generator(this, function (t) {
26583      return "ResNet50" === (e = validateModelConfig(e)).architecture ? [2, loadResNet(e)] : "MobileNetV1" === e.architecture ? [2, loadMobileNet(e)] : [2, null];
26584    });
26585  });
26586}
26587
26588var version = "2.2.1";
26589exports.version = version;
26590},{"@tensorflow/tfjs-core":"node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js","@tensorflow/tfjs-converter":"node_modules/@tensorflow/tfjs-converter/dist/tf-converter.esm.js"}],"node_modules/@tensorflow-models/facemesh/dist/facemesh.esm.js":[function(require,module,exports) {
26591"use strict";
26592
26593Object.defineProperty(exports, "__esModule", {
26594  value: true
26595});
26596exports.load = load$1;
26597exports.FaceMesh = void 0;
26598
26599var _tfjsCore = require("@tensorflow/tfjs-core");
26600
26601var _tfjsConverter = require("@tensorflow/tfjs-converter");
26602
26603/**
26604    * @license
26605    * Copyright 2020 Google LLC. All Rights Reserved.
26606    * Licensed under the Apache License, Version 2.0 (the "License");
26607    * you may not use this file except in compliance with the License.
26608    * You may obtain a copy of the License at
26609    *
26610    * http://www.apache.org/licenses/LICENSE-2.0
26611    *
26612    * Unless required by applicable law or agreed to in writing, software
26613    * distributed under the License is distributed on an "AS IS" BASIS,
26614    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26615    * See the License for the specific language governing permissions and
26616    * limitations under the License.
26617    * =============================================================================
26618    */
26619const disposeBox = e => {
26620  e.startEndTensor.dispose(), e.startPoint.dispose(), e.endPoint.dispose();
26621},
26622      createBox = e => ({
26623  startEndTensor: e,
26624  startPoint: (0, _tfjsCore.slice)(e, [0, 0], [-1, 2]),
26625  endPoint: (0, _tfjsCore.slice)(e, [0, 2], [-1, 2])
26626}),
26627      scaleBox = (e, t) => {
26628  const s = (0, _tfjsCore.mul)(e.startPoint, t),
26629        o = (0, _tfjsCore.mul)(e.endPoint, t),
26630        n = (0, _tfjsCore.concat2d)([s, o], 1);
26631  return createBox(n);
26632},
26633      ANCHORS_CONFIG = {
26634  strides: [8, 16],
26635  anchors: [2, 6]
26636},
26637      NUM_LANDMARKS = 6;
26638
26639function generateAnchors(e, t, s) {
26640  const o = [];
26641
26642  for (let n = 0; n < s.strides.length; n++) {
26643    const i = s.strides[n],
26644          r = Math.floor((t + i - 1) / i),
26645          a = Math.floor((e + i - 1) / i),
26646          c = s.anchors[n];
26647
26648    for (let e = 0; e < r; e++) {
26649      const t = i * (e + .5);
26650
26651      for (let e = 0; e < a; e++) {
26652        const s = i * (e + .5);
26653
26654        for (let e = 0; e < c; e++) o.push([s, t]);
26655      }
26656    }
26657  }
26658
26659  return o;
26660}
26661
26662function decodeBounds(e, t, s) {
26663  const o = (0, _tfjsCore.slice)(e, [0, 1], [-1, 2]),
26664        n = (0, _tfjsCore.add)(o, t),
26665        i = (0, _tfjsCore.slice)(e, [0, 3], [-1, 2]),
26666        r = (0, _tfjsCore.div)(i, s),
26667        a = (0, _tfjsCore.div)(n, s),
26668        c = (0, _tfjsCore.div)(r, 2),
26669        l = (0, _tfjsCore.sub)(a, c),
26670        d = (0, _tfjsCore.add)(a, c),
26671        h = (0, _tfjsCore.mul)(l, s),
26672        u = (0, _tfjsCore.mul)(d, s);
26673  return (0, _tfjsCore.concat2d)([h, u], 1);
26674}
26675
26676function getInputTensorDimensions(e) {
26677  return e instanceof _tfjsCore.Tensor ? [e.shape[0], e.shape[1]] : [e.height, e.width];
26678}
26679
26680function flipFaceHorizontal(e, t) {
26681  let s, o, n;
26682
26683  if (e.topLeft instanceof _tfjsCore.Tensor && e.bottomRight instanceof _tfjsCore.Tensor) {
26684    const [i, r] = (0, _tfjsCore.tidy)(() => [(0, _tfjsCore.concat)([(0, _tfjsCore.sub)(t - 1, e.topLeft.slice(0, 1)), e.topLeft.slice(1, 1)]), (0, _tfjsCore.concat)([(0, _tfjsCore.sub)(t - 1, e.bottomRight.slice(0, 1)), e.bottomRight.slice(1, 1)])]);
26685    s = i, o = r, null != e.landmarks && (n = (0, _tfjsCore.tidy)(() => {
26686      const s = (0, _tfjsCore.sub)((0, _tfjsCore.tensor1d)([t - 1, 0]), e.landmarks),
26687            o = (0, _tfjsCore.tensor1d)([1, -1]);
26688      return (0, _tfjsCore.mul)(s, o);
26689    }));
26690  } else {
26691    const [i, r] = e.topLeft,
26692          [a, c] = e.bottomRight;
26693    s = [t - 1 - i, r], o = [t - 1 - a, c], null != e.landmarks && (n = e.landmarks.map(e => [t - 1 - e[0], e[1]]));
26694  }
26695
26696  const i = {
26697    topLeft: s,
26698    bottomRight: o
26699  };
26700  return null != n && (i.landmarks = n), null != e.probability && (i.probability = e.probability instanceof _tfjsCore.Tensor ? e.probability.clone() : e.probability), i;
26701}
26702
26703function scaleBoxFromPrediction(e, t) {
26704  return (0, _tfjsCore.tidy)(() => {
26705    let s;
26706    return s = e.hasOwnProperty("box") ? e.box : e, scaleBox(s, t).startEndTensor.squeeze();
26707  });
26708}
26709
26710class BlazeFaceModel {
26711  constructor(e, t, s, o, n, i) {
26712    this.blazeFaceModel = e, this.width = t, this.height = s, this.maxFaces = o, this.anchorsData = generateAnchors(t, s, ANCHORS_CONFIG), this.anchors = (0, _tfjsCore.tensor2d)(this.anchorsData), this.inputSizeData = [t, s], this.inputSize = (0, _tfjsCore.tensor1d)([t, s]), this.iouThreshold = n, this.scoreThreshold = i;
26713  }
26714
26715  async getBoundingBoxes(e, t, s = !0) {
26716    const [o, n, i] = (0, _tfjsCore.tidy)(() => {
26717      const t = e.resizeBilinear([this.width, this.height]),
26718            s = (0, _tfjsCore.mul)((0, _tfjsCore.sub)(t.div(255), .5), 2),
26719            o = this.blazeFaceModel.predict(s).squeeze(),
26720            n = decodeBounds(o, this.anchors, this.inputSize),
26721            i = (0, _tfjsCore.slice)(o, [0, 0], [-1, 1]);
26722      return [o, n, (0, _tfjsCore.sigmoid)(i).squeeze()];
26723    }),
26724          r = console.warn;
26725
26726    console.warn = () => {};
26727
26728    const a = _tfjsCore.image.nonMaxSuppression(n, i, this.maxFaces, this.iouThreshold, this.scoreThreshold);
26729
26730    console.warn = r;
26731    const c = await a.array();
26732    a.dispose();
26733    let l = c.map(e => (0, _tfjsCore.slice)(n, [e, 0], [1, -1]));
26734    t || (l = await Promise.all(l.map(async e => {
26735      const t = await e.array();
26736      return e.dispose(), t;
26737    }
26737)));
26738    const d = e.shape[1],
26739          h = e.shape[2];
26740    let u;
26741    u = t ? (0, _tfjsCore.div)([h, d], this.inputSize) : [h / this.inputSizeData[0], d / this.inputSizeData[1]];
26742    const p = [];
26743
26744    for (let e = 0; e < l.length; e++) {
26745      const n = l[e],
26746            r = (0, _tfjsCore.tidy)(() => {
26747        const r = createBox(n instanceof _tfjsCore.Tensor ? n : (0, _tfjsCore.tensor2d)(n));
26748        if (!s) return r;
26749        const a = c[e];
26750        let l;
26751        return l = t ? this.anchors.slice([a, 0], [1, 2]) : this.anchorsData[a], {
26752          box: r,
26753          landmarks: (0, _tfjsCore.slice)(o, [a, NUM_LANDMARKS - 1], [1, -1]).squeeze().reshape([NUM_LANDMARKS, -1]),
26754          probability: (0, _tfjsCore.slice)(i, [a], [1]),
26755          anchor: l
26756        };
26757      });
26758      p.push(r);
26759    }
26760
26761    return n.dispose(), i.dispose(), o.dispose(), {
26762      boxes: p,
26763      scaleFactor: u
26764    };
26765  }
26766
26767  async estimateFaces(e, t = !1, s = !1, o = !0) {
26768    const [, n] = getInputTensorDimensions(e),
26769          i = (0, _tfjsCore.tidy)(() => (e instanceof _tfjsCore.Tensor || (e = _tfjsCore.browser.fromPixels(e)), e.toFloat().expandDims(0))),
26770          {
26771      boxes: r,
26772      scaleFactor: a
26773    } = await this.getBoundingBoxes(i, t, o);
26774    return i.dispose(), t ? r.map(e => {
26775      const t = scaleBoxFromPrediction(e, a);
26776      let i = {
26777        topLeft: t.slice([0], [2]),
26778        bottomRight: t.slice([2], [2])
26779      };
26780
26781      if (o) {
26782        const {
26783          landmarks: t,
26784          probability: s,
26785          anchor: o
26786        } = e,
26787              n = t.add(o).mul(a);
26788        i.landmarks = n, i.probability = s;
26789      }
26790
26791      return s && (i = flipFaceHorizontal(i, n)), i;
26792    }) : Promise.all(r.map(async e => {
26793      const t = scaleBoxFromPrediction(e, a);
26794      let i;
26795
26796      if (o) {
26797        const [s, o, n] = await Promise.all([e.landmarks, t, e.probability].map(async e => e.array())),
26798              r = e.anchor,
26799              [c, l] = a,
26800              d = s.map(e => [(e[0] + r[0]) * c, (e[1] + r[1]) * l]);
26801        i = {
26802          topLeft: o.slice(0, 2),
26803          bottomRight: o.slice(2),
26804          landmarks: d,
26805          probability: n
26806        }, disposeBox(e.box), e.landmarks.dispose(), e.probability.dispose();
26807      } else {
26808        const e = await t.array();
26809        i = {
26810          topLeft: e.slice(0, 2),
26811          bottomRight: e.slice(2)
26812        };
26813      }
26814
26815      return t.dispose(), s && (i = flipFaceHorizontal(i, n)), i;
26816    }));
26817  }
26818
26819}
26820
26821const BLAZEFACE_MODEL_URL = "https://tfhub.dev/tensorflow/tfjs-model/blazeface/1/default/1";
26822
26823async function load({
26824  maxFaces: e = 10,
26825  inputWidth: t = 128,
26826  inputHeight: s = 128,
26827  iouThreshold: o = .3,
26828  scoreThreshold: n = .75
26829} = {}) {
26830  const i = await (0, _tfjsConverter.loadGraphModel)(BLAZEFACE_MODEL_URL, {
26831    fromTFHub: !0
26832  });
26833  return new BlazeFaceModel(i, t, s, e, o, n);
26834}
26835
26836const MESH_ANNOTATIONS = {
26837  silhouette: [10, 338, 297, 332, 284, 251, 389, 356, 454, 323, 361, 288, 397, 365, 379, 378, 400, 377, 152, 148, 176, 149, 150, 136, 172, 58, 132, 93, 234, 127, 162, 21, 54, 103, 67, 109],
26838  lipsUpperOuter: [61, 185, 40, 39, 37, 0, 267, 269, 270, 409, 291],
26839  lipsLowerOuter: [146, 91, 181, 84, 17, 314, 405, 321, 375, 291],
26840  lipsUpperInner: [78, 191, 80, 81, 82, 13, 312, 311, 310, 415, 308],
26841  lipsLowerInner: [78, 95, 88, 178, 87, 14, 317, 402, 318, 324, 308],
26842  rightEyeUpper0: [246, 161, 160, 159, 158, 157, 173],
26843  rightEyeLower0: [33, 7, 163, 144, 145, 153, 154, 155, 133],
26844  rightEyeUpper1: [247, 30, 29, 27, 28, 56, 190],
26845  rightEyeLower1: [130, 25, 110, 24, 23, 22, 26, 112, 243],
26846  rightEyeUpper2: [113, 225, 224, 223, 222, 221, 189],
26847  rightEyeLower2: [226, 31, 228, 229, 230, 231, 232, 233, 244],
26848  rightEyeLower3: [143, 111, 117, 118, 119, 120, 121, 128, 245],
26849  rightEyebrowUpper: [156, 70, 63, 105, 66, 107, 55, 193],
26850  rightEyebrowLower: [35, 124, 46, 53, 52, 65],
26851  leftEyeUpper0: [466, 388, 387, 386, 385, 384, 398],
26852  leftEyeLower0: [263, 249, 390, 373, 374, 380, 381, 382, 362],
26853  leftEyeUpper1: [467, 260, 259, 257, 258, 286, 414],
26854  leftEyeLower1: [359, 255, 339, 254, 253, 252, 256, 341, 463],
26855  leftEyeUpper2: [342, 445, 444, 443, 442, 441, 413],
26856  leftEyeLower2: [446, 261, 448, 449, 450, 451, 452, 453, 464],
26857  leftEyeLower3: [372, 340, 346, 347, 348, 349, 350, 357, 465],
26858  leftEyebrowUpper: [383, 300, 293, 334, 296, 336, 285, 417],
26859  leftEyebrowLower: [265, 353, 276, 283, 282, 295],
26860  midwayBetweenEyes: [168],
26861  noseTip: [1],
26862  noseBottom: [2],
26863  noseRightCorner: [98],
26864  noseLeftCorner: [327],
26865  rightCheek: [205],
26866  leftCheek: [425]
26867};
26868
26869function disposeBox$1(e) {
26870  null != e && null != e.startPoint && (e.startEndTensor.dispose(), e.startPoint.dispose(), e.endPoint.dispose());
26871}
26872
26873function createBox$1(e, t, s) {
26874  return {
26875    startEndTensor: e,
26876    startPoint: null != t ? t : (0, _tfjsCore.slice)(e, [0, 0], [-1, 2]),
26877    endPoint: null != s ? s : (0, _tfjsCore.slice)(e, [0, 2], [-1, 2])
26878  };
26879}
26880
26881function scaleBoxCoordinates(e, t) {
26882  const s = (0, _tfjsCore.mul)(e.startPoint, t),
26883        o = (0, _tfjsCore.mul)(e.endPoint, t);
26884  return createBox$1((0, _tfjsCore.concat2d)([s, o], 1));
26885}
26886
26887function getBoxSize(e) {
26888  return (0, _tfjsCore.tidy)(() => {
26889    const t = (0, _tfjsCore.sub)(e.endPoint, e.startPoint);
26890    return (0, _tfjsCore.abs)(t);
26891  });
26892}
26893
26894function getBoxCenter(e) {
26895  return (0, _tfjsCore.tidy)(() => {
26896    const t = (0, _tfjsCore.div)((0, _tfjsCore.sub)(e.endPoint, e.startPoint), 2);
26897    return (0, _tfjsCore.add)(e.startPoint, t);
26898  });
26899}
26900
26901function cutBoxFromImageAndResize(e, t, s) {
26902  const o = t.shape[1],
26903        n = t.shape[2],
26904        i = e.startEndTensor;
26905  return (0, _tfjsCore.tidy)(() => {
26906    const e = (0, _tfjsCore.concat2d)([i.slice([0, 1], [-1, 1]), i.slice([0, 0], [-1, 1]), i.slice([0, 3], [-1, 1]), i.slice([0, 2], [-1, 1])], 0),
26907          r = (0, _tfjsCore.div)(e.transpose(), [o, n, o, n]);
26908    return _tfjsCore.image.cropAndResize(t, r, [0], s);
26909  });
26910}
26911
26912function enlargeBox(e, t = 1.5) {
26913  return (0, _tfjsCore.tidy)(() => {
26914    const s = getBoxCenter(e),
26915          o = getBoxSize(e),
26916          n = (0, _tfjsCore.mul)((0, _tfjsCore.div)(o, 2), t),
26917          i = (0, _tfjsCore.sub)(s, n),
26918          r = (0, _tfjsCore.add)(s, n);
26919    return createBox$1((0, _tfjsCore.concat2d)([i, r], 1), i, r);
26920  });
26921}
26922
26923const LANDMARKS_COUNT = 468,
26924      UPDATE_REGION_OF_INTEREST_IOU_THRESHOLD = .25;
26925
26926class Pipeline {
26927  constructor(e, t, s, o, n, i) {
26928    this.regionsOfInterest = [], this.runsWithoutFaceDetector = 0, this.boundingBoxDetector = e, this.meshDetector = t, this.meshWidth = s, this.meshHeight = o, this.maxContinuousChecks = n, this.maxFaces = i;
26929  }
26930
26931  async predict(e) {
26932    if (this.shouldUpdateRegionsOfInterest()) {
26933      const t = !0,
26934            s = !1,
26935            {
26936        boxes: o,
26937        scaleFactor: n
26938      } = await this.boundingBoxDetector.getBoundingBoxes(e, t, s);
26939      if (0 === o.length) return n.dispose(), this.clearAllRegionsOfInterest(), null;
26940      const i = o.map(e => enlargeBox(scaleBoxCoordinates(e, n)));
26941      o.forEach(disposeBox$1), this.updateRegionsOfInterest(i), this.runsWithoutFaceDetector = 0;
26942    } else this.runsWithoutFaceDetector++;
26943
26944    return (0, _tfjsCore.tidy)(() => this.regionsOfInterest.map((t, s) => {
26945      const o = cutBoxFromImageAndResize(t, e, [this.meshHeight, this.meshWidth]).div(255),
26946            [, n, i] = this.meshDetector.predict(o),
26947            r = (0, _tfjsCore.reshape)(i, [-1, 3]),
26948            a = (0, _tfjsCore.div)(getBoxSize(t), [this.meshWidth, this.meshHeight]),
26949            c = (0, _tfjsCore.mul)(r, a.concat((0, _tfjsCore.tensor2d)([1], [1, 1]), 1)).add(t.startPoint.concat((0, _tfjsCore.tensor2d)([0], [1, 1]), 1)),
26950            l = this.calculateLandmarksBoundingBox(c);
26951      return disposeBox$1(this.regionsOfInterest[s]), this.regionsOfInterest[s] = l, {
26952        coords: r,
26953        scaledCoords: c,
26954        box: l,
26955        flag: n.squeeze()
26956      };
26957    }));
26958  }
26959
26960  updateRegionsOfInterest(e) {
26961    for (let t = 0; t < e.length; t++) {
26962      const s = e[t],
26963            o = this.regionsOfInterest[t];
26964      let n = 0;
26965
26966      if (o && o.startPoint) {
26967        const [e, t, i, r] = s.startEndTensor.arraySync()[0],
26968              [a, c, l, d] = o.startEndTensor.arraySync()[0],
26969              h = Math.max(e, a),
26970              u = Math.max(t, c),
26971              p = (Math.min(i, l) - h) * (Math.min(r, d) - u);
26972        n = p / ((i - e) * (r - t) + (l - a) * (d - t) - p);
26973      }
26974
26975      n > UPDATE_REGION_OF_INTEREST_IOU_THRESHOLD ? disposeBox$1(s) : (this.regionsOfInterest[t] = s, disposeBox$1(o));
26976    }
26977
26978    for (let t = e.length; t < this.regionsOfInterest.length; t++) disposeBox$1(this.regionsOfInterest[t]);
26979
26980    this.regionsOfInterest = this.regionsOfInterest.slice(0, e.length);
26981  }
26982
26983  clearRegionOfInterest(e) {
26984    null != this.regionsOfInterest[e] && (disposeBox$1(this.regionsOfInterest[e]), this.regionsOfInterest = [...this.regionsOfInterest.slice(0, e), ...this.regionsOfInterest.slice(e + 1)]);
26985  }
26986
26987  clearAllRegionsOfInterest() {
26988    for (let e = 0; e < this.regionsOfInterest.length; e++) disposeBox$1(this.regionsOfInterest[e]);
26989
26990    this.regionsOfInterest = [];
26991  }
26992
26993  shouldUpdateRegionsOfInterest() {
26994    const e = this.regionsOfInterest.length,
26995          t = 0 === e;
26996    return 1 === this.maxFaces || t ? t : e !== this.maxFaces && this.runsWithoutFaceDetector >= this.maxContinuousChecks;
26997  }
26998
26999  calculateLandmarksBoundingBox(e) {
27000    const t = e.slice([0, 0], [LANDMARKS_COUNT, 1]),
27001          s = e.slice([0, 1], [LANDMARKS_COUNT, 1]);
27002    return enlargeBox(createBox$1((0, _tfjsCore.stack)([t.min(), s.min(), t.max(), s.max()]).expandDims(0)));
27003  }
27004
27005}
27006
27007const FACEMESH_GRAPHMODEL_PATH = "https://tfhub.dev/mediapipe/tfjs-model/facemesh/1/default/1",
27008      MESH_MODEL_INPUT_WIDTH = 192,
27009      MESH_MODEL_INPUT_HEIGHT = 192;
27010
27011async function load$1({
27012  maxContinuousChecks: e = 5,
27013  detectionConfidence: t = .9,
27014  maxFaces: s = 10,
27015  iouThreshold: o = .3,
27016  scoreThreshold: n = .75
27017} = {}) {
27018  const [i, r] = await Promise.all([loadDetectorModel(s, o, n), loadMeshModel()]);
27019  return new FaceMesh(i, r, e, t, s);
27020}
27021
27022async function loadDetectorModel(e, t, s) {
27023  return load({
27024    maxFaces: e,
27025    iouThreshold: t,
27026    scoreThreshold: s
27027  });
27028}
27029
27030async function loadMeshModel() {
27031  return (0, _tfjsConverter.loadGraphModel)(FACEMESH_GRAPHMODEL_PATH, {
27032    fromTFHub: !0
27033  });
27034}
27035
27036function getInputTensorDimensions$1(e) {
27037  return e instanceof _tfjsCore.Tensor ? [e.shape[0], e.shape[1]] : [e.height, e.width];
27038}
27039
27040function flipFaceHorizontal$1(e, t) {
27041  if (e.mesh instanceof _tfjsCore.Tensor) {
27042    const [s, o, n, i] = (0, _tfjsCore.tidy)(() => {
27043      const s = (0, _tfjsCore.tensor1d)([t - 1, 0, 0]),
27044            o = (0, _tfjsCore.tensor1d)([1, -1, 1]);
27045      return (0, _tfjsCore.tidy)(() => [(0, _tfjsCore.concat)([(0, _tfjsCore.sub)(t - 1, e.boundingBox.topLeft.slice(0, 1)), e.boundingBox.topLeft.slice(1, 1)]), (0, _tfjsCore.concat)([(0, _tfjsCore.sub)(t - 1, e.boundingBox.bottomRight.slice(0, 1)), e.boundingBox.bottomRight.slice(1, 1)]), (0, _tfjsCore.sub)(s, e.mesh).mul(o), (0, _tfjsCore.sub)(s, e.scaledMesh).mul(o)]);
27046    });
27047    return Object.assign({}, e, {
27048      boundingBox: {
27049        topLeft: s,
27050        bottomRight: o
27051      },
27052      mesh: n,
27053      scaledMesh: i
27054    });
27055  }
27056
27057  return Object.assign({}, e, {
27058    boundingBox: {
27059      topLeft: [t - 1 - e.boundingBox.topLeft[0], e.boundingBox.topLeft[1]],
27060      bottomRight: [t - 1 - e.boundingBox.bottomRight[0], e.boundingBox.bottomRight[1]]
27061    },
27062    mesh: e.mesh.map(e => {
27063      const s = e.slice(0);
27064      return s[0] = t - 1 - e[0], s;
27065    }),
27066    scaledMesh: e.scaledMesh.map(e => {
27067      const s = e.slice(0);
27068      return s[0] = t - 1 - e[0], s;
27069    })
27070  });
27071}
27072
27073class FaceMesh {
27074  constructor(e, t, s, o, n) {
27075    this.pipeline = new Pipeline(e, t, MESH_MODEL_INPUT_WIDTH, MESH_MODEL_INPUT_HEIGHT, s, n), this.detectionConfidence = o;
27076  }
27077
27078  static getAnnotations() {
27079    return MESH_ANNOTATIONS;
27080  }
27081
27082  async estimateFaces(e, t = !1, s = !1) {
27083    const [, o] = getInputTensorDimensions$1(e),
27084          n = (0, _tfjsCore.tidy)(() => (e instanceof _tfjsCore.Tensor || (e = _tfjsCore.browser.fromPixels(e)), e.toFloat().expandDims(0))),
27085          i = (0, _tfjsCore.env)().get("WEBGL_PACK_DEPTHWISECONV");
27086    (0, _tfjsCore.env)().set("WEBGL_PACK_DEPTHWISECONV", !0);
27087    const r = await this.pipeline.predict(n);
27088    return (0, _tfjsCore.env)().set("WEBGL_PACK_DEPTHWISECONV", i), n.dispose(), null != r && r.length > 0 ? Promise.all(r.map(async (e, n) => {
27089      const {
27090        coords: i,
27091        scaledCoords: r,
27092        box: a,
27093        flag: c
27094      } = e;
27095      let l = [c];
27096      t || (l = l.concat([i, r, a.startPoint, a.endPoint]));
27097      const d = await Promise.all(l.map(async e => e.array())),
27098            h = d[0];
27099
27100      if (c.dispose(), h < this.detectionConfidence && this.pipeline.clearRegionOfInterest(n), t) {
27101        const e = {
27102          faceInViewConfidence: h,
27103          mesh: i,
27104          scaledMesh: r,
27105          boundingBox: {
27106            topLeft: a.startPoint.squeeze(),
27107            bottomRight: a.endPoint.squeeze()
27108          }
27109        };
27110        return s ? flipFaceHorizontal$1(e, o) : e;
27111      }
27112
27113      const [u, p, f, m] = d.slice(1);
27114      r.dispose(), i.dispose();
27115      let g = {
27116        faceInViewConfidence: h,
27117        boundingBox: {
27118          topLeft: f,
27119          bottomRight: m
27120        },
27121        mesh: u,
27122        scaledMesh: p
27123      };
27124      s && (g = flipFaceHorizontal$1(g, o));
27125      const b = {};
27126
27127      for (const e in MESH_ANNOTATIONS) b[e] = MESH_ANNOTATIONS[e].map(e => g.scaledMesh[e]);
27128
27129      return g.annotations = b, g;
27130    })) : [];
27131  }
27132
27133}
27134
27135exports.FaceMesh = FaceMesh;
27136},{"@tensorflow/tfjs-core":"node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js","@tensorflow/tfjs-converter":"node_modules/@tensorflow/tfjs-converter/dist/tf-converter.esm.js"}],"node_modules/@tensorflow/tfjs-layers/dist/tf-layers.esm.js":[function(require,module,exports) {
27137"use strict";
27138
27139Object.defineProperty(exports, "__esModule", {
27140  value: true
27141});
27142exports.input = input;
27143exports.loadLayersModel = loadLayersModel;
27144exports.model = model;
27145exports.registerCallbackConstructor = registerCallbackConstructor;
27146exports.sequential = sequential;
27147exports.version_layers = exports.LayerVariable = exports.Sequential = exports.RNN = exports.LayersModel = exports.SymbolicTensor = exports.InputSpec = exp
27147orts.EarlyStopping = exports.callbacks = exports.Callback = exports.History = exports.CustomCallback = exports.CallbackList = exports.regularizers = exports.models = exports.metrics = exports.layers = exports.initializers = exports.constraints = void 0;
27148
27149var _tfjsCore = require("@tensorflow/tfjs-core");
27150
27151/**
27152 * @license
27153 * Copyright 2020 Google LLC. All Rights Reserved.
27154 * Licensed under the Apache License, Version 2.0 (the "License");
27155 * you may not use this file except in compliance with the License.
27156 * You may obtain a copy of the License at
27157 *
27158 * http://www.apache.org/licenses/LICENSE-2.0
27159 *
27160 * Unless required by applicable law or agreed to in writing, software
27161 * distributed under the License is distributed on an "AS IS" BASIS,
27162 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27163 * See the License for the specific language governing permissions and
27164 * limitations under the License.
27165 * =============================================================================
27166 */
27167var extendStatics = function (e, t) {
27168  return (extendStatics = Object.setPrototypeOf || {
27169    __proto__: []
27170  } instanceof Array && function (e, t) {
27171    e.__proto__ = t;
27172  } || function (e, t) {
27173    for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
27174  })(e, t);
27175};
27176
27177function __extends(e, t) {
27178  function n() {
27179    this.constructor = e;
27180  }
27181
27182  extendStatics(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, new n());
27183}
27184
27185var _epsilon,
27186    __assign = function () {
27187  return (__assign = Object.assign || function (e) {
27188    for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
27189
27190    return e;
27191  }).apply(this, arguments);
27192};
27193
27194function __awaiter(e, t, n, r) {
27195  return new (n || (n = Promise))(function (i, a) {
27196    function o(e) {
27197      try {
27198        l(r.next(e));
27199      } catch (e) {
27200        a(e);
27201      }
27202    }
27203
27204    function s(e) {
27205      try {
27206        l(r.throw(e));
27207      } catch (e) {
27208        a(e);
27209      }
27210    }
27211
27212    function l(e) {
27213      e.done ? i(e.value) : new n(function (t) {
27214        t(e.value);
27215      }).then(o, s);
27216    }
27217
27218    l((r = r.apply(e, t || [])).next());
27219  });
27220}
27221
27222function __generator(e, t) {
27223  var n,
27224      r,
27225      i,
27226      a,
27227      o = {
27228    label: 0,
27229    sent: function () {
27230      if (1 & i[0]) throw i[1];
27231      return i[1];
27232    },
27233    trys: [],
27234    ops: []
27235  };
27236  return a = {
27237    next: s(0),
27238    throw: s(1),
27239    return: s(2)
27240  }, "function" == typeof Symbol && (a[Symbol.iterator] = function () {
27241    return this;
27242  }), a;
27243
27244  function s(a) {
27245    return function (s) {
27246      return function (a) {
27247        if (n) throw new TypeError("Generator is already executing.");
27248
27249        for (; o;) try {
27250          if (n = 1, r && (i = 2 & a[0] ? r.return : a[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, a[1])).done) return i;
27251
27252          switch (r = 0, i && (a = [2 & a[0], i.value]), a[0]) {
27253            case 0:
27254            case 1:
27255              i = a;
27256              break;
27257
27258            case 4:
27259              return o.label++, {
27260                value: a[1],
27261                done: !1
27262              };
27263
27264            case 5:
27265              o.label++, r = a[1], a = [0];
27266              continue;
27267
27268            case 7:
27269              a = o.ops.pop(), o.trys.pop();
27270              continue;
27271
27272            default:
27273              if (!(i = (i = o.trys).length > 0 && i[i.length - 1]) && (6 === a[0] || 2 === a[0])) {
27274                o = 0;
27275                continue;
27276              }
27277
27278              if (3 === a[0] && (!i || a[1] > i[0] && a[1] < i[3])) {
27279                o.label = a[1];
27280                break;
27281              }
27282
27283              if (6 === a[0] && o.label < i[1]) {
27284                o.label = i[1], i = a;
27285                break;
27286              }
27287
27288              if (i && o.label < i[2]) {
27289                o.label = i[2], o.ops.push(a);
27290                break;
27291              }
27292
27293              i[2] && o.ops.pop(), o.trys.pop();
27294              continue;
27295          }
27296
27297          a = t.call(e, o);
27298        } catch (e) {
27299          a = [6, e], r = 0;
27300        } finally {
27301          n = i = 0;
27302        }
27303
27304        if (5 & a[0]) throw a[1];
27305        return {
27306          value: a[0] ? a[1] : void 0,
27307          done: !0
27308        };
27309      }([a, s]);
27310    };
27311  }
27312}
27313
27314function epsilon() {
27315  return null == _epsilon && (_epsilon = (0, _tfjsCore.backend)().epsilon()), _epsilon;
27316}
27317
27318function imageDataFormat() {
27319  return "channelsLast";
27320}
27321
27322var AttributeError = function (e) {
27323  function t(n) {
27324    var r = e.call(this, n) || this;
27325    return Object.setPrototypeOf(r, t.prototype), r;
27326  }
27327
27328  return __extends(t, e), t;
27329}(Error),
27330    RuntimeError = function (e) {
27331  function t(n) {
27332    var r = e.call(this, n) || this;
27333    return Object.setPrototypeOf(r, t.prototype), r;
27334  }
27335
27336  return __extends(t, e), t;
27337}(Error),
27338    ValueError = function (e) {
27339  function t(n) {
27340    var r = e.call(this, n) || this;
27341    return Object.setPrototypeOf(r, t.prototype), r;
27342  }
27343
27344  return __extends(t, e), t;
27345}(Error),
27346    NotImplementedError = function (e) {
27347  function t(n) {
27348    var r = e.call(this, n) || this;
27349    return Object.setPrototypeOf(r, t.prototype), r;
27350  }
27351
27352  return __extends(t, e), t;
27353}(Error),
27354    AssertionError = function (e) {
27355  function t(n) {
27356    var r = e.call(this, n) || this;
27357    return Object.setPrototypeOf(r, t.prototype), r;
27358  }
27359
27360  return __extends(t, e), t;
27361}(Error),
27362    IndexError = function (e) {
27363  function t(n) {
27364    var r = e.call(this, n) || this;
27365    return Object.setPrototypeOf(r, t.prototype), r;
27366  }
27367
27368  return __extends(t, e), t;
27369}(Error);
27370
27371function pyListRepeat(e, t) {
27372  if (Array.isArray(e)) {
27373    for (var n = [], r = 0; r < t; r++) n = n.concat(e);
27374
27375    return n;
27376  }
27377
27378  return (n = new Array(t)).fill(e), n;
27379}
27380
27381function assert(e, t) {
27382  if (!e) throw new AssertionError(t);
27383}
27384
27385function count(e, t) {
27386  for (var n = 0, r = 0, i = e; r < i.length; r++) {
27387    i[r] === t && n++;
27388  }
27389
27390  return n;
27391}
27392
27393function singletonOrArray(e) {
27394  return 1 === e.length ? e[0] : e;
27395}
27396
27397function toList(e) {
27398  return Array.isArray(e) ? e : [e];
27399}
27400
27401function toSnakeCase(e) {
27402  var t = e.replace(/(.)([A-Z][a-z0-9]+)/g, "$1_$2").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
27403  return "_" !== t[0] ? t : "private" + t;
27404}
27405
27406function toCamelCase(e) {
27407  return e.length <= 1 ? e : -1 === e.indexOf("_") ? e : e.replace(/[_]+(\w|$)/g, function (e, t) {
27408    return t.toUpperCase();
27409  });
27410}
27411
27412var _GLOBAL_CUSTOM_OBJECTS = {};
27413
27414function serializeKerasObject(e) {
27415  if (null === e || void 0 === e) return null;
27416  var t = {};
27417  return t.className = e.getClassName(), t.config = e.getConfig(), t;
27418}
27419
27420function convertNDArrayScalarsInConfig(e) {
27421  if (null != e && "object" == typeof e) if (Array.isArray(e)) e.forEach(function (e) {
27422    return convertNDArrayScalarsInConfig(e);
27423  });else for (var t = 0, n = Object.keys(e); t < n.length; t++) {
27424    var r = n[t],
27425        i = e[r];
27426    null != i && "object" == typeof i && (Array.isArray(i) || "ndarray" !== i.type || "number" != typeof i.value ? convertNDArrayScalarsInConfig(i) : e[r] = i.value);
27427  }
27428}
27429
27430function deserializeKerasObject(e, t, n, r, i) {
27431  var a, o, s;
27432
27433  if (void 0 === t && (t = {}), void 0 === n && (n = {}), void 0 === r && (r = "object"), void 0 === i && (i = !1), "string" == typeof e) {
27434    var l = e,
27435        u = void 0;
27436    if (l in n) u = n[l];else if (l in _GLOBAL_CUSTOM_OBJECTS) u = _GLOBAL_CUSTOM_OBJECTS[l];else if (null == (u = t[l])) throw new ValueError("Unknown " + r + ": " + e + ". This may be due to one of the following reasons:\n1. The " + r + " is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom " + r + " is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().");
27437    return u;
27438  }
27439
27440  var c = e;
27441  if (null == c.className || null == c.config) throw new ValueError(r + ": Improper config format: " + JSON.stringify(c) + ".\n'className' and 'config' must set.");
27442  var p = c.className,
27443      h = void 0,
27444      d = void 0;
27445  if (p in n ? (h = (a = n[p])[0], d = a[1]) : p in _GLOBAL_CUSTOM_OBJECTS ? (h = (o = _GLOBAL_CUSTOM_OBJECTS.className)[0], d = o[1]) : p in t && (h = (s = t[p])[0], d = s[1]), null == h) throw new ValueError("Unknown " + r + ": " + p + ". This may be due to one of the following reasons:\n1. The " + r + " is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom " + r + " is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().");
27446
27447  if (null != d) {
27448    for (var f = {}, g = 0, m = Object.keys(_GLOBAL_CUSTOM_OBJECTS); g < m.length; g++) {
27449      f[S = m[g]] = _GLOBAL_CUSTOM_OBJECTS[S];
27450    }
27451
27452    for (var y = 0, v = Object.keys(n); y < v.length; y++) {
27453      f[S = v[y]] = n[S];
27454    }
27455
27456    c.config.customObjects = f;
27457
27458    for (var b = __assign({}, _GLOBAL_CUSTOM_OBJECTS), w = 0, z = Object.keys(n); w < z.length; w++) {
27459      var S = z[w];
27460      _GLOBAL_CUSTOM_OBJECTS[S] = n[S];
27461    }
27462
27463    convertNDArrayScalarsInConfig(c.config);
27464    var A = d(h, c.config, n, i);
27465    return _GLOBAL_CUSTOM_OBJECTS = __assign({}, b), A;
27466  }
27467
27468  b = __assign({}, _GLOBAL_CUSTOM_OBJECTS);
27469
27470  for (var _ = 0, I = Object.keys(n); _ < I.length; _++) {
27471    S = I[_];
27472    _GLOBAL_CUSTOM_OBJECTS[S] = n[S];
27473  }
27474
27475  A = new h(c.config);
27476  return _GLOBAL_CUSTOM_OBJECTS = __assign({}, b), A;
27477}
27478
27479function numberCompare(e, t) {
27480  return e < t ? -1 : e > t ? 1 : 0;
27481}
27482
27483function reverseNumberCompare(e, t) {
27484  return -1 * numberCompare(e, t);
27485}
27486
27487function unique(e) {
27488  if (null == e) return e;
27489
27490  for (var t = [], n = 0, r = e; n < r.length; n++) {
27491    var i = r[n];
27492    -1 === t.indexOf(i) && t.push(i);
27493  }
27494
27495  return t;
27496}
27497
27498function isObjectEmpty(e) {
27499  if (null == e) throw new ValueError("Invalid value in obj: " + JSON.stringify(e));
27500
27501  for (var t in e) if (e.hasOwnProperty(t)) return !1;
27502
27503  return !0;
27504}
27505
27506function checkStringTypeUnionValue(e, t, n) {
27507  if (null != n && e.indexOf(n) < 0) throw new ValueError(n + " is not a valid " + t + ".  Valid values are " + e + " or null/undefined.");
27508}
27509
27510function checkArrayTypeAndLength(e, t, n, r) {
27511  return void 0 === n && (n = 0), void 0 === r && (r = 1 / 0), assert(n >= 0), assert(r >= n), Array.isArray(e) && e.length >= n && e.length <= r && e.every(function (e) {
27512    return typeof e === t;
27513  });
27514}
27515
27516function assertPositiveInteger(e, t) {
27517  Array.isArray(e) ? (_tfjsCore.util.assert(e.length > 0, function () {
27518    return t + " is unexpectedly an empty array.";
27519  }), e.forEach(function (e, n) {
27520    return assertPositiveInteger(e, "element " + (n + 1) + " of " + t);
27521  })) : _tfjsCore.util.assert(Number.isInteger(e) && e > 0, function () {
27522    return "Expected " + t + " to be a positive integer, but got " + formatAsFriendlyString(e) + ".";
27523  });
27524}
27525
27526function formatAsFriendlyString(e) {
27527  return null === e ? "null" : Array.isArray(e) ? "[" + e.map(function (e) {
27528    return formatAsFriendlyString(e);
27529  }).join(",") + "]" : "string" == typeof e ? '"' + e + '"' : "" + e;
27530}
27531
27532function debounce(e, t) {
27533  var n,
27534      r = _tfjsCore.util.now();
27535
27536  return function () {
27537    for (var i = [], a = 0; a < arguments.length; a++) i[a] = arguments[a];
27538
27539    var o = _tfjsCore.util.now();
27540
27541    return o - r < t ? n : (r = o, n = e.apply(void 0, i));
27542  };
27543}
27544
27545function mapActivationToFusedKernel(e) {
27546  return "relu" === e ? "relu" : "linear" === e ? "linear" : "elu" === e ? "elu" : null;
27547}
27548
27549function calcL2Norms(e, t) {
27550  return (0, _tfjsCore.tidy)(function () {
27551    return (0, _tfjsCore.sqrt)((0, _tfjsCore.sum)((0, _tfjsCore.mulStrict)(e, e), t, !0));
27552  });
27553}
27554
27555var Constraint = function (e) {
27556  function t() {
27557    return null !== e && e.apply(this, arguments) || this;
27558  }
27559
27560  return __extends(t, e), t.prototype.getConfig = function () {
27561    return {};
27562  }, t;
27563}(_tfjsCore.serialization.Serializable),
27564    MaxNorm = function (e) {
27565  function t(t) {
27566    var n = e.call(this) || this;
27567    return n.defaultMaxValue = 2, n.defaultAxis = 0, n.maxValue = null != t.maxValue ? t.maxValue : n.defaultMaxValue, n.axis = null != t.axis ? t.axis : n.defaultAxis, n;
27568  }
27569
27570  return __extends(t, e), t.prototype.apply = function (e) {
27571    var t = this;
27572    return (0, _tfjsCore.tidy)(function () {
27573      var n = calcL2Norms(e, t.axis),
27574          r = (0, _tfjsCore.clipByValue)(n, 0, t.maxValue);
27575      return (0, _tfjsCore.mul)(e, (0, _tfjsCore.div)(r, (0, _tfjsCore.add)(epsilon(), n)));
27576    });
27577  }, t.prototype.getConfig = function () {
27578    return {
27579      maxValue: this.maxValue,
27580      axis: this.axis
27581    };
27582  }, t.className = "MaxNorm", t;
27583}(Constraint);
27584
27585_tfjsCore.serialization.registerClass(MaxNorm);
27586
27587var UnitNorm = function (e) {
27588  function t(t) {
27589    var n = e.call(this) || this;
27590    return n.defaultAxis = 0, n.axis = null != t.axis ? t.axis : n.defaultAxis, n;
27591  }
27592
27593  return __extends(t, e), t.prototype.apply = function (e) {
27594    var t = this;
27595    return (0, _tfjsCore.tidy)(function () {
27596      return (0, _tfjsCore.div)(e, (0, _tfjsCore.add)(epsilon(), calcL2Norms(e, t.axis)));
27597    });
27598  }, t.prototype.getConfig = function () {
27599    return {
27600      axis: this.axis
27601    };
27602  }, t.className = "UnitNorm", t;
27603}(Constraint);
27604
27605_tfjsCore.serialization.registerClass(UnitNorm);
27606
27607var NonNeg = function (e) {
27608  function t() {
27609    return null !== e && e.apply(this, arguments) || this;
27610  }
27611
27612  return __extends(t, e), t.prototype.apply = function (e) {
27613    return (0, _tfjsCore.relu)(e);
27614  }, t.className = "NonNeg", t;
27615}(Constraint);
27616
27617_tfjsCore.serialization.registerClass(NonNeg);
27618
27619var MinMaxNorm = function (e) {
27620  function t(t) {
27621    var n = e.call(this) || this;
27622    return n.defaultMinValue = 0, n.defaultMaxValue = 1, n.defaultRate = 1, n.defaultAxis = 0, n.minValue = null != t.minValue ? t.minValue : n.defaultMinValue, n.maxValue = null != t.maxValue ? t.maxValue : n.defaultMaxValue, n.rate = null != t.rate ? t.rate : n.defaultRate, n.axis = null != t.axis ? t.axis : n.defaultAxis, n;
27623  }
27624
27625  return __extends(t, e), t.prototype.apply = function (e) {
27626    var t = this;
27627    return (0, _tfjsCore.tidy)(function () {
27628      var n = calcL2Norms(e, t.axis),
27629          r = (0, _tfjsCore.add)((0, _tfjsCore.mul)(t.rate, (0, _tfjsCore.clipByValue)(n, t.minValue, t.maxValue)), (0, _tfjsCore.mul)(1 - t.rate, n));
27630      return (0, _tfjsCore.mul)(e, (0, _tfjsCore.div)(r, (0, _tfjsCore.add)(epsilon(), n)));
27631    });
27632  }, t.prototype.getConfig = function () {
27633    return {
27634      minValue: this.minValue,
27635      maxValue: this.maxValue,
27636      rate: this.rate,
27637      axis: this.axis
27638    };
27639  }, t.className = "MinMaxNorm", t;
27640}(Constraint);
27641
27642_tfjsCore.serialization.registerClass(MinMaxNorm);
27643
27644var CONSTRAINT_IDENTIFIER_REGISTRY_SYMBOL_MAP = {
27645  maxNorm: "MaxNorm",
27646  minMaxNorm: "MinMaxNorm",
27647  nonNeg: "NonNeg",
27648  unitNorm: "UnitNorm"
27649};
27650
27651function serializeConstraint(e) {
27652  return serializeKerasObject(e);
27653}
27654
27655function deserializeConstraint(e, t) {
27656  return void 0 === t && (t = {}), deserializeKerasObject(e, _tfjsCore.serialization.SerializationMap.getMap().classNameMap, t, "constraint");
27657}
27658
27659function getConstraint(e) {
27660  return null == e ? null : "string" == typeof e ? deserializeConstraint({
27661    className: e in CONSTRAINT_IDENTIFIER_REGISTRY_SYMBOL_MAP ? CONSTRAINT_IDENTIFIER_REGISTRY_SYMBOL_MAP[e] : e,
27662    config: {}
27663  }) : e instanceof Constraint ? e : deserializeConstraint(e);
27664}
27665
27666function maxNorm(e) {
27667  return new MaxNorm(e);
27668}
27669
27670function unitNorm(e) {
27671  return new UnitNorm(e);
27672}
27673
27674function nonNeg() {
27675  return new NonNeg();
27676}
27677
27678function minMaxNorm(e) {
27679  return new MinMaxNorm(e);
27680}
27681
27682var exports_constraints = Object.freeze({
27683  maxNorm: maxNorm,
27684  unitNorm: unitNorm,
27685  nonNeg: nonNeg,
27686  minMaxNorm: minMaxNorm
27687}),
27688    VALID_DATA_FORMAT_VALUES = ["channelsFirst", "channelsLast"],
27689    VALID_PADDING_MODE_VALUES = ["valid", "same", "causal"],
27690    VALID_POOL_MODE_VALUES = ["max", "avg"],
27691    VALID_BIDIRECTIONAL_MERGE_MODES = ["sum", "mul", "concat", "ave"],
27692    nameMap = new Map();
27693exports.constraints = exports_constraints;
27694
27695function checkDataFormat(e) {
27696  checkStringTypeUnionValue(VALID_DATA_FORMAT_VALUES, "DataFormat", e);
27697}
27698
27699function checkPaddingMode(e) {
27700  checkStringTypeUnionValue(VALID_PADDING_MODE_VALUES, "PaddingMode", e);
27701}
27702
27703function checkPoolMode(e) {
27704  checkStringTypeUnionValue(VALID_POOL_MODE_VALUES, "PoolMode", e);
27705}
27706
27707var _nameScopeStack = [],
27708    _nameScopeDivider = "/";
27709
27710function nameScope(e, t) {
27711  _nameScopeStack.push(e);
27712
27713  try {
27714    var n = t();
27715    return _nameScopeStack.pop(), n;
27716  } catch (e) {
27717    throw _nameScopeStack.pop(), e;
27718  }
27719}
27720
27721function currentNameScopePrefix() {
27722  return 0 === _nameScopeStack.length ? "" : _nameScopeStack.join(_nameScopeDivider) + _nameScopeDivider;
27723}
27724
27725function getScopedTensorName(e) {
27726  if (!isValidTensorName(e)) throw new Error("Not a valid tensor name: '" + e + "'");
27727  return currentNameScopePrefix() + e;
27728}
27729
27730function getUniqueTensorName(e) {
27731  if (!isValidTensorName(e)) throw new Error("Not a valid tensor name: '" + e + "'");
27732  nameMap.has(e) || nameMap.set(e, 0);
27733  var t = nameMap.get(e);
27734
27735  if (nameMap.set(e, nameMap.get(e) + 1), t > 0) {
27736    var n = e + "_" + t;
27737    return nameMap.set(n, 1), n;
27738  }
27739
27740  return e;
27741}
27742
27743var tensorNameRegex = new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);
27744
27745function isValidTensorName(e) {
27746  return !!e.match(tensorNameRegex);
27747}
27748
27749function isInteger(e) {
27750  return e === parseInt(e.toString(), 10);
27751}
27752
27753function arrayProd(e, t, n) {
27754  null == t && (t = 0), null == n && (n = e.length);
27755
27756  for (var r = 1, i = t; i < n; ++i) r *= e[i];
27757
27758  return r;
27759}
27760
27761function toArray1D(e) {
27762  return e = Array.isArray(e) ? new Float32Array(e) : e, (0, _tfjsCore.tensor1d)(e);
27763}
27764
27765function min$1(e) {
27766  return (0, _tfjsCore.min)(toArray1D(e)).dataSync()[0];
27767}
27768
27769function max$1(e) {
27770  return (0, _tfjsCore.max)(toArray1D(e)).dataSync()[0];
27771}
27772
27773function range(e, t) {
27774  if (t < e) throw new ValueError("end (" + t + ") < begin (" + e + ") is forbidden.");
27775
27776  for (var n = [], r = e; r < t; ++r) n.push(r);
27777
27778  return n;
27779}
27780
27781function cast$1(e, t) {
27782  return e.asType(t);
27783}
27784
27785function expandDims$1(e, t) {
27786  void 0 === t && (t = -1);
27787  var n = e.shape.slice();
27788  return t < 0 && (t = n.length + t + 1), n.splice(t, 0, 1), e.reshape(n);
27789}
27790
27791function repeat(e, t) {
27792  return (0, _tfjsCore.tidy)(function () {
27793    if (2 !== e.shape.length) throw new ValueError("repeat() expects a rank-2 tensor, but received a rank-" + e.shape.length + " tensor.");
27794    return tile$1(expandDims$1(e, 1), [1, t, 1]);
27795  });
27796}
27797
27798function flatten(e) {
27799  var t = [arrayProd(e.shape)];
27800  return e.reshape(t);
27801}
27802
27803function batchFlatten(e) {
27804  if (e.rank <= 1) throw new ValueError("batchFlatten requires a minimum rank of 2. Got rank: " + e.rank + ".");
27805  var t = [e.shape[0], arrayProd(e.shape, 1)];
27806  return e.reshape(t);
27807}
27808
27809function sliceAlongFirstAxis(e, t, n) {
27810  return (0, _tfjsCore.tidy)(function () {
27811    switch (e.rank) {
27812      case 1:
27813        return (0, _tfjsCore.slice1d)(e, t, n);
27814
27815      case 2:
27816        return (0, _tfjsCore.slice2d)(e, [t, 0], [n, e.shape[1]]);
27817
27818      case 3:
27819        return (0, _tfjsCore.slice3d)(e, [t, 0, 0], [n, e.shape[1], e.shape[2]]);
27820
27821      case 4:
27822        return (0, _tfjsCore.slice4d)(e, [t, 0, 0, 0], [n, e.shape[1], e.shape[2], e.shape[3]]);
27823
27824      case 5:
27825        return (0, _tfjsCore.slice)(e, [t, 0, 0, 0, 0], [n, e.shape[1], e.shape[2], e.shape[3], e.shape[4]]);
27826
27827      case 6:
27828        return (0, _tfjsCore.slice)(e, [t, 0, 0, 0, 0, 0], [n, e.shape[1], e.shape[2], e.shape[3], e.shape[4], e.shape[5]]);
27829
27830      default:
27831        throw new ValueError("sliceAlongFirstAxis() received an unsupported tensor rank: " + e.rank);
27832    }
27833  });
27834}
27835
27836function sliceAlongLastAxis(e, t, n) {
27837  return (0, _tfjsCore.tidy)(function () {
27838    switch (e.rank) {
27839      case 1:
27840        return (0, _tfjsCore.slice1d)(e, t, n);
27841
27842      case 2:
27843        return (0, _tfjsCore.slice2d)(e, [0, t], [e.shape[0], n]);
27844
27845      case 3:
27846        return (0, _tfjsCore.slice3d)(e, [0, 0, t], [e.shape[0], e.shape[1], n]);
27847
27848      case 4:
27849        return (0, _tfjsCore.slice4d)(e, [0, 0, 0, t], [e.shape[0], e.shape[1], e.shape[2], n]);
27850
27851      default:
27852        throw new ValueError("sliceAlongLastAxis() received an unsupported tensor rank: " + e.rank);
27853    }
27854  });
27855}
27856
27857function sliceAlongAxis(e, t, n, r) {
27858  return (0, _tfjsCore.tidy)(function () {
27859    switch (e.rank) {
27860      case 1:
27861        return (0, _tfjsCore.slice1d)(e, t, n);
27862
27863      case 2:
27864        switch (r) {
27865          case 1:
27866            return sliceAlongFirstAxis(e, t, n);
27867
27868          case 2:
27869            return sliceAlongLastAxis(e, t, n);
27870
27871          default:
27872            throw new ValueError("The axis is not within the rank of the tensor " + r);
27873        }
27874
27875      case 3:
27876        switch (r) {
27877          case 1:
27878            return sliceAlongFirstAxis(e, t, n);
27879
27880          case 2:
27881            return (0, _tfjsCore.slice3d)(e, [0, t, 0], [e.shape[0], n, e.shape[2]]);
27882
27883          case 3:
27884            return sliceAlongLastAxis(e, t, n);
27885
27886          default:
27887            throw new ValueError("The axis is not within the rank of the tensor " + r);
27888        }
27889
27890      case 4:
27891        switch (r) {
27892          case 1:
27893            return sliceAlongFirstAxis(e, t, n);
27894
27895          case 2:
27896            return (0, _tfjsCore.slice4d)(e, [0, t, 0, 0], [e.shape[0], n, e.shape[2], e.shape[3]]);
27897
27898          case 3:
27899            return (0, _tfjsCore.slice4d)(e, [0, 0, t, 0], [e.shape[0], e.shape[1], n, e.shape[3]]);
27900
27901          case 4:
27902            return sliceAlongLastAxis(e, t, n);
27903
27904          default:
27905            throw new ValueError("The axis is not within the rank of the tensor " + r);
27906        }
27907
27908      default:
27909        throw new ValueError("sliceAlongLastAxis() received an unsupported tensor rank: " + e.rank);
27910    }
27911  });
27912}
27913
27914function concatenate(e, t) {
27915  var n;
27916  return void 0 === t && (t = -1), t < 0 && (t = 0 !== (n = e[0].rank) ? n : 0), t === e[0].rank && (t = -1), (0, _tfjsCore.concat)(e, t);
27917}
27918
27919function concatAlongFirstAxis(e, t) {
27920  switch (e.rank) {
27921    case 1:
27922      return (0, _tfjsCore.concat1d)([e, t]);
27923
27924    case 2:
27925      return (0, _tfjsCore.concat2d)([e, t], 0);
27926
27927    case 3:
27928      return (0, _tfjsCore.concat3d)([e, t], 0);
27929
27930    case 4:
27931      return (0, _tfjsCore.concat4d)([e, t], 0);
27932
27933    default:
27934      throw new ValueError("concatAlongFirstAxis() received an unsupported tensor rank: " + e.rank);
27935  }
27936}
27937
27938function tile$1(e, t) {
27939  if (Array.isArray(t) || (t = [t]), e.rank !== t.length) throw new ValueError("The length of input n (" + t.length + ") does not match the number of dimensions in input x (" + e.rank + ")");
27940  return (0, _tfjsCore.tile)(e, t);
27941}
27942
27943function randomNormal$1(e, t, n, r, i) {
27944  return void 0 === t && (t = 0), void 0 === n && (n = 1), (0, _tfjsCore.randomNormal)(e, t, n, r, i);
27945}
27946
27947function dot(e, t, n, r) {
27948  if (e.rank < 2 || t.rank < 2) throw new NotImplementedError("dot requires both inputs to be rank >= 2 but got x shape = " + e.shape + " and y shape = " + t.shape);
27949  if (t.rank >= 3 && e.shape.slice(-1)[0] !== (c = t.shape.slice(-2)[0])) throw new NotImplementedError("If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = " + e.shape + " and  y shape = " + t.shape);
27950
27951  if (2 === e.rank && 2 === t.rank) {
27952    var i = !1,
27953        a = !1;
27954    return _tfjsCore.fused.matMul({
27955      a: e,
27956      b: t,
27957      transposeA: i,
27958      transposeB: a,
27959      bias: r ? reshapeBias(e.rank, r, imageDataFormat()) : null,
27960      activation: n
27961    });
27962  }
27963
27964  var o = e.shape.slice(),
27965      s = o.pop();
27966  e = e.reshape([-1, s]);
27967  var l = t.shape.slice(),
27968      u = l.pop(),
27969      c = l.pop(),
27970      p = l.concat([u]),
27971      h = Array.from({
27972    length: t.rank
27973  }, function (e, n) {
27974    return 0 === n ? t.rank - 2 : n <= t.rank - 2 ? n - 1 : n;
27975  });
27976  t = t.transpose(h).reshape([c, -1]);
27977  var d = o.concat(p);
27978  i = !1, a = !1;
27979  return _tfjsCore.fused.matMul({
27980    a: e,
27981    b: t,
27982    transposeA: i,
27983    transposeB: a,
27984    bias: r ? reshapeBias(e.rank, r, imageDataFormat()) : null,
27985    activation: n
27986  }).reshape(d);
27987}
27988
27989function gather$1(e, t, n) {
27990  return (0, _tfjsCore.tidy)(function () {
27991    return t = Array.isArray(t) ? (0, _tfjsCore.tensor1d)(t, "int32") : t.toInt(), (0, _tfjsCore.gather)(e, t, n);
27992  });
27993}
27994
27995function square(e) {
27996  return (0, _tfjsCore.mulStrict)(e, e);
27997}
27998
27999function reshapeBias(e, t, n) {
28000  var r = t.shape;
28001  if (1 !== t.rank && t.rank !== e) throw new ValueError("Unexpected bias dimensions: " + t.rank + "; expected it to be 1 or " + e);
28002
28003  if (5 === e) {
28004    if ("channelsFirst" === n) return 1 === r.length ? t.reshape([1, r[0], 1, 1, 1]) : t.reshape([1, r[3], r[0], r[1], r[2]]);
28005    if ("channelsLast" === n) return 1 === r.length ? t.reshape([1, 1, 1, 1, r[0]]) : t.reshape([1].concat(r));
28006  } else if (4 === e) {
28007    if ("channelsFirst" === n) return 1 === r.length ? t.reshape([1, r[0], 1, 1]) : t.reshape([1, r[2], r[0], r[1]]);
28008    if ("channelsLast" === n) return 1 === r.length ? t.reshape([1, 1, 1, r[0]]) : t.reshape([1].concat(r));
28009  } else if (3 === e) {
28010    if ("channelsFirst" === n) return 1 === r.length ? t.reshape([1, r[0], 1]) : t.reshape([1, r[1], r[0]]);
28011    if ("channelsLast" === n) return 1 === r.length ? t.reshape([1, 1, r[0]]) : t.reshape([1].concat(r));
28012  } else if (e < 3) return t;
28013
28014  throw new ValueError("Unsupported input rank by biasAdd: " + t.rank);
28015}
28016
28017function biasAdd(e, t, n) {
28018  return (0, _tfjsCore.tidy)(function () {
28019    return null == n && (n = imageDataFormat()), checkDataFormat(n), e.add(reshapeBias(e.rank, t, n));
28020  });
28021}
28022
28023function elu$1(e, t) {
28024  if (void 0 === t && (t = 1), 1 !== t) throw new NotImplementedError("Support for alpha values other than 1 (" + t + ") is not implemented yet.");
28025  return (0, _tfjsCore.elu)(e);
28026}
28027
28028function softsign(e) {
28029  return (0, _tfjsCore.tidy)(function () {
28030    return (0, _tfjsCore.div)(e, (0, _tfjsCore.abs)(e).add(1));
28031  });
28032}
28033
28034function dropout$1(e, t, n, r) {
28035  return (0, _tfjsCore.tidy)(function () {
28036    return (0, _tfjsCore.dropout)(e, t, n, r);
28037  });
28038}
28039
28040function hardSigmoid(e) {
28041  return (0, _tfjsCore.tidy)(function () {
28042    var t = (0, _tfjsCore.add)(.5, (0, _tfjsCore.mul)(.2, e));
28043    return (0, _tfjsCore.clipByValue)(t, 0, 1);
28044  });
28045}
28046
28047function inTrainPhase(e, t, n) {
28048  return void 0 === n && (n = !1), n ? e() : t();
28049}
28050
28051var VALID_FAN_MODE_VALUES = ["fanIn", "fanOut", "fanAvg"],
28052    VALID_DISTRIBUTION_VALUES = ["normal", "uniform", "truncatedNormal"];
28053
28054function checkFanMode(e) {
28055  checkStringTypeUnionValue(VALID_FAN_MODE_VALUES, "FanMode", e);
28056}
28057
28058function checkDistribution(e) {
28059  checkStringTypeUnionValue(VALID_DISTRIBUTION_VALUES, "Distribution", e);
28060}
28061
28062var Initializer = function (e) {
28063  function t() {
28064    return null !== e && e.apply(this, arguments) || this;
28065  }
28066
28067  return __extends(t, e), t.prototype.fromConfigUsesCustomObjects = function () {
28068    return !1;
28069  }, t.prototype.getConfig = function () {
28070    return {};
28071  }, t;
28072}(_tfjsCore.serialization.Serializable),
28073    Zeros = function (e) {
28074  function t() {
28075    return null !== e && e.apply(this, arguments) || this;
28076  }
28077
28078  return __extends(t, e), t.prototype.apply = function (e, t) {
28079    return (0, _tfjsCore.zeros)(e, t);
28080  }, t.className = "Zeros", t;
28081}(Initializer);
28082
28083_tfjsCore.serialization.registerClass(Zeros);
28084
28085var Ones = function (e) {
28086  function t() {
28087    return null !== e && e.apply(this, arguments) || this;
28088  }
28089
28090  return __extends(t, e), t.prototype.apply = function (e, t) {
28091    return (0, _tfjsCore.ones)(e, t);
28092  }, t.className = "Ones", t;
28093}(Initializer);
28094
28095_tfjsCore.serialization.registerClass(Ones);
28096
28097var Constant = function (e) {
28098  function t(t) {
28099    var n = e.call(this) || this;
28100    if ("object" != typeof t) throw new ValueError("Expected argument of type ConstantConfig but got " + t);
28101    if (void 0 === t.value) throw new ValueError("config must have value set but got " + t);
28102    return n.value = t.value, n;
28103  }
28104
28105  return __extends(t, e), t.prototype.apply = function (e, t) {
28106    var n = this;
28107    return (0, _tfjsCore.tidy)(function () {
28108      return (0, _tfjsCore.mul)((0, _tfjsCore.scalar)(n.value), (0, _tfjsCore.ones)(e, t));
28109    });
28110  }, t.prototype.getConfig = function () {
28111    return {
28112      value: this.value
28113    };
28114  }, t.className = "Constant", t;
28115}(Initializer);
28116
28117_tfjsCore.serialization.registerClass(Constant);
28118
28119var RandomUniform = function (e) {
28120  function t(t) {
28121    var n = e.call(this) || this;
28122    return n.DEFAULT_MINVAL = -.05, n.DEFAULT_MAXVAL = .05, n.minval = t.minval || n.DEFAULT_MINVAL, n.maxval = t.maxval || n.DEFAULT_MAXVAL, n.seed = t.seed, n;
28123  }
28124
28125  return __extends(t, e), t.prototype.apply = function (e, t) {
28126    return (0, _tfjsCore.randomUniform)(e, this.minval, this.maxval, t);
28127  }, t.prototype.getConfig = function () {
28128    return {
28129      minval: this.minval,
28130      maxval: this.maxval,
28131      seed: this.seed
28132    };
28133  }, t.className = "RandomUniform", t;
28134}(Initializer);
28135
28136_tfjsCore.serialization.registerClass(RandomUniform);
28137
28138var RandomNormal = function (e) {
28139  function t(t) {
28140    var n = e.call(this) || this;
28141    return n.DEFAULT_MEAN = 0, n.DEFAULT_STDDEV = .05, n.mean = t.mean || n.DEFAULT_MEAN, n.stddev = t.stddev || n.DEFAULT_STDDEV, n.seed = t.seed, n;
28142  }
28143
28144  return __extends(t, e), t.prototype.apply = function (e, t) {
28145    if ("float32" !== (t = t || "float32") && "int32" !== t) throw new NotImplementedError("randomNormal does not support dType " + t + ".");
28146    return randomNormal$1(e, this.mean, this.stddev, t, this.seed);
28147  }, t.prototype.getConfig = function () {
28148    return {
28149      mean: this.mean,
28150      stddev: this.stddev,
28151      seed: this.seed
28152    };
28153  }, t.className = "RandomNormal", t;
28154}(Initializer);
28155
28156_tfjsCore.serialization.registerClass(RandomNormal);
28157
28158var TruncatedNormal = function (e) {
28159  function t(t) {
28160    var n = e.call(this) || this;
28161    return n.DEFAULT_MEAN = 0, n.DEFAULT_STDDEV = .05, n.mean = t.mean || n.DEFAULT_MEAN, n.stddev = t.stddev || n.DEFAULT_STDDEV, n.seed = t.seed, n;
28162  }
28163
28164  return __extends(t, e), t.prototype.apply = function (e, t) {
28165    if ("float32" !== (t = t || "float32") && "int32" !== t) throw new NotImplementedError("truncatedNormal does not support dType " + t + ".");
28166    return (0, _tfjsCore.truncatedNormal)(e, this.mean, this.stddev, t, this.seed);
28167  }, t.prototype.getConfig = function () {
28168    return {
28169      mean: this.mean,
28170      stddev: this.stddev,
28171      seed: this.seed
28172    };
28173  }, t.className = "TruncatedNormal", t;
28174}(Initializer);
28175
28176_tfjsCore.serialization.registerClass(TruncatedNormal);
28177
28178var Identity = function (e) {
28179  function t(t) {
28180    var n = e.call(this) || this;
28181    return n.gain = null != t.gain ? t.gain : 1, n;
28182  }
28183
28184  return __extends(t, e), t.prototype.apply = function (e, t) {
28185    var n = this;
28186    return (0, _tfjsCore.tidy)(function () {
28187      if (2 !== e.length || e[0] !== e[1]) throw new ValueError("Identity matrix initializer can only be used for 2D square matrices.");
28188      return (0, _tfjsCore.mul)(n.gain, (0, _tfjsCore.eye)(e[0]));
28189    });
28190  }, t.prototype.getConfig = function () {
28191    return {
28192      gain: this.gain
28193    };
28194  }, t.className = "Identity", t;
28195}(Initializer);
28196
28197function computeFans(e, t) {
28198  var n, r;
28199  if (void 0 === t && (t = "channelsLast"), checkDataFormat(t), 2 === e.length) n = e[0], r = e[1];else if (-1 !== [3, 4, 5].indexOf(e.length)) {
28200    if ("channelsFirst" === t) {
28201      var i = arrayProd(e, 2);
28202      n = e[1] * i, r = e[0] * i;
28203    } else if ("channelsLast" === t) {
28204      i = arrayProd(e, 0, e.length - 2);
28205      n = e[e.length - 2] * i, r = e[e.length - 1] * i;
28206    }
28207  } else {
28208    var a = arrayProd(e);
28209    n = Math.sqrt(a), r = Math.sqrt(a);
28210  }
28211  return [n, r];
28212}
28213
28214_tfjsCore.serialization.registerClass(Identity);
28215
28216var VarianceScaling = function (e) {
28217  function t(t) {
28218    var n = e.call(this) || this;
28219    if (t.scale < 0) throw new ValueError("scale must be a positive float. Got: " + t.scale);
28220    return n.scale = null == t.scale ? 1 : t.scale, n.mode = null == t.mode ? "fanIn" : t.mode, checkFanMode(n.mode), n.distribution = null == t.distribution ? "normal" : t.distribution, checkDistribution(n.distribution), n.seed = t.seed, n;
28221  }
28222
28223  return __extends(t, e), t.prototype.apply = function (e, t) {
28224    var n = computeFans(e),
28225        r = n[0],
28226        i = n[1],
28227        a = this.scale;
28228
28229    if ("fanIn" === this.mode ? a /= Math.max(1, r) : "fanOut" === this.mode ? a /= Math.max(1, i) : a /= Math.max(1, (r + i) / 2), "normal" === this.distribution) {
28230      var o = Math.sqrt(a);
28231      if ("float32" !== (t = t || "float32") && "int32" !== t) throw new NotImplementedError(this.getClassName() + " does not support dType " + t + ".");
28232      return (0, _tfjsCore.truncatedNormal)(e, 0, o, t, this.seed);
28233    }
28234
28235    var s = Math.sqrt(3 * a);
28236    return (0, _tfjsCore.randomUniform)(e, -s, s, t);
28237  }, t.prototype.getConfig = function () {
28238    return {
28239      scale: this.scale,
28240      mode: this.mode,
28241      distribution: this.distribution,
28242      seed: this.seed
28243    };
28244  }, t.className = "VarianceScaling", t;
28245}(Initializer);
28246
28247_tfjsCore.serialization.registerClass(VarianceScaling);
28248
28249var GlorotUniform = function (e) {
28250  function t(t) {
28251    return e.call(this, {
28252      scale: 1,
28253      mode: "fanAvg",
28254      distribution: "uniform",
28255      seed: null == t ? null : t.seed
28256    }) || this;
28257  }
28258
28259  return __extends(t, e), t.prototype.getClassName = function () {
28260    return VarianceScaling.className;
28261  }, t.className = "GlorotUniform", t;
28262}(VarianceScaling);
28263
28264_tfjsCore.serialization.registerClass(GlorotUniform);
28265
28266var GlorotNormal = function (e) {
28267  function t(t) {
28268    return e.call(this, {
28269      scale: 1,
28270      mode: "fanAvg",
28271      distribution: "normal",
28272      seed: null == t ? null : t.seed
28273    }) || this;
28274  }
28275
28276  return __extends(t, e), t.prototype.getClassName = function () {
28277    return VarianceScaling.className;
28278  }, t.className = "GlorotNormal", t;
28279}(VarianceScaling);
28280
28281_tfjsCore.serialization.registerClass(GlorotNormal);
28282
28283var HeNormal = function (e) {
28284  function t(t) {
28285    return e.call(this, {
28286      scale: 2,
28287      mode: "fanIn",
28288      distribution: "normal",
28289      seed: null == t ? null : t.seed
28290    }) || this;
28291  }
28292
28293  return __extends(t, e), t.prototype.getClassName = function () {
28294    return VarianceScaling.className;
28295  }, t.className = "HeNormal", t;
28296}(VarianceScaling);
28297
28298_tfjsCore.serialization.registerClass(HeNormal);
28299
28300var HeUniform = function (e) {
28301  function t(t) {
28302    return e.call(this, {
28303      scale: 2,
28304      mode: "fanIn",
28305      distribution: "uniform",
28306      seed: null == t ? null :
28306 t.seed
28307    }) || this;
28308  }
28309
28310  return __extends(t, e), t.prototype.getClassName = function () {
28311    return VarianceScaling.className;
28312  }, t.className = "HeUniform", t;
28313}(VarianceScaling);
28314
28315_tfjsCore.serialization.registerClass(HeUniform);
28316
28317var LeCunNormal = function (e) {
28318  function t(t) {
28319    return e.call(this, {
28320      scale: 1,
28321      mode: "fanIn",
28322      distribution: "normal",
28323      seed: null == t ? null : t.seed
28324    }) || this;
28325  }
28326
28327  return __extends(t, e), t.prototype.getClassName = function () {
28328    return VarianceScaling.className;
28329  }, t.className = "LeCunNormal", t;
28330}(VarianceScaling);
28331
28332_tfjsCore.serialization.registerClass(LeCunNormal);
28333
28334var LeCunUniform = function (e) {
28335  function t(t) {
28336    return e.call(this, {
28337      scale: 1,
28338      mode: "fanIn",
28339      distribution: "uniform",
28340      seed: null == t ? null : t.seed
28341    }) || this;
28342  }
28343
28344  return __extends(t, e), t.prototype.getClassName = function () {
28345    return VarianceScaling.className;
28346  }, t.className = "LeCunNormal", t;
28347}(VarianceScaling);
28348
28349_tfjsCore.serialization.registerClass(LeCunUniform);
28350
28351var Orthogonal = function (e) {
28352  function t(t) {
28353    var n = e.call(this) || this;
28354    if (n.DEFAULT_GAIN = 1, n.gain = null == t.gain ? n.DEFAULT_GAIN : t.gain, n.seed = t.seed, null != n.seed) throw new NotImplementedError("Random seed is not implemented for Orthogonal Initializer yet.");
28355    return n;
28356  }
28357
28358  return __extends(t, e), t.prototype.apply = function (e, t) {
28359    var n = this;
28360    return (0, _tfjsCore.tidy)(function () {
28361      if (2 !== e.length) throw new NotImplementedError("The Orthogonal Initializer does not support non-2D shapes yet.");
28362      e[0] * e[1] > 2e3 && console.warn("Orthogonal initializer is being called on a matrix with more than 2000 (" + e[0] * e[1] + ") elements: Slowness may result.");
28363
28364      var t = randomNormal$1(e[0] > e[1] ? [e[1], e[0]] : e, 0, 1, "float32"),
28365          r = _tfjsCore.linalg.gramSchmidt(t);
28366
28367      return e[0] > e[1] && (r = r.transpose()), (0, _tfjsCore.mul)(n.gain, r);
28368    });
28369  }, t.prototype.getConfig = function () {
28370    return {
28371      gain: this.gain,
28372      seed: this.seed
28373    };
28374  }, t.className = "Orthogonal", t;
28375}(Initializer);
28376
28377_tfjsCore.serialization.registerClass(Orthogonal);
28378
28379var INITIALIZER_IDENTIFIER_REGISTRY_SYMBOL_MAP = {
28380  constant: "Constant",
28381  glorotNormal: "GlorotNormal",
28382  glorotUniform: "GlorotUniform",
28383  heNormal: "HeNormal",
28384  heUniform: "HeUniform",
28385  identity: "Identity",
28386  leCunNormal: "LeCunNormal",
28387  leCunUniform: "LeCunUniform",
28388  ones: "Ones",
28389  orthogonal: "Orthogonal",
28390  randomNormal: "RandomNormal",
28391  randomUniform: "RandomUniform",
28392  truncatedNormal: "TruncatedNormal",
28393  varianceScaling: "VarianceScaling",
28394  zeros: "Zeros"
28395};
28396
28397function deserializeInitializer(e, t) {
28398  return void 0 === t && (t = {}), deserializeKerasObject(e, _tfjsCore.serialization.SerializationMap.getMap().classNameMap, t, "initializer");
28399}
28400
28401function serializeInitializer(e) {
28402  return serializeKerasObject(e);
28403}
28404
28405function getInitializer(e) {
28406  if ("string" == typeof e) {
28407    var t = e in INITIALIZER_IDENTIFIER_REGISTRY_SYMBOL_MAP ? INITIALIZER_IDENTIFIER_REGISTRY_SYMBOL_MAP[e] : e;
28408    if ("GlorotNormal" === t) return new GlorotNormal();
28409    if ("GlorotUniform" === t) return new GlorotUniform();
28410    if ("HeNormal" === t) return new HeNormal();
28411    if ("HeUniform" === t) return new HeUniform();
28412    if ("LeCunNormal" === t) return new LeCunNormal();
28413    if ("LeCunUniform" === t) return new LeCunUniform();
28414    var n = {};
28415    return n.className = t, n.config = {}, deserializeInitializer(n);
28416  }
28417
28418  return e instanceof Initializer ? e : deserializeInitializer(e);
28419}
28420
28421function zeros$1() {
28422  return new Zeros();
28423}
28424
28425function ones$1() {
28426  return new Ones();
28427}
28428
28429function constant(e) {
28430  return new Constant(e);
28431}
28432
28433function randomUniform$1(e) {
28434  return new RandomUniform(e);
28435}
28436
28437function randomNormal$2(e) {
28438  return new RandomNormal(e);
28439}
28440
28441function truncatedNormal$1(e) {
28442  return new TruncatedNormal(e);
28443}
28444
28445function identity(e) {
28446  return new Identity(e);
28447}
28448
28449function varianceScaling(e) {
28450  return new VarianceScaling(e);
28451}
28452
28453function glorotUniform(e) {
28454  return new GlorotUniform(e);
28455}
28456
28457function glorotNormal(e) {
28458  return new GlorotNormal(e);
28459}
28460
28461function heNormal(e) {
28462  return new HeNormal(e);
28463}
28464
28465function heUniform(e) {
28466  return new HeUniform(e);
28467}
28468
28469function leCunNormal(e) {
28470  return new LeCunNormal(e);
28471}
28472
28473function leCunUniform(e) {
28474  return new LeCunUniform(e);
28475}
28476
28477function orthogonal(e) {
28478  return new Orthogonal(e);
28479}
28480
28481var exports_initializers = Object.freeze({
28482  zeros: zeros$1,
28483  ones: ones$1,
28484  constant: constant,
28485  randomUniform: randomUniform$1,
28486  randomNormal: randomNormal$2,
28487  truncatedNormal: truncatedNormal$1,
28488  identity: identity,
28489  varianceScaling: varianceScaling,
28490  glorotUniform: glorotUniform,
28491  glorotNormal: glorotNormal,
28492  heNormal: heNormal,
28493  heUniform: heUniform,
28494  leCunNormal: leCunNormal,
28495  leCunUniform: leCunUniform,
28496  orthogonal: orthogonal
28497}),
28498    _nextUniqueTensorId = 0;
28499exports.initializers = exports_initializers;
28500
28501function getNextUniqueTensorId() {
28502  return _nextUniqueTensorId++;
28503}
28504
28505var _uidPrefixes = {};
28506
28507function getUid(e) {
28508  return void 0 === e && (e = ""), e in _uidPrefixes || (_uidPrefixes[e] = 0), _uidPrefixes[e] += 1, e + _uidPrefixes[e].toString();
28509}
28510
28511function isArrayOfShapes(e) {
28512  return Array.isArray(e) && Array.isArray(e[0]);
28513}
28514
28515function normalizeShapeList(e) {
28516  return 0 === e.length ? [] : Array.isArray(e[0]) ? e : [e];
28517}
28518
28519function getExactlyOneTensor(e) {
28520  var t;
28521
28522  if (Array.isArray(e)) {
28523    if (1 !== e.length) throw new ValueError("Expected Tensor length to be 1; got " + e.length);
28524    t = e[0];
28525  } else t = e;
28526
28527  return t;
28528}
28529
28530function getExactlyOneShape(e) {
28531  if (Array.isArray(e) && Array.isArray(e[0])) {
28532    if (1 === e.length) return (e = e)[0];
28533    throw new ValueError("Expected exactly 1 Shape; got " + e.length);
28534  }
28535
28536  return e;
28537}
28538
28539function countParamsInWeights(e) {
28540  for (var t = 0, n = 0, r = e; n < r.length; n++) {
28541    var i = r[n];
28542    0 === i.shape.length ? t += 1 : t += i.shape.reduce(function (e, t) {
28543      return e * t;
28544    });
28545  }
28546
28547  return t;
28548}
28549
28550var DEFAULT_VARIABLE_NAME_PREFIX = "Variable",
28551    LayerVariable = function () {
28552  function e(e, t, n, r, i) {
28553    void 0 === t && (t = "float32"), void 0 === n && (n = DEFAULT_VARIABLE_NAME_PREFIX), void 0 === r && (r = !0), void 0 === i && (i = null), this.dtype = null == t ? "float32" : t, this.shape = e.shape, this.id = getNextUniqueTensorId(), n = null == n ? DEFAULT_VARIABLE_NAME_PREFIX : n, this.originalName = getScopedTensorName(n), this.name = getUniqueTensorName(this.originalName), this.trainable_ = r, this.constraint = i, this.val = (0, _tfjsCore.variable)(e, this.trainable_, this.name, this.dtype);
28554  }
28555
28556  return e.prototype.read = function () {
28557    return this.assertNotDisposed(), this.val;
28558  }, e.prototype.write = function (e) {
28559    return this.assertNotDisposed(), checkShapesMatch(this.val, e), this.val.id !== e.id && (this.val.assign(e), null != this.constraint && this.val.assign(this.constraint.apply(this.val))), this;
28560  }, e.prototype.dispose = function () {
28561    this.assertNotDisposed(), this.val.dispose();
28562  }, e.prototype.assertNotDisposed = function () {
28563    if (this.val.isDisposed) throw new Error("LayersVariable " + this.name + " is already disposed.");
28564  }, Object.defineProperty(e.prototype, "trainable", {
28565    get: function () {
28566      return this.trainable_;
28567    },
28568    set: function (e) {
28569      this.trainable_ = e, this.val.trainable = e;
28570    },
28571    enumerable: !0,
28572    configurable: !0
28573  }), e;
28574}();
28575
28576exports.LayerVariable = LayerVariable;
28577
28578function checkShapesMatch(e, t) {
28579  if (e.shape.toString() !== t.shape.toString()) throw new Error("Shape mismatch: " + JSON.stringify(e.shape) + " vs. " + JSON.stringify(t.shape));
28580}
28581
28582function batchGetValue(e) {
28583  return e.map(function (e) {
28584    return e.read();
28585  });
28586}
28587
28588function batchSetValue(e) {
28589  e.forEach(function (e) {
28590    e[0].write(e[1]);
28591  });
28592}
28593
28594var InputSpec = function () {
28595  return function (e) {
28596    this.dtype = e.dtype, this.shape = e.shape, null != e.shape ? this.ndim = e.shape.length : this.ndim = e.ndim, this.maxNDim = e.maxNDim, this.minNDim = e.minNDim, this.axes = e.axes || {};
28597  };
28598}(),
28599    SymbolicTensor = function () {
28600  return function (e, t, n, r, i, a, o) {
28601    this.dtype = e, this.shape = t, this.sourceLayer = n, this.inputs = r, this.callArgs = i, this.outputTensorIndex = o, this.id = getNextUniqueTensorId(), null != a && (this.originalName = getScopedTensorName(a), this.name = getUniqueTensorName(this.originalName)), this.rank = t.length;
28602  };
28603}(),
28604    _nextNodeID = 0,
28605    Node = function () {
28606  function e(e, t) {
28607    this.callArgs = t, this.id = _nextNodeID++, this.outboundLayer = e.outboundLayer, this.inboundLayers = e.inbou
28607ndLayers, this.nodeIndices = e.nodeIndices, this.tensorIndices = e.tensorIndices, this.inputTensors = e.inputTensors, this.outputTensors = e.outputTensors, this.inputMasks = e.inputMasks, this.outputMasks = e.outputMasks, this.inputShapes = e.inputShapes, this.outputShapes = e.outputShapes;
28608
28609    for (var n = 0, r = e.inboundLayers; n < r.length; n++) {
28610      var i = r[n];
28611      null != i && i.outboundNodes.push(this);
28612    }
28613
28614    e.outboundLayer.inboundNodes.push(this);
28615  }
28616
28617  return e.prototype.getConfig = function () {
28618    for (var e = [], t = 0, n = this.inboundLayers; t < n.length; t++) {
28619      var r = n[t];
28620      null != r ? e.push(r.name) : e.push(null);
28621    }
28622
28623    return {
28624      outboundLayer: this.outboundLayer ? this.outboundLayer.name : null,
28625      inboundLayers: e,
28626      nodeIndices: this.nodeIndices,
28627      tensorIndices: this.tensorIndices
28628    };
28629  }, e;
28630}(),
28631    _nextLayerID = 0,
28632    Layer = function (e) {
28633  function t(t) {
28634    var n = e.call(this) || this;
28635    n._callHook = null, n._addedWeightNames = [], n._stateful = !1, n.id = _nextLayerID++, n.activityRegularizer = null, n.inputSpec = null, n.supportsMasking = !1, n._trainableWeights = [], n._nonTrainableWeights = [], n._losses = [], n._updates = [], n._built = !1, n.inboundNodes = [], n.outboundNodes = [];
28636    var r = t.name;
28637
28638    if (!r) {
28639      var i = n.getClassName();
28640      r = toSnakeCase(i) + "_" + getUid(i);
28641    }
28642
28643    if (n.name = r, n.trainable_ = null == t.trainable || t.trainable, null != t.inputShape || null != t.batchInputShape) {
28644      var a = void 0;
28645      if (null != t.batchInputShape) a = t.batchInputShape;else if (null != t.inputShape) {
28646        var o = null;
28647        null != t.batchSize && (o = t.batchSize), a = [o].concat(t.inputShape);
28648      }
28649      n.batchInputShape = a;
28650      var s = t.dtype;
28651      null == s && (s = t.inputDType), null == s && (s = "float32"), n.dtype = s;
28652    }
28653
28654    return null != t.weights ? n.initialWeights = t.weights : n.initialWeights = null, n._refCount = null, n.fastWeightInitDuringBuild = !1, n;
28655  }
28656
28657  return __extends(t, e), t.nodeKey = function (e, t) {
28658    return e.name + "_ib-" + t.toString();
28659  }, t.prototype.getNodeAtIndex = function (e, t) {
28660    if (0 === this.inboundNodes.length) throw new RuntimeError("The layer has never been called and thus has no defined " + t + ".");
28661    if (this.inboundNodes.length <= e) throw new ValueError("Asked to get " + t + " at node " + e + ", but the layer has only " + this.inboundNodes.length + " inbound nodes.");
28662    return this.inboundNodes[e];
28663  }, t.prototype.getInputAt = function (e) {
28664    return singletonOrArray(this.getNodeAtIndex(e, "input").inputTensors);
28665  }, t.prototype.getOutputAt = function (e) {
28666    return singletonOrArray(this.getNodeAtIndex(e, "output").outputTensors);
28667  }, Object.defineProperty(t.prototype, "input", {
28668    get: function () {
28669      if (this.inboundNodes.length > 1) throw new AttributeError("Layer " + this.name + ' has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use `getInputAt(nodeIndex)` instead.');
28670      if (0 === this.inboundNodes.length) throw new AttributeError("Layer " + this.name + " is not connected, no input to return.");
28671      return singletonOrArray(this.getNodeAtIndex(0, "input").inputTensors);
28672    },
28673    enumerable: !0,
28674    configurable: !0
28675  }), Object.defineProperty(t.prototype, "output", {
28676    get: function () {
28677      if (0 === this.inboundNodes.length) throw new AttributeError("Layer " + this.name + " has no inbound nodes.");
28678      if (this.inboundNodes.length > 1) throw new AttributeError("Layer " + this.name + ' has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use `getOutputAt(nodeIndex)` instead.');
28679      return singletonOrArray(this.getNodeAtIndex(0, "output").outputTensors);
28680    },
28681    enumerable: !0,
28682    configurable: !0
28683  }), Object.defineProperty(t.prototype, "losses", {
28684    get: function () {
28685      return this._losses;
28686    },
28687    enumerable: !0,
28688    configurable: !0
28689  }), t.prototype.calculateLosses = function () {
28690    return this.losses.map(function (e) {
28691      return e();
28692    });
28693  }, Object.defineProperty(t.prototype, "updates", {
28694    get: function () {
28695      return this._updates;
28696    },
28697    enumerable: !0,
28698    configurable: !0
28699  }), Object.defineProperty(t.prototype, "built", {
28700    get: function () {
28701      return this._built;
28702    },
28703    set: function (e) {
28704      this._built = e;
28705    },
28706    enumerable: !0,
28707    configurable: !0
28708  }), Object.defineProperty(t.prototype, "trainable", {
28709    get: function () {
28710      return this.trainable_;
28711    },
28712    set: function (e) {
28713      this._trainableWeights.forEach(function (t) {
28714        return t.trainable = e;
28715      }), this.trainable_ = e;
28716    },
28717    enumerable: !0,
28718    configurable: !0
28719  }), Object.defineProperty(t.prototype, "trainableWeights", {
28720    get: function () {
28721      return this.trainable_ ? this._trainableWeights.filter(function (e) {
28722        return e.trainable;
28723      }) : [];
28724    },
28725    set: function (e) {
28726      this._trainableWeights = e;
28727    },
28728    enumerable: !0,
28729    configurable: !0
28730  }), Object.defineProperty(t.prototype, "nonTrainableWeights", {
28731    get: function () {
28732      return this.trainable ? this._trainableWeights.filter(function (e) {
28733        return !e.trainable;
28734      }).concat(this._nonTrainableWeights) : this._trainableWeights.concat(this._nonTrainableWeights);
28735    },
28736    set: function (e) {
28737      this._nonTrainableWeights = e;
28738    },
28739    enumerable: !0,
28740    configurable: !0
28741  }), Object.defineProperty(t.prototype, "weights", {
28742    get: function () {
28743      return this.trainableWeights.concat(this.nonTrainableWeights);
28744    },
28745    enumerable: !0,
28746    configurable: !0
28747  }), Object.defineProperty(t.prototype, "stateful", {
28748    get: function () {
28749      return this._stateful;
28750    },
28751    enumerable: !0,
28752    configurable: !0
28753  }), t.prototype.resetStates = function () {
28754    if (!this.stateful) throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.");
28755  }, t.prototype.assertInputCompatibility = function (e) {
28756    if (e = toList(e), null != this.inputSpec && 0 !== this.inputSpec.length) {
28757      var t = toList(this.inputSpec);
28758      if (e.length !== t.length) throw new ValueError("Layer " + this.name + " expects " + t.length + " inputs, but it received " + e.length + " input tensors. Input received: " + e);
28759
28760      for (var n = 0; n < e.length; n++) {
28761        var r = e[n],
28762            i = t[n];
28763
28764        if (null != i) {
28765          var a = r.rank;
28766          if (null != i.ndim && a !== i.ndim) throw new ValueError("Input " + n + " is incompatible with layer " + this.name + ": expected ndim=" + i.ndim + ", found ndim=" + a);
28767          if (null != i.maxNDim && a > i.maxNDim) throw new ValueError("Input " + n + " is incompatible with layer " + this.name + ": expected max_ndim=" + i.maxNDim + ", found ndim=" + a);
28768          if (null != i.minNDim && a < i.minNDim) throw new ValueError("Input " + n + " is incompatible with layer " + this.name + ": expected min_ndim=" + i.minNDim + ", found ndim=" + a + ".");
28769          if (null != i.dtype && r.dtype !== i.dtype) throw new ValueError("Input " + n + " is incompatible with layer " + this.name + " : expected dtype=" + i.dtype + ", found dtype=" + r.dtype + ".");
28770
28771          if (i.axes) {
28772            var o = r.shape;
28773
28774            for (var s in i.axes) {
28775              var l = Number(s),
28776                  u = i.axes[s],
28777                  c = l >= 0 ? o[l] : o[o.length + l];
28778              if (null != u && -1 === [u, null].indexOf(c)) throw new ValueError("Input " + n + " is incompatible with layer " + this.name + ": expected axis " + l + " of input shape to have value " + u + " but got shape " + o + ".");
28779            }
28780          }
28781
28782          if (null != i.shape) for (var p = 0; p < i.shape.length; ++p) {
28783            var h = i.shape[p],
28784                d = r.shape[p];
28785            if (null != h && null != d && h !== d) throw new ValueError("Input " + n + " is incompatible with layer " + this.name + ": expected shape=" + i.shape + ", found shape=" + r.shape + ".");
28786          }
28787        }
28788      }
28789    }
28790  }, t.prototype.call = function (e, t) {
28791    return e;
28792  }, t.prototype.invokeCallHook = function (e, t) {
28793    null != this._callHook && this._callHook(e, t);
28794  }, t.prototype.setCallHook = function (e) {
28795    this._callHook = e;
28796  }, t.prototype.clearCallHook = function () {
28797    this._callHook = null;
28798  }, t.prototype.apply = function (e, t) {
28799    var n = this;
28800    t = t || {}, this.assertNotDisposed();
28801
28802    for (var r = toList(e), i = !0, a = 0, o = r; a < o.length; a++) {
28803      if (!(o[a] instanceof SymbolicTensor)) {
28804        i = !1;
28805        break;
28806      }
28807    }
28808
28809    for (var s = !0, l = 0, u = r; l < u.length; l++) {
28810      if (u[l] instanceof SymbolicTensor) {
28811        s = !1;
28812        break;
28813      }
28814    }
28815
28816    if (i === s) throw new ValueError("Arguments to apply() must be all SymbolicTensors or all Tensors");
28817    return nameScope(this.name, function () {
28818      if (!n.built) {
28819        n.assertInputCompatibility(e);
28820
28821        for (var i = [], a = 0, o = toList(e); a < o.length; a++) {
28822          var l = o[a];
28823          i.push(l.shape);
28824        }
28825
28826        n.build(singletonOrArray(i)), n.built = !0, n.initialWeights && n.setWeights(n.initialWeights), null === n._refCount && s && (n._refCount = 1);
28827      }
28828
28829      if (n.assertInputCompatibility(e), s) {
28830        for (var u = [], c = 0, p = toList(g = n.call(e, t)); c < p.length; c++) {
28831          var h = p[c];
28832          -1 !== r.indexOf(h) && (h = h.clone()), u.push(h);
28833        }
28834
28835        if (g = singletonOrArray(u), null != n.activityRegularizer) throw new NotImplementedError("Layer invocation in the presence of activity regularizer(s) is not supported yet.");
28836        return g;
28837      }
28838
28839      var d = collectInputShape(e),
28840          f = n.computeOutputShape(d),
28841          g = void 0,
28842          m = guessOutputDType(e);
28843      if (n.warnOnIncompatibleInputShape(Array.isArray(e) ? d[0] : d), g = null != f && f.length > 0 && Array.isArray(f[0]) ? f.map(function (r, i) {
28844        return new SymbolicTensor(m, r, n, toList(e), t, n.name, i);
28845      }) : new SymbolicTensor(m, f, n, toList(e), t, n.name), n.addInboundNode(e, g, null, null, d, f, t), n._refCount++, null != n.activityRegularizer) throw new NotImplementedError("Layer invocation in the presence of activity regularizer(s) is not supported yet.");
28846      return g;
28847    });
28848  }, t.prototype.warnOnIncompatibleInputShape = function (e) {
28849    if (null != this.batchInputShape) if (e.length !== this.batchInputShape.length) console.warn("The rank of the input tensor provided (shape: " + JSON.stringify(e) + ") does not match that of the batchInputShape (" + JSON.stringify(this.batchInputShape) + ") of the layer " + this.name);else {
28850      var t = !1;
28851      this.batchInputShape.forEach(function (n, r) {
28852        null != n && null != e[r] && e[r] !== n && (t = !0);
28853      }), t && console.warn("The shape of the input tensor (" + JSON.stringify(e) + ") does not match the expectation of layer " + this.name + ": " + JSON.stringify(this.batchInputShape));
28854    }
28855  }, Object.defineProperty(t.prototype, "outputShape", {
28856    get: function () {
28857      if (null == this.inboundNodes || 0 === this.inboundNodes.length) throw new AttributeError("The layer " + this.name + " has never been called and thus has no defined output shape.");
28858
28859      for (var e = [], t = 0, n = this.inboundNodes; t < n.length; t++) {
28860        var r = n[t],
28861            i = JSON.stringify(r.outputShapes);
28862        -1 === e.indexOf(i) && e.push(i);
28863      }
28864
28865      if (1 === e.length) {
28866        var a = this.inboundNodes[0].outputShapes;
28867        return Array.isArray(a) && Array.isArray(a[0]) && 1 === a.length ? a[0] : a;
28868      }
28869
28870      throw new AttributeError("The layer " + this.name + ' has multiple inbound nodes with different output shapes. Hence the notion of "outut shape" is ill-defined for the layer.');
28871    },
28872    enumerable: !0,
28873    configurable: !0
28874  }), t.prototype.countParams = function () {
28875    if (!this.built) throw new RuntimeError("You tried to call countParams() on " + this.name + ", but the layer is not built yet. Build it first by calling build(batchInputShape).");
28876    return countParamsInWeights(this.weights);
28877  }, t.prototype.build = function (e) {
28878    this.built = !0;
28879  }, t.prototype.getWeights = function (e) {
28880    return void 0 === e && (e = !1), batchGetValue(e ? this.trainableWeights : this.weights);
28881  }, t.prototype.setWeights = function (e) {
28882    var t = this;
28883    (0, _tfjsCore.tidy)(function () {
28884      var n = t.weights;
28885      if (n.length !== e.length) throw new ValueError('You called setWeights(weights) on layer "' + t.name + '" with a weight list of length ' + e.length + ", but the layer was expecting " + n.length + " weights. Provided weights: " + e + "...");
28886
28887      if (0 !== n.length) {
28888        for (var r = [], i = batchGetValue(n), a = 0; a < i.length; ++a) {
28889          var o = i[a],
28890              s = n[a],
28891              l = e[a];
28892          if (!_tfjsCore.util.arraysEqual(o.shape, l.shape)) throw new ValueError("Layer weight shape " + o.shape + " not compatible with provided weight shape " + l.shape);
28893          r.push([s, l]);
28894        }
28895
28896        batchSetValue(r);
28897      }
28898    });
28899  }, t.prototype.addWeight = function (e, t, n, r, i, a, o) {
28900    if (-1 !== this._addedWeightNames.indexOf(e)) throw new ValueError("Duplicate weight name " + e + " for layer " + this.name);
28901    this._addedWeightNames.push(e), null == n && (n = "float32"), this.fastWeightInitDuringBuild && (r = getInitializer("zeros"));
28902    var s = r.apply(t, n),
28903        l = new LayerVariable(s, n, e, a, o);
28904    return s.dispose(), null != i && this.addLoss(function () {
28905      return i.apply(l.read());
28906    }), null == a && (a = !0), a ? this._trainableWeights.push(l) : this._nonTrainableWeights.push(l), l;
28907  }, t.prototype.setFastWeightInitDuringBuild = function (e) {
28908    this.fastWeightInitDuringBuild = e;
28909  }, t.prototype.addLoss = function (e) {
28910    var t;
28911    null == e || Array.isArray(e) && 0 === e.length || (e = toList(e), void 0 !== this._losses && null !== this._losses && (t = this.losses).push.apply(t, e));
28912  }, t.prototype.computeOutputShape = function (e) {
28913    return e;
28914  }, t.prototype.computeMask = function (e, t) {
28915    var n = this;
28916
28917    if (!this.supportsMasking) {
28918      if (null != t) {
28919        if (!Array.isArray(t)) throw new TypeError("Layer " + this.name + " does not support masking, but was passed an inputMask.");
28920        t.forEach(function (e) {
28921          if (null != e) throw new TypeError("Layer " + n.name + " does not support masking, but was passed an inputMask.");
28922        });
28923      }
28924
28925      return null;
28926    }
28927
28928    return t;
28929  }, t.prototype.addInboundNode = function (e, t, n, r, i, a, o) {
28930    void 0 === o && (o = null);
28931    var s = toList(e);
28932    t = toList(t), n = toList(n), r = toList(r), i = normalizeShapeList(i), a = normalizeShapeList(a);
28933
28934    for (var l = [], u = [], c = [], p = 0, h = s; p < h.length; p++) {
28935      var d = h[p];
28936      l.push(d.sourceLayer), u.push(d.nodeIndex), c.push(d.tensorIndex);
28937    }
28938
28939    new Node({
28940      outboundLayer: this,
28941      inboundLayers: l,
28942      nodeIndices: u,
28943      tensorIndices: c,
28944      inputTensors: s,
28945      outputTensors: t,
28946      inputMasks: n,
28947      outputMasks: r,
28948      inputShapes: i,
28949      outputShapes: a
28950    }, o);
28951
28952    for (var f = 0; f < t.length; f++) t[f].sourceLayer = this, t[f].nodeIndex = this.inboundNodes.length - 1, t[f].tensorIndex = f;
28953  }, t.prototype.getConfig = function () {
28954    var e = {
28955      name: this.name,
28956      trainable: this.trainable
28957    };
28958    return null != this.batchInputShape && (e.batchInputShape = this.batchInputShape), null != this.dtype && (e.dtype = this.dtype), e;
28959  }, t.prototype.disposeWeights = function () {
28960    return this.weights.forEach(function (e) {
28961      return e.dispose();
28962    }), this.weights.length;
28963  }, t.prototype.assertNotDisposed = function () {
28964    if (0 === this._refCount) throw new Error("Layer '" + this.name + "' is already disposed.");
28965  }, t.prototype.dispose = function () {
28966    if (!this.built) throw new Error("Cannot dispose Layer " + this.name + " because it has not been built yet.");
28967    if (null === this._refCount) throw new Error("Cannot dispose Layer " + this.name + " because it has not been used yet.");
28968    this.assertNotDisposed();
28969    var e = 0;
28970    return 0 == --this._refCount && (e = this.disposeWeights()), {
28971      refCountAfterDispose: this._refCount,
28972      numDisposedVariables: e
28973    };
28974  }, t;
28975}(_tfjsCore.serialization.Serializable);
28976
28977exports.SymbolicTensor = SymbolicTensor;
28978exports.InputSpec = InputSpec;
28979
28980function collectInputShape(e) {
28981  for (var t = [], n = 0, r = e = toList(e); n < r.length; n++) {
28982    var i = r[n];
28983    t.push(i.shape);
28984  }
28985
28986  return singletonOrArray(t);
28987}
28988
28989function guessOutputDType(e) {
28990  return "float32";
28991}
28992
28993function getSourceInputs(e, t, n) {
28994  if ((null == t || null != n && n > 0) && (t = e.sourceLayer, n = e.nodeIndex), 0 === t.inboundNodes.length) return [e];
28995  var r = t.inboundNodes[n];
28996  if (0 === r.inboundLayers.length) return r.inputTensors;
28997
28998  for (var i = [], a = 0; a < r.inboundLayers.length; a++) for (var o = 0, s = getSourceInputs(r.inputTensors[a], r.inboundLayers[a], r.nodeIndices[a]); o < s.length; o++) {
28999    var l = s[o];
29000    -1 === i.indexOf(l) && i.push(l);
29001  }
29002
29003  return i;
29004}
29005
29006var ModelLoggingVerbosity,
29007    InputLayer = function (e) {
29008  function t(t) {
29009    var n = e.call(this, {
29010      dtype: t.dtype,
29011      name: null != t.name ? t.name : getUid("input").toString()
29012    }) || this;
29013    if (null == t.batchSize && (t.batchSize = null), null == t.sparse && (t.sparse = !1), n.trainable = !1, n.built = !0, n.sparse = t.sparse, null != t.inputShape && null != t.batchInputShape) throw new ValueError("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time.");
29014    var r = t.batchInputShape;
29015
29016    if (null == r) {
29017      if (null == t.inputShape) throw new ValueError("An InputLayer should be passed either a `batchInputShape` or an `inputShape`.");
29018      r = [t.batchSize].concat(t.inputShape);
29019    } else if (null != t.batchSize) throw new ValueError("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer.");
29020
29021    var i = t.dtype || "float32";
29022    n.batchInputShape = r, n.dtype = i, n.inputSpec = [{
29023      shape: r
29024    }];
29025    var a = new SymbolicTensor(n.dtype, n.batchInputShape, n, [], {}, n.name);
29026    return a.nodeIndex = 0, a.tensorIndex = 0, new Node({
29027      outboundLayer: n,
29028      inboundLayers: [],
29029      nodeIndices: [],
29030      tensorIndices: [],
29031      inputTensors: [a],
29032      outputTensors: [a],
29033      inputMasks: [null],
29034      outputMasks: [null],
29035      inputShapes: [r],
29036      outputShapes: [r]
29037    }), n;
29038  }
29039
29040  return __extends(t, e), t.prototype.apply = function (e, t) {
29041    throw new ValueError("Cannot pass any input to an InputLayer's apply() method. InputLayer name: " + this.name);
29042  }, t.prototype.dispose = function () {
29043    return {
29044      refCountAfterDispose: this._refCount,
29045      numDisposedVariables: 0
29046    };
29047  }, t.prototype.getConfig = function () {
29048    return {
29049      batchInputShape: this.batchInputShape,
29050      dtype: this.dtype,
29051      sparse: this.sparse,
29052      name: this.name
29053    };
29054  }, t.className = "InputLayer", t;
29055}(Layer);
29056
29057function Input(e) {
29058  if (null == e.batchShape && null == e.shape) throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension.");
29059  if (null != e.batchShape && null != e.shape) throw new ValueError("Please provide either a `shape` or `batchShape` argument to Input, but not both.");
29060  var t = e.batchShape;
29061  null != e.shape && null == t && (t = [null].concat(e.shape));
29062  var n = e.dtype;
29063  return null == n && (n = "float32"), new InputLayer({
29064    batchInputShape: t,
29065    name: e.name,
29066    dtype: n,
29067    sparse: e.sparse
29068  }).inboundNodes[0].outputTensors[0];
29069}
29070
29071function resolveScalarsInLogs(e) {
29072  return __awaiter(this, void 0, void 0, function () {
29073    var t, n, r, i, a, o, s, l;
29074    return __generator(this, function (u) {
29075      switch (u.label) {
29076        case 0:
29077          if (null == e) return [2];
29078
29079          for (i in t = [], n = [], r = [], e) "number" != typeof (a = e[i]) && (o = a, t.push(o.data()), n.push(i), r.push(o));
29080
29081          return t.length > 0 ? [4, Promise.all(t)] : [3, 2];
29082
29083        case 1:
29084          for (s = u.sent(), l = 0; l < s.length; ++l) e[n[l]] = s[l][0];
29085
29086          (0, _tfjsCore.dispose)(r), u.label = 2;
29087
29088        case 2:
29089          return [2];
29090      }
29091    });
29092  });
29093}
29094
29095function disposeTensorsInLogs(e) {
29096  if (null != e) for (var t in e) {
29097    var n = e[t];
29098    "number" != typeof n && n.dispose();
29099  }
29100}
29101
29102_tfjsCore.serialization.registerClass(InputLayer), function (e) {
29103  e[e.SILENT = 0] = "SILENT", e[e.VERBOSE = 1] = "VERBOSE";
29104}(ModelLoggingVerbosity || (ModelLoggingVerbosity = {}));
29105
29106var DEFAULT_YIELD_EVERY_MS = 125,
29107    BaseCallback = function () {
29108  function e() {
29109    this.validationData = null;
29110  }
29111
29112  return e.prototype.setParams = function (e) {
29113    this.params = e;
29114  }, e.prototype.onEpochBegin = function (e, t) {
29115    return __awaiter(this, void 0, void 0, function () {
29116      return __generator(this, function (e) {
29117        return [2];
29118      });
29119    });
29120  }, e.prototype.onEpochEnd = function (e, t) {
29121    return __awaiter(this, void 0, void 0, function () {
29122      return __generator(this, function (e) {
29123        return [2];
29124      });
29125    });
29126  }, e.prototype.onBatchBegin = function (e, t) {
29127    return __awaiter(this, void 0, void 0, function () {
29128      return __generator(this, function (e) {
29129        return [2];
29130      });
29131    });
29132  }, e.prototype.onBatchEnd = function (e, t) {
29133    return __awaiter(this, void 0, void 0, function () {
29134      return __generator(this, function (e) {
29135        return [2];
29136      });
29137    });
29138  }, e.prototype.onTrainBegin = function (e) {
29139    return __awaiter(this, void 0, void 0, function () {
29140      return __generator(this, function (e) {
29141        return [2];
29142      });
29143    });
29144  }, e.prototype.onTrainEnd = function (e) {
29145    return __awaiter(this, void 0, void 0, function () {
29146      return __generator(this, function (e) {
29147        return [2];
29148      });
29149    });
29150  }, e.prototype.setModel = function (e) {}, e;
29151}(),
29152    CallbackList = function () {
29153  function e(e, t) {
29154    void 0 === t && (t = 10), null == e && (e = []), this.callbacks = e, this.queueLength = t;
29155  }
29156
29157  return e.prototype.append = function (e) {
29158    this.callbacks.push(e);
29159  }, e.prototype.setParams = function (e) {
29160    for (var t = 0, n = this.callbacks; t < n.length; t++) {
29161      n[t].setParams(e);
29162    }
29163  }, e.prototype.setModel = function (e) {
29164    for (var t = 0, n = this.callbacks; t < n.length; t++) {
29165      n[t].setModel(e);
29166    }
29167  }, e.prototype.onEpochBegin = function (e, t) {
29168    return __awaiter(this, void 0, void 0, function () {
29169      var n, r;
29170      return __generator(this, function (i) {
29171        switch (i.label) {
29172          case 0:
29173            null == t && (t = {}), n = 0, r = this.callbacks, i.label = 1;
29174
29175          case 1:
29176            return n < r.length ? [4, r[n].onEpochBegin(e, t)] : [3, 4];
29177
29178          case 2:
29179            i.sent(), i.label = 3;
29180
29181          case 3:
29182            return n++, [3, 1];
29183
29184          case 4:
29185            return [2];
29186        }
29187      });
29188    });
29189  }, e.prototype.onEpochEnd = function (e, t) {
29190    return __awaiter(this, void 0, void 0, function () {
29191      var n, r;
29192      return __generator(this, function (i) {
29193        switch (i.label) {
29194          case 0:
29195            null == t && (t = {}), n = 0, r = this.callbacks, i.label = 1;
29196
29197          case 1:
29198            return n < r.length ? [4, r[n].onEpochEnd(e, t)] : [3, 4];
29199
29200          case 2:
29201            i.sent(), i.label = 3;
29202
29203          case 3:
29204            return n++, [3, 1];
29205
29206          case 4:
29207            return [2];
29208        }
29209      });
29210    });
29211  }, e.prototype.onBatchBegin = function (e, t) {
29212    return __awaiter(this, void 0, void 0, function () {
29213      var n, r;
29214      return __generator(this, function (i) {
29215        switch (i.label) {
29216          case 0:
29217            null == t && (t = {}), n = 0, r = this.callbacks, i.label = 1;
29218
29219          case 1:
29220            return n < r.length ? [4, r[n].onBatchBegin(e, t)] : [3, 4];
29221
29222          case 2:
29223            i.sent(), i.label = 3;
29224
29225          case 3:
29226            return n++, [3, 1];
29227
29228          case 4:
29229            return [2];
29230        }
29231      });
29232    });
29233  }, e.prototype.onBatchEnd = function (e, t) {
29234    return __awaiter(this, void 0, void 0, function () {
29235      var n, r;
29236      return __generator(this, function (i) {
29237        switch (i.label) {
29238          case 0:
29239            null == t && (t = {}), n = 0, r = this.callbacks, i.label = 1;
29240
29241          case 1:
29242            return n < r.length ? [4, r[n].onBatchEnd(e, t)] : [3, 4];
29243
29244          case 2:
29245            i.sent(), i.label = 3;
29246
29247          case 3:
29248            return n++, [3, 1];
29249
29250          case 4:
29251            return [2];
29252        }
29253      });
29254    });
29255  }, e.prototype.onTrainBegin = function (e) {
29256    return __awaiter(this, void 0, void 0, function () {
29257      var t, n;
29258      return __generator(this, function (r) {
29259        switch (r.label) {
29260          case 0:
29261            null == e && (e = {}), t = 0, n = this.callbacks, r.label = 1;
29262
29263          case 1:
29264            return t < n.length ? [4, n[t].onTrainBegin(e)] : [3, 4];
29265
29266          case 2:
29267            r.sent(), r.label = 3;
29268
29269          case 3:
29270            return t++, [3, 1];
29271
29272          case 4:
29273            return [2];
29274        }
29275      });
29276    });
29277  }, e.prototype.onTrainEnd = function (e) {
29278    return __awaiter(this, void 0, void 0, function () {
29279      var t, n;
29280      return __generator(this, function (r) {
29281        switch (r.label) {
29282          case 0:
29283            null == e && (e = {}), t = 0, n = this.callbacks, r.label = 1;
29284
29285          case 1:
29286            return t < n.length ? [4, n[t].onTrainEnd(e)] : [3, 4];
29287
29288          case 2:
29289            r.sent(), r.label = 3;
29290
29291          case 3:
29292            return t++, [3, 1];
29293
29294          case 4:
29295            return [2];
29296        }
29297      });
29298    });
29299  }, e;
29300}(),
29301    BaseLogger = function (e) {
29302  function t() {
29303    return e.call(this) || this;
29304  }
29305
29306  return __extends(t, e), t.prototype.onEpochBegin = function (e) {
29307    return __awaiter(this, void 0, void 0, function () {
29308      return __generator(this, function (e) {
29309        return this.seen = 0, this.totals = {}, [2];
29310      });
29311    });
29312  }, t.prototype.onBatchEnd = function (e, t) {
29313    return __awaiter(this, void 0, void 0, function () {
29314      var e,
29315          n,
29316          r,
29317          i,
29318          a = this;
29319      return __generator(this, function (o) {
29320        for (i in null == t && (t = {}), e = null == t.size ? 0 : t.size, this.seen += e, n = function (n) {
29321          var i = t[n];
29322          if ("number" == typeof i) r.totals.hasOwnProperty(n) || (r.totals[n] = 0), r.totals[n] = r.totals[n] + i * e;else {
29323            var o = void 0;
29324            n in r.totals ? o = r.totals[n] : r.totals[n] = 0;
29325            var s = (0, _tfjsCore.tidy)(function () {
29326              return (0, _tfjsCore.add)(a.totals[n], (0, _tfjsCore.mul)(i, e));
29327            });
29328            r.totals[n] = s, null != o && o.dispose();
29329          }
29330        }, r = this, t) n(i);
29331
29332        return [2];
29333      });
29334    });
29335  }, t.prototype.onEpochEnd = function (e, t) {
29336    return __awaiter(this, void 0, void 0, function () {
29337      var e,
29338          n,
29339          r,
29340          i,
29341          a,
29342          o = this;
29343      return __generator(this, function (s) {
29344        if (null != t) for (e = function (e) {
29345          if (null == n.totals[e]) return "continue";
29346          "number" == typeof n.totals[e] ? t[e] = n.totals[e] / n.seen : (0, _tfjsCore.tidy)(function () {
29347            var n = (0, _tfjsCore.mul)((0, _tfjsCore.div)(1, o.seen), o.totals[e]);
29348            t[e] = n, o.totals[e].dispose(), (0, _tfjsCore.keep)(t[e]);
29349          });
29350        }, n = this, r = 0, i = this.params.metrics; r < i.length; r++) a = i[r], e(a);
29351        return [2];
29352      });
29353    });
29354  }, t;
29355}(BaseCallback),
29356    History = function (e) {
29357  function t() {
29358    return null !== e && e.apply(this, arguments) || this;
29359  }
29360
29361  return __extends(t, e), t.prototype.onTrainBegin = function (e) {
29362    return __awaiter(this, void 0, void 0, function () {
29363      return __generator(this, function (e) {
29364        return this.epoch = [], this.history = {}, [2];
29365      });
29366    });
29367  }, t.prototype.onEpochEnd = function (e, t) {
29368    return __awaiter(this, void 0, void 0, function () {
29369      var n;
29370      return __generator(this, function (r) {
29371        for (n in null == t && (t = {}), this.epoch.push(e), t) null == this.history[n] && (this.history[n] = []), this.history[n].push(t[n]);
29372
29373        return [2];
29374      });
29375    });
29376  }, t.prototype.syncData = function () {
29377    return __awaiter(this, void 0, void 0, function () {
29378      var e, t, n, r, i, a, o, s, l;
29379      return __generator(this, function (u) {
29380        switch (u.label) {
29381          case 0:
29382            for (r in e = [], t = [], n = [], this.history) for (i = this.history[r], a = 0; a < i.length; ++a) "number" != typeof i[a] && (o = i[a], e.push(o.data()), t.push(r), n.push(a));
29383
29384            return [4, Promise.all(e)];
29385
29386          case 1:
29387            for (s = u.sent(), l = 0; l < s.length; ++l) this.history[t[l]][n[l]].dispose(), this.history[t[l]][n[l]] = s[l][0];
29388
29389            return [2];
29390        }
29391      });
29392    });
29393  }, t;
29394}(BaseCallback),
29395    CustomCallback = function (e) {
29396  function t(t, n) {
29397    var r = e.call(this) || this;
29398    if (r.currentEpoch = 0, r.yieldEvery = n || "auto", "auto" === r.yieldEvery && (r.yieldEvery = DEFAULT_YIELD_EVERY_MS), "never" === r.yieldEvery && null != t.onYield) throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback");
29399    return _tfjsCore.util.isNumber(r.yieldEvery) && (r.maybeWait = debounce(r.maybeWait.bind(r), r.yieldEvery)), r.trainBegin = t.onTrainBegin, r.trainEnd = t.onTrainEnd, r.epochBegin = t.onEpochBegin, r.epochEnd = t.onEpochEnd, r.batchBegin = t.onBatchBegin, r.batchEnd = t.onBatchEnd, r.yield = t.onYield, r;
29400  }
29401
29402  return __extends(t, e), t.prototype.maybeWait = function (e, t, n) {
29403    return __awaiter(this, void 0, void 0, function () {
29404      var r;
29405      return __generator(this, function (i) {
29406        switch (i.label) {
29407          case 0:
29408            return r = [], null == this.yield ? [3, 2] : [4, resolveScalarsInLogs(n)];
29409
29410          case 1:
29411            i.sent(), r.push(this.yield(e, t, n)), i.label = 2;
29412
29413          case 2:
29414            return r.push((0, _tfjsCore.nextFrame)()), [4, Promise.all(r)];
29415
29416          case 3:
29417            return i.sent(), [2];
29418        }
29419      });
29420    });
29421  }, t.prototype.onEpochBegin = function (e, t) {
29422    return __awaiter(this, void 0, void 0, function () {
29423      return __generator(this, function (n) {
29424        switch (n.label) {
29425          case 0:
29426            return this.currentEpoch = e, null == this.epochBegin ? [3, 3] : [4, resolveScalarsInLogs(t)];
29427
29428          case 1:
29429            return n.sent(), [4, this.epochBegin(e, t)];
29430
29431          case 2:
29432            n.sent(), n.label = 3;
29433
29434          case 3:
29435            return [2];
29436        }
29437      });
29438    });
29439  }, t.prototype.onEpochEnd = function (e, t) {
29440    return __awaiter(this, void 0, void 0, function () {
29441      var n;
29442      return __generator(this, function (r) {
29443        switch (r.label) {
29444          case 0:
29445            return n = [], null == this.epochEnd ? [3, 2] : [4, resolveScalarsInLogs(t)];
29446
29447          case 1:
29448            r.sent(), n.push(this.epochEnd(e, t)), r.label = 2;
29449
29450          case 2:
29451            return "epoch" === this.yieldEvery && n.push((0, _tfjsCore.nextFrame)()), [4, Promise.all(n)];
29452
29453          case 3:
29454            return r.sent(), [2];
29455        }
29456      });
29457    });
29458  }, t.prototype.onBatchBegin = function (e, t) {
29459    return __awaiter(this, void 0, void 0, function () {
29460      return __generator(this, function (n) {
29461        switch (n.label) {
29462          case 0:
29463            return null == this.batchBegin ? [3, 3] : [4, resolveScalarsInLogs(t)];
29464
29465          case 1:
29466            return n.sent(), [4, this.batchBegin(e, t)];
29467
29468          case 2:
29469            n.sent(), n.label = 3;
29470
29471          case 3:
29472            return [2];
29473        }
29474      });
29475    });
29476  }, t.prototype.onBatchEnd = function (e, t) {
29477    return __awaiter(this, void 0, void 0, function () {
29478      var n;
29479      return __generator(this, function (r) {
29480        switch (r.label) {
29481          case 0:
29482            return n = [], null == this.batchEnd ? [3, 2] : [4, resolveScalarsInLogs(t)];
29483
29484          case 1:
29485            r.sent(), n.push(this.batchEnd(e, t)), r.label = 2;
29486
29487          case 2:
29488            return "batch" === this.yieldEvery ? n.push((0, _tfjsCore.nextFrame)()) : _tfjsCore.util.isNumber(this.yieldEvery) && n.push(this.maybeWait(this.currentEpoch, e, t)), [4, Promise.all(n)];
29489
29490          case 3:
29491            return r.sent(), [2];
29492        }
29493      });
29494    });
29495  }, t.prototype.onTrainBegin = function (e) {
29496    return __awaiter(this, void 0, void 0, function () {
29497      return __generator(this, function (t) {
29498        switch (t.label) {
29499          case 0:
29500            return null == this.trainBegin ? [3, 3] : [4, resolveScalarsInLogs(e)];
29501
29502          case 1:
29503            return t.sent(), [4, this.trainBegin(e)];
29504
29505          case 2:
29506            t.sent(), t.label = 3;
29507
29508          case 3:
29509            return [2];
29510        }
29511      });
29512    });
29513  }, t.prototype.onTrainEnd = function (e) {
29514    return __awaiter(this, void 0, void 0, function () {
29515      return __generator(this, function (t) {
29516        switch (t.label) {
29517          case 0:
29518            return null == this.trainEnd ? [3, 3] : [4, resolveScalarsInLogs(e)];
29519
29520          case 1:
29521            return t.sent(), [4, this.trainEnd(e)];
29522
29523          case 2:
29524            t.sent(), t.label = 3;
29525
29526          case 3:
29527            return [2];
29528        }
29529      });
29530    });
29531  }, t;
29532}(BaseCallback);
29533
29534exports.CustomCallback = CustomCallback;
29535exports.History = History;
29536exports.CallbackList = CallbackList;
29537
29538function standardizeCallbacks(e, t) {
29539  return null == e && (e = {}), e instanceof BaseCallback ? [e] : Array.isArray(e) && e[0] instanceof BaseCallback ? e : toList(e).map(function (e) {
29540    return new CustomCallback(e, t);
29541  });
29542}
29543
29544var CallbackConstructorRegistry = function () {
29545  function e() {}
29546
29547  return e.registerCallbackConstructor = function (t, n) {
29548    _tfjsCore.util.assert(t >= 0 && Number.isInteger(t), function () {
29549      return "Verbosity level is expected to be an integer >= 0, but got " + t;
29550    }), e.checkForDuplicate(n), null == e.constructors[t] && (e.constructors[t] = []), e.constructors[t].push(n);
29551  }, e.checkForDuplicate = function (t) {
29552    for (var n in e.constructors) {
29553      e.constructors[+n].forEach(function (e) {
29554        if (e === t) throw new ValueError("Duplicate callback constructor.");
29555      });
29556    }
29557  }, e.clear = function () {
29558    e.constructors = {};
29559  }, e.createCallbacks = function (t) {
29560    var n = [];
29561
29562    for (var r in e.constructors) {
29563      var i = +r;
29564      t >= i && n.push.apply(n, e.constructors[i]);
29565    }
29566
29567    return n.map(function (e) {
29568      return new e();
29569    });
29570  }, e.constructors = {}, e;
29571}();
29572
29573function configureCallbacks(e, t, n, r, i, a, o, s, l) {
29574  var u = new History(),
29575      c = [new BaseLogger()].concat(CallbackConstructorRegistry.createCallbacks(t));
29576  null != e && c.push.apply(c, e), c.push(u);
29577  var p = new CallbackList(c);
29578  return p.setParams({
29579    epochs: n,
29580    initialEpoch: r,
29581    samples: i,
29582    steps: a,
29583    batchSize: o,
29584    verbose: t,
29585    doValidation: s,
29586    metrics: l
29587  }), {
29588    callbackList: p,
29589    history: u
29590  };
29591}
29592
29593function deserialize(e, t, n) {
29594  return void 0 === t && (t = {}), void 0 === n && (n = !1), deserializeKerasObject(e, _tfjsCore.serialization.SerializationMap.getMap().classNameMap, t, "layer", n);
29595}
29596
29597function l2Normalize(e, t) {
29598  return (0, _tfjsCore.tidy)(function () {
29599    "float32" !== e.dtype && (e = e.asType("float32"));
29600    var n = (0, _tfjsCore.sum)(square(e), t, !0),
29601        r = (0, _tfjsCore.fill)(n.shape, epsilon()),
29602        i = (0, _tfjsCore.sqrt)((0, _tfjsCore.maximum)(n, r));
29603    return (0, _tfjsCore.div)(e, i);
29604  });
29605}
29606
29607function meanSquaredError(e, t) {
29608  return (0, _tfjsCore.tidy)(function () {
29609    return (0, _tfjsCore.mean)(square((0, _tfjsCore.sub)(t, e)), -1);
29610  });
29611}
29612
29613function meanAbsoluteError(e, t) {
29614  return (0, _tfjsCore.tidy)(function () {
29615    return (0, _tfjsCore.mean)((0, _tfjsCore.abs)((0, _tfjsCore.sub)(t, e)), -1);
29616  });
29617}
29618
29619function meanAbsolutePercentageError(e, t) {
29620  return (0, _tfjsCore.tidy)(function () {
29621    var n = (0, _tfjsCore.sub)(e, t),
29622        r = (0, _tfjsCore.clipByValue)((0, _tfjsCore.abs)(e), epsilon(), Number.MAX_VALUE),
29623        i = (0, _tfjsCore.abs)((0, _tfjsCore.div)(n, r));
29624    return (0, _tfjsCore.mul)(100, (0, _tfjsCore.mean)(i, -1));
29625  });
29626}
29627
29628function meanSquaredLogarithmicError(e, t) {
29629  return (0, _tfjsCore.tidy)(function () {
29630    var n = (0, _tfjsCore.clipByValue)(t, epsilon(), Number.MAX_VALUE),
29631        r = (0, _tfjsCore.log)((0, _tfjsCore.add)(1, n)),
29632        i = (0, _tfjsCore.clipByValue)(e, epsilon(), Number.MAX_VALUE),
29633        a = (0, _tfjsCore.log)((0, _tfjsCore.add)(1, i));
29634    return (0, _tfjsCore.mean)(square((0, _tfjsCore.sub)(r, a)), -1);
29635  });
29636}
29637
29638function squaredHinge(e, t) {
29639  return (0, _tfjsCore.tidy)(function () {
29640    var n = (0, _tfjsCore.maximum)(0, (0, _tfjsCore.sub)(1, (0, _tfjsCore.mul)(e, t)));
29641    return (0, _tfjsCore.mean)(square(n), -1);
29642  });
29643}
29644
29645function hinge(e, t) {
29646  return (0, _tfjsCore.tidy)(function () {
29647    var n = (0, _tfjsCore.maximum)(0, (0, _tfjsCore.sub)(1, (0, _tfjsCore.mul)(e, t)));
29648    return (0, _tfjsCore.mean)(n, -1);
29649  });
29650}
29651
29652function categoricalHinge(e, t) {
29653  return (0, _tfjsCore.tidy)(function () {
29654    var n = (0, _tfjsCore.sum)((0, _tfjsCore.mul)(e, t), -1),
29655        r = (0, _tfjsCore.max)((0, _tfjsCore.mul)((0, _tfjsCore.sub)(1, e), t), -1);
29656    return (0, _tfjsCore.maximum)(0, (0, _tfjsCore.add)(1, (0, _tfjsCore.sub)(r, n)));
29657  });
29658}
29659
29660function logcosh(e, t) {
29661  return (0, _tfjsCore.tidy)(function () {
29662    var n = Math.log(2),
29663        r = (0, _tfjsCore.sub)(t, e),
29664        i = (0, _tfjsCore.sub)((0, _tfjsCore.add)(r, (0, _tfjsCore.softplus)((0, _tfjsCore.mul)(-2, r))), n);
29665    return (0, _tfjsCore.mean)(i, -1);
29666  });
29667}
29668
29669function categoricalCrossentropy(e, t, n) {
29670  return void 0 === n && (n = !1), (0, _tfjsCore.tidy)(function () {
29671    if (n) t = (0, _tfjsCore.softmax)(t);else {
29672      var r = (0, _tfjsCore.sum)(t, t.shape.length - 1, !0);
29673      t = (0, _tfjsCore.div)(t, r);
29674    }
29675    return t = (0, _tfjsCore.clipByValue)(t, epsilon(), 1 - epsilon()), (0, _tfjsCore.neg)((0, _tfjsCore.sum)((0, _tfjsCore.mul)(e.toFloat(), (0, _tfjsCore.log)(t)), t.shape.length - 1));
29676  });
29677}
29678
29679function sparseCategoricalCrossentropy(e, t) {
29680  return (0, _tfjsCore.tidy)(function () {
29681    var n = (0, _tfjsCore.floor)(flatten(e)).toInt(),
29682        r = (t = (0, _tfjsCore.clipByValue)(t, epsilon(), 1 - epsilon())).shape;
29683    return categoricalCrossentropy((0, _tfjsCore.oneHot)(n, r[r.length - 1]).reshape(r), t, !1);
29684  });
29685}
29686
29687function sigmoidCrossEntropyWithLogits(e, t) {
29688  if (!_tfjsCore.util.arraysEqual(e.shape, t.shape)) throw new ValueError("logits and labels must have the same shape, but got shapes " + JSON.stringify(e.shape) + " and " + JSON.stringify(t.shape));
29689  return (0, _tfjsCore.tidy)(function () {
29690    var n = t.relu(),
29691        r = t.abs().neg();
29692    return n.sub(t.mul(e)).add(r.exp().log1p());
29693  });
29694}
29695
29696function binaryCrossentropy(e, t) {
29697  return (0, _tfjsCore.tidy)(function () {
29698    var n;
29699    return n = (0, _tfjsCore.clipByValue)(t, epsilon(), 1 - epsilon()), n = (0, _tfjsCore.log)((0, _tfjsCore.div)(n, (0, _tfjsCore.sub)(1, n))), (0, _tfjsCore.mean)(sigmoidCrossEntropyWithLogits(e, n), -1);
29700  });
29701}
29702
29703function kullbackLeiblerDivergence(e, t) {
29704  return (0, _tfjsCore.tidy)(function () {
29705    var n = (0, _tfjsCore.clipByValue)(e, epsilon(), 1),
29706        r = (0, _tfjsCore.clipByValue)(t, epsilon(), 1);
29707    return (0, _tfjsCore.sum)((0, _tfjsCore.mul)(e, (0, _tfjsCore.log)((0, _tfjsCore.div)(n, r))), -1);
29708  });
29709}
29710
29711function poisson(e, t) {
29712  return (0, _tfjsCore.tidy)(function () {
29713    var n = (0, _tfjsCore.log)((0, _tfjsCore.add)(epsilon(), t));
29714    return (0, _tfjsCore.mean)((0, _tfjsCore.sub)(t, (0, _tfjsCore.mul)(e, n)), -1);
29715  });
29716}
29717
29718function cosineProximity(e, t) {
29719  return (0, _tfjsCore.tidy)(function () {
29720    var n = l2Normalize(e, -1),
29721        r = l2Normalize(t, -1),
29722        i = (0, _tfjsCore.mul)(n, r);
29723    return (0, _tfjsCore.neg)((0, _tfjsCore.sum)(i, -1));
29724  });
29725}
29726
29727var lossesMap = {
29728  meanSquaredError: meanSquaredError,
29729  meanAbsoluteError: meanAbsoluteError,
29730  meanAbsolutePercentageError: meanAbsolutePercentageError,
29731  meanSquaredLogarithmicError: meanSquaredLogarithmicError,
29732  squaredHinge: squaredHinge,
29733  hinge: hinge,
29734  categoricalHinge: categoricalHinge,
29735  logcosh: logcosh,
29736  categoricalCrossentropy: categoricalCrossentropy,
29737  sparseCategoricalCrossentropy: sparseCategoricalCrossentropy,
29738  binaryCrossentropy: binaryCrossentropy,
29739  kullbackLeiblerDivergence: kullbackLeiblerDivergence,
29740  poisson: poisson,
29741  cosineProximity: cosineProximity
29742};
29743
29744function get(e) {
29745  if ("string" == typeof e) {
29746    if (e in lossesMap) return lossesMap[e];
29747    var t = "Unknown loss " + e;
29748    throw e.toLowerCase().includes("softmaxcrossentropy") && (t = "Unknown loss " + e + '. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy'), new ValueError(t);
29749  }
29750
29751  return e;
29752}
29753
29754function binaryAccuracy(e, t) {
29755  return (0, _tfjsCore.tidy)(function () {
29756    var n = (0, _tfjsCore.mul)(.5, (0, _tfjsCore.onesLike)(t)),
29757        r = cast$1((0, _tfjsCore.greater)(t, n), e.dtype);
29758    return (0, _tfjsCore.mean)((0, _tfjsCore.equal)(e, r), -1);
29759  });
29760}
29761
29762function categoricalAccuracy(e, t) {
29763  return (0, _tfjsCore.tidy)(function () {
29764    return cast$1((0, _tfjsCore.equal)((0, _tfjsCore.argMax)(e, -1), (0, _tfjsCore.argMax)(t, -1)), "float32");
29765  });
29766}
29767
29768function truePositives(e, t) {
29769  return (0, _tfjsCore.tidy)(function () {
29770    return (0, _tfjsCore.logicalAnd)(e.equal(1), t.equal(1)).sum().cast("float32");
29771  });
29772}
29773
29774function falseNegatives(e, t) {
29775  return (0, _tfjsCore.tidy)(function () {
29776    return (0, _tfjsCore.logicalAnd)(e.equal(1), t.equal(0)).sum().cast("float32");
29777  });
29778}
29779
29780function falsePositives(e, t) {
29781  return (0, _tfjsCore.tidy)(function () {
29782    return (0, _tfjsCore.logicalAnd)(e.equal(0), t.equal(1)).sum().cast("float32");
29783  });
29784}
29785
29786function precision(e, t) {
29787  return (0, _tfjsCore.tidy)(function () {
29788    var n = truePositives(e, t),
29789        r = falsePositives(e, t),
29790        i = n.add(r);
29791    return (0, _tfjsCore.where)((0, _tfjsCore.greater)(i, 0), n.div(i), 0).cast("float32");
29792  });
29793}
29794
29795function recall(e, t) {
29796  return (0, _tfjsCore.tidy)(function () {
29797    var n = truePositives(e, t),
29798        r = falseNegatives(e, t),
29799        i = n.add(r);
29800    return (0, _tfjsCore.where)((0, _tfjsCore.greater)(i, 0), n.div(i), 0).cast("float32");
29801  });
29802}
29803
29804function binaryCrossentropy$1(e, t) {
29805  return binaryCrossentropy(e, t);
29806}
29807
29808function sparseCategoricalAccuracy(e, t) {
29809  return e.rank === t.rank && (e = e.squeeze([e.rank - 1])), (t = t.argMax(-1)).dtype !== e.dtype && (t = t.asType(e.dtype)), (0, _tfjsCore.equal)(e, t).asType("float32");
29810}
29811
29812var mse$1 = meanSquaredError,
29813    MSE$1 = meanSquaredError,
29814    mae$1 = meanAbsoluteError,
29815    MAE$1 = meanAbsoluteError,
29816    mape$1 = meanAbsolutePercentageError,
29817    MAPE$1 = meanAbsolutePercentageError,
29818    categoricalCrossentropy$1 = categoricalCrossentropy,
29819    cosine$1 = cosineProximity,
29820    sparseCategoricalCrossentropy$1 = sparseCategoricalCrossentropy,
29821    metricsMap = {
29822  binaryAccuracy: binaryAccuracy,
29823  categoricalAccuracy: categoricalAccuracy,
29824  precision: precision,
29825  categoricalCrossentropy: categoricalCrossentropy$1,
29826  sparseCategoricalCrossentropy: sparseCategoricalCrossentropy$1,
29827  mse: mse$1,
29828  MSE: MSE$1,
29829  mae: mae$1,
29830  MAE: MAE$1,
29831  mape: mape$1,
29832  MAPE: MAPE$1,
29833  cosine: cosine$1
29834};
29835
29836function get$1(e) {
29837  if ("string" == typeof e && e in metricsMap) return metricsMap[e];
29838  if ("string" != typeof e && null != e) return e;
29839  throw new ValueError("Unknown metric " + e);
29840}
29841
29842function getLossOrMetricName(e) {
29843  if (assert(null !== e, "Unknown LossOrMetricFn " + e), "string" == typeof e) return e;
29844
29845  for (var t = void 0, n = 0, r = Object.keys(lossesMap); n < r.length; n++) {
29846    var i = r[n];
29847
29848    if (lossesMap[i] === e) {
29849      t = i;
29850      break;
29851    }
29852  }
29853
29854  if (void 0 !== t) return t;
29855
29856  for (var a = 0, o = Object.keys(metricsMap); a < o.length; a++) {
29857    i = o[a];
29858
29859    if (metricsMap[i] === e) {
29860      t = i;
29861      break;
29862    }
29863  }
29864
29865  return void 0 !== t ? t : e.name;
29866}
29867
29868function getOptimizer(e) {
29869  var t = {
29870    Adagrad: function () {
29871      return _tfjsCore.train.adagrad(.01);
29872    },
29873    Adadelta: function () {
29874      return _tfjsCore.train.adadelta(1, .95, epsilon());
29875    },
29876    Adam: function () {
29877      return _tfjsCore.train.adam(.001, .9, .999, epsilon());
29878    },
29879    Adamax: function () {
29880      return _tfjsCore.train.adamax(.002, .9, .999, epsilon(), 0);
29881    },
29882    RMSProp: function () {
29883      return _tfjsCore.train.rmsprop(.001, .9, 0, epsilon());
29884    },
29885    SGD: function () {
29886      return _tfjsCore.train.sgd(.01);
29887    }
29888  };
29889  if (t.adagrad = t.Adagrad, t.adadelta = t.Adadelta, t.adam = t.Adam, t.adamax = t.Adamax, t.rmsprop = t.RMSProp, t.sgd = t.SGD, e in t) return t[e]();
29890  throw new ValueError("Unknown Optimizer " + e);
29891}
29892
29893var MAX_USER_DEFINED_METADATA_SERIALIZED_LENGTH = 1048576;
29894
29895function checkUserDefinedMetadata(e, t, n) {
29896  if (void 0 === n && (n = !1), null == e || "object" != typeof e || Object.getPrototypeOf(e) !== Object.prototype || !plainObjectCheck(e)) throw new Error("User-defined metadata is expected to be a JSON object, but is not.");
29897
29898  if (n) {
29899    var r = JSON.stringify(e);
29900    r.length > MAX_USER_DEFINED_METADATA_SERIALIZED_LENGTH && console.warn('User-defined metadata of model "' + t + '" is too large in size (length=' + r.length + " when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= " + MAX_USER_DEFINED_METADATA_SERIALIZED_LENGTH + ".");
29901  }
29902}
29903
29904function plainObjectCheck(e) {
29905  if (null === e) return !0;
29906
29907  if ("object" == typeof e) {
29908    if (Object.getPrototypeOf(e) === Object.prototype) {
29909      for (var t = 0, n = Object.keys(e); t < n.length; t++) {
29910        var r = n[t];
29911        if ("string" != typeof r) return !1;
29912        if (!plainObjectCheck(e[r])) return !1;
29913      }
29914
29915      return !0;
29916    }
29917
29918    if (Array.isArray(e)) {
29919      for (var i = 0, a = e; i < a.length; i++) {
29920        if (!plainObjectCheck(a[i])) return !1;
29921      }
29922
29923      return !0;
29924    }
29925
29926    return !1;
29927  }
29928
29929  var o = typeof e;
29930  return "string" === o || "number" === o || "boolean" === o;
29931}
29932
29933function printSummary(e, t, n, r) {
29934  void 0 === r && (r = console.log);
29935  var i,
29936      a = isModelSequentialLike(e),
29937      o = ["Layer (type)", "Output shape", "Param #"];
29938  if (a ? (t = t || 65, n = n || [.45, .85, 1]) : (t = t || 98, n = n || [.33, .55, .67, 1]), n[n.length - 1] <= 1 && (n = n.map(function (e) {
29939    return Math.floor(t * e);
29940  })), !a) for (var s in o.push("Receives inputs"), i = [], e.nodesByDepth) i.push.apply(i, e.nodesByDepth[s]);
29941  r("_".repeat(t)), printRow(o, n, r), r("=".repeat(t));
29942
29943  for (var l = e.layers, u = 0; u < l.length; ++u) a ? printLayerSummary(l[u], n, r) : printLayerSummaryWithConnections(l[u], n, i, r), r((u === l.length - 1 ? "=" : "_").repeat(t));
29944
29945  e.checkTrainableWeightsConsistency();
29946  var c = countTrainableParams(e),
29947      p = countParamsInWeights(e.nonTrainableWeights);
29948  r("Total params: " + (c + p)), r("Trainable params: " + c), r("Non-trainable params: " + p), r("_".repeat(t));
29949}
29950
29951function countTrainableParams(e) {
29952  return null != e.collectedTrainableWeights ? countParamsInWeights(e.collectedTrainableWeights) : countParamsInWeights(e.trainableWeights);
29953}
29954
29955function isModelSequentialLike(e) {
29956  var t = !0,
29957      n = [],
29958      r = [];
29959
29960  for (var i in e.nodesByDepth) n.push(e.nodesByDepth[i]);
29961
29962  for (var a = 0, o = n; a < o.length; a++) {
29963    var s = o[a];
29964
29965    if (s.length > 1 || 1 === s.length && s[0].inboundLayers.length > 1) {
29966      t = !1;
29967      break;
29968    }
29969
29970    r.push.apply(r, s);
29971  }
29972
29973  if (t) for (var l = 0, u = e.layers; l < u.length; l++) {
29974    for (var c = !1, p = 0, h = u[l].inboundNodes; p < h.length; p++) {
29975      var d = h[p];
29976
29977      if (-1 !== r.indexOf(d)) {
29978        if (c) {
29979          t = !1;
29980          break;
29981        }
29982
29983        c = !0;
29984      }
29985    }
29986
29987    if (!t) break;
29988  }
29989  return t;
29990}
29991
29992function printRow(e, t, n) {
29993  void 0 === n && (n = console.log);
29994
29995  for (var r = "", i = 0; i < e.length; ++i) i > 0 && (r = r.slice(0, r.length - 1) + " "), r = (r += e[i]).slice(0, t[i]), r += " ".repeat(t[i] - r.length);
29996
29997  n(r);
29998}
29999
30000function printLayerSummary(e, t, n) {
30001  var r;
30002
30003  try {
30004    r = JSON.stringify(e.outputShape);
30005  } catch (e) {
30006    r = "multiple";
30007  }
30008
30009  printRow([e.name + " (" + e.getClassName() + ")", r, e.countParams().toString()], t, n);
30010}
30011
30012function printLayerSummaryWithConnections(e, t, n, r) {
30013  var i;
30014
30015  try {
30016    i = JSON.stringify(e.outputShape);
30017  } catch (e) {
30018    i = "multiple";
30019  }
30020
30021  for (var a = [], o = 0, s = e.inboundNodes; o < s.length; o++) {
30022    var l = s[o];
30023    if (!(null != n && n.length > 0 && -1 === n.indexOf(l))) for (var u = 0; u < l.inboundLayers.length; ++u) {
30024      var c = l.inboundLayers[u].name,
30025          p = l.nodeIndices[u],
30026          h = l.tensorIndices[u];
30027      a.push(c + "[" + p + "][" + h + "]");
30028    }
30029  }
30030
30031  var d = e.name,
30032      f = e.getClassName(),
30033      g = 0 === a.length ? "" : a[0];
30034  printRow([d + " (" + f + ")", i, e.countParams().toString(), g], t, r);
30035
30036  for (u = 1; u < a.length; ++u) printRow(["", "", "", a[u]], t, r);
30037}
30038
30039function isArrayItemInputOrOutputName(e, t, n) {
30040  return ("inboundNodes" === e || "outputLayers" === e || "inputLayers" === e) && 0 === t && "string" == typeof n;
30041}
30042
30043function convertPythonicToTs(e, t) {
30044  if (null === e) return null;
30045  if ("string" == typeof e) return toCamelCase(e);
30046  if ("number" == typeof e || "boolean" == typeof e) return e;
30047
30048  if (e instanceof Array) {
30049    for (var n = [], r = e.length, i = 0; i < r; ++i) {
30050      var a = e[i];
30051      isArrayItemInputOrOutputName(t, i, a) ? n.push(a) : n.push(convertPythonicToTs(a, t));
30052    }
30053
30054    return n;
30055  }
30056
30057  for (var o = {}, s = 0, l = Object.keys(e); s < l.length; s++) {
30058    var u = l[s],
30059        c = e[u];
30060    if ("name" === u && "string" == typeof c) o[u] = c;else {
30061      var p = toCamelCase(u);
30062      o[p] = convertPythonicToTs(c, p);
30063    }
30064  }
30065
30066  return o;
30067}
30068
30069function convertTsToPythonic(e, t) {
30070  if (null === e || void 0 === e) return null;
30071  if ("string" == typeof e) return toSnakeCase(e);
30072  if ("number" == typeof e || "boolean" == typeof e) return e;
30073
30074  if (e instanceof Array) {
30075    for (var n = [], r = e.length, i = 0; i < r; ++i) {
30076      var a = e[i];
30077      isArrayItemInputOrOutputName(t, i, a) ? n.push(a) : n.push(convertTsToPythonic(a, t));
30078    }
30079
30080    return n;
30081  }
30082
30083  for (var o = {}, s = 0, l = Object.keys(e); s < l.length; s++) {
30084    var u = l[s],
30085        c = e[u],
30086        p = toSnakeCase(u);
30087    o[p] = "name" !== u && "className" !== u || "string" != typeof c ? convertTsToPythonic(c, u) : c;
30088  }
30089
30090  return o;
30091}
30092
30093var version = "1.7.1";
30094exports.version_layers = version;
30095
30096function assertFeedCompatibility(e, t) {
30097  if (null == e.dtype || e.dtype === t.dtype) return t;
30098
30099  try {
30100    return (0, _tfjsCore.cast)(t, e.dtype);
30101  } catch (n) {
30102    throw new ValueError("The dtype of the feed (" + t.dtype + ") can not be cast to the dtype of the key '" + e.name + "' (" + e.dtype + ").");
30103  }
30104}
30105
30106var FeedDict = function () {
30107  function e(t) {
30108    if (this.id2Value = {}, this.id2Mask = {}, this.name2Id = {}, t instanceof e) for (var n in t.id2Value) this.id2Value[n] = t.id2Value[n], n in t.id2Mask && (this.id2Mask[n] = t.id2Mask[n]);else {
30109      if (null == t) return;
30110
30111      for (var r = 0, i = t; r < i.length; r++) {
30112        var a = i[r];
30113        this.add(a.key, a.value);
30114      }
30115    }
30116  }
30117
30118  return e.prototype.add = function (e, t, n) {
30119    if (null != this.id2Value[e.id]) throw new ValueError("Duplicate key: name=" + e.name + ", id=" + e.id);
30120    return this.id2Value[e.id] = assertFeedCompatibility(e, t), this.name2Id[e.name] = e.id, null != n && (this.id2Mask[e.id] = n), this;
30121  }, e.prototype.addFeed = function (e) {
30122    this.add(e.key, e.value);
30123  }, e.prototype.hasKey = function (e) {
30124    return null != this.id2Value[e.id];
30125  }, e.prototype.names = function () {
30126    return Object.keys(this.name2Id);
30127  }, e.prototype.getValue = function (e) {
30128    if (e instanceof SymbolicTensor) {
30129      if (null == this.id2Value[e.id]) throw new ValueError("Nonexistent key: " + e.name);
30130      return this.id2Value[e.id];
30131    }
30132
30133    var t = this.name2Id[e];
30134    if (null == t) throw new ValueError("Feed dict has no SymbolicTensor name: " + e);
30135    return this.id2Value[t];
30136  }, e.prototype.getMask = function (e) {
30137    if (e instanceof SymbolicTensor) {
30138      if (null == this.id2Value[e.id]) throw new ValueError("Nonexistent key: " + e.name);
30139      return this.id2Mask[e.id];
30140    }
30141
30142    var t = this.name2Id[e];
30143    if (null == t) throw new ValueError("Feed dict has no SymbolicTensor name: " + e);
30144    return this.id2Mask[t];
30145  }, e.prototype.disposeMasks = function () {
30146    null != this.id2Mask && (0, _tfjsCore.dispose)(this.id2Mask);
30147  }, e;
30148}(),
30149    cachedSorted = {},
30150    cachedRecipientCounts = {};
30151
30152function execute(e, t, n, r) {
30153  for (var i = null != n && n.training, a = Array.isArray(e), o = a ? e : [e], s = o.map(function (e) {
30154    return e.name;
30155  }), l = [], u = t.names(), c = 0, p = s; c < p.length; c++) {
30156    var h = p[c];
30157    -1 !== u.indexOf(h) ? l.push(t.getValue(h)) : l.push(null);
30158  }
30159
30160  null != r && (r.maxNumTensors = -1 / 0, r.minNumTensors = 1 / 0);
30161  var d,
30162      f,
30163      g = s.join(",") + "|" + t.names().join(",");
30164
30165  if (null == cachedSorted[g]) {
30166    var m = getTopologicalSortAndRecipientCounts(o, t);
30167    d = m.sorted, f = m.recipientCounts, cachedSorted[g] = d, cachedRecipientCounts[g] = f;
30168  }
30169
30170  d = cachedSorted[g], f = {}, i || Object.assign(f, cachedRecipientCounts[g]);
30171
30172  for (var y = new FeedDict(t), v = 0; v < d.length; ++v) {
30173    if (null != r) {
30174      var b = (0, _tfjsCore.memory)().numTensors;
30175      b > r.maxNumTensors && (r.maxNumTensors = b), b < r.minNumTensors && (r.minNumTensors = b);
30176    }
30177
30178    var w = d[v],
30179        z = w.sourceLayer;
30180
30181    if (!(z instanceof InputLayer)) {
30182      for (var S = [], A = [], _ = [], I = !1, C = 0, E = w.inputs; C < E.length; C++) {
30183        var N = E[C],
30184            k = y.getValue(N),
30185            x = y.getMask(N);
30186        S.push(k), A.push(x), null != x && (I = !0), i || (f[N.name]--, 0 !== f[N.name] || t.hasKey(N) || -1 !== s.indexOf(N.name) || k.isDisposed || !0 === N.sourceLayer.stateful || _.push(k));
30187      }
30188
30189      I && ((n = n || {}).mask = A[0]);
30190      var L = toList(z.apply(S, n)),
30191          T = null;
30192      z.supportsMasking && (T = z.computeMask(S, A));
30193
30194      for (var D = getNodeOutputs(w), O = Array.isArray(D) ? D : [D], R = 0; R < O.length; ++R) {
30195        y.hasKey(O[R]) || y.add(O[R], L[R], Array.isArray(T) ? T[0] : T);
30196        var M = s.indexOf(O[R].name);
30197        -1 !== M && (l[M] = L[R]);
30198      }
30199
30200      i || (0, _tfjsCore.dispose)(_);
30201    }
30202  }
30203
30204  return y.disposeMasks(), a ? l : l[0];
30205}
30206
30207function getTopologicalSortAndRecipientCounts(e, t) {
30208  _tfjsCore.util.assert(null != e && e.length > 0, function () {
30209    return "Expected at least one fetch, got none";
30210  });
30211
30212  var n = [],
30213      r = {};
30214
30215  if (1 === e.length) {
30216    var i = getTopologicalSortAndRecipientCountsForOneFetch(e[0], t);
30217    n = i.sorted, r = i.recipientMap;
30218  } else for (var a = new Set(), o = 0, s = e; o < s.length; o++) {
30219    for (var l = getTopologicalSortAndRecipientCountsForOneFetch(s[o], t), u = l.sorted, c = l.recipientMap, p = 0, h = u; p < h.length; p++) {
30220      var d = h[p];
30221      a.has(d.name) || (n.push(d), a.add(d.name));
30222    }
30223
30224    var f = function (e) {
30225      null == r[e] && (r[e] = new Set()), c[e].forEach(function (t) {
30226        return r[e].add(t);
30227      });
30228    };
30229
30230    for (var g in c) f(g);
30231  }
30232
30233  return {
30234    sorted: n,
30235    recipientCounts: recipientMap2Counts(r)
30236  };
30237}
30238
30239function recipientMap2Counts(e) {
30240  var t = {};
30241
30242  for (var n in e) t[n] = e[n].size;
30243
30244  return t;
30245}
30246
30247function getTopologicalSortAndRecipientCountsForOneFetch(e, t) {
30248  for (var n = new Set(), r = [], i = {}, a = 0, o = t.names(); a < o.length; a++) {
30249    var s = o[a];
30250    n.add(s);
30251  }
30252
30253  var l = [],
30254      u = [];
30255
30256  for (l.push(e); l.length > 0;) {
30257    var c = l[l.length - 1];
30258    if (n.has(c.name)) l.pop();else {
30259      var p = u[u.length - 1] === l.length - 1;
30260      if (0 === c.inputs.length || p) l.pop(), r.push(c), n.add(c.name), p && u.pop();else {
30261        u.push(l.length - 1);
30262
30263        for (var h = 0, d = c.inputs; h < d.length; h++) {
30264          var f = d[h];
30265          null == i[f.name] && (i[f.name] = new Set()), i[f.name].add(c.name), n.has(f.name) || l.push(f);
30266        }
30267      }
30268    }
30269  }
30270
30271  return {
30272    sorted: r,
30273    recipientMap: i
30274  };
30275}
30276
30277function getNodeOutputs(e) {
30278  var t;
30279  if (1 === e.sourceLayer.inboundNodes.length) t = e.sourceLayer.output;else {
30280    for (var n = null, r = 0; r < e.sourceLayer.inboundNodes.length; ++r) for (var i = 0, a = e.sourceLayer.inboundNodes[r].outputTensors; i < a.length; i++) {
30281      if (a[i].id === e.id) {
30282        n = r;
30283        break;
30284      }
30285    }
30286
30287    t = e.sourceLayer.getOutputAt(n);
30288  }
30289  return t;
30290}
30291
30292var Container = function (e) {
30293  function t(n) {
30294    var r = e.call(this, {}) || this;
30295
30296    if (r.containerNodes = new Set(), r.name = n.name, null == r.name) {
30297      var i = r.getClassName().toLowerCase();
30298      r.name = getUid(i);
30299    }
30300
30301    if (r.supportsMasking = !1, r.trainable_ = !0, Array.isArray(n.inputs) ? r.inputs = n.inputs.slice() : r.inputs = [n.inputs], Array.isArray(n.outputs) ? r.outputs = n.outputs.slice() : r.outputs = [n.outputs], unique(r.inputs).length !== r.inputs.length) throw new ValueError("The list of inputs passed to the model is redundant. All inputs should only appear once. Found: " + r.inputs.map(function (e) {
30302      return e.name;
30303    }));
30304    unique(r.outputs).length !== r.outputs.length && console.warn("The list of outputs passed to the model is redundant. All outputs should only appear once. Found: " + r.outputs.map(function (e) {
30305      return e.name;
30306    })), r.inputLayers = [], r.inputLayersNodeIndices = [], r.inputLayersTensorIndices = [], r.outputLayers = [], r.outputLayersNodeIndices = [], r.outputLayersTensorIndices = [], r.layers = [], r.internalContainerRefs = [];
30307
30308    for (var a = 0, o = r.outputs; a < o.length; a++) {
30309      var s = (C = o[a]).sourceLayer,
30310          l = C.nodeIndex,
30311          u = C.tensorIndex;
30312      r.outputLayers.push(s), r.outputLayersNodeIndices.push(l), r.outputLayersTensorIndices.push(u);
30313    }
30314
30315    for (var c = 0, p = r.inputs; c < p.length; c++) {
30316      s = (C = p[c]).sourceLayer, l = C.nodeIndex, u = C.tensorIndex;
30317      assert(0 === l, "input layer has >1 nodes"), assert(0 === u, "input layer has >1 tensors"), r.inputLayers.push(s), r.inputLayersNodeIndices.push(l), r.inputLayersTensorIndices.push(u);
30318    }
30319
30320    r.inputNames = [], r.outputNames = [], r.feedInputShapes = [], r.feedInputNames = [], r.feedOutputNames = [];
30321
30322    for (var h = 0; h < r.inputLayers.length; h++) {
30323      if (!((s = r.inputLayers[h]) instanceof InputLayer)) throw new TypeError("Input layers to a LayersModel must be InputLayer objects. Received inputs: " + n.inputs + ". Input " + h + " (0-based) originates from layer type " + s.getClassName() + ".");
30324      r.inputNames.push(s.name), r.feedInputShapes.push(s.batchInputShape), r.feedInputNames.push(s.name);
30325    }
30326
30327    for (var d = 0, f = r.outputLayers; d < f.length; d++) {
30328      s = f[d];
30329      r.outputNames.push(s.name);
30330    }
30331
30332    r.internalInputShapes = r.inputs.map(function (e) {
30333      return e.shape;
30334    }), r.internalOutputShapes = r.outputs.map(function (e) {
30335      return e.shape;
30336    });
30337
30338    for (var g = {}, m = {}, y = {}, v = {}, b = {}, w = [], z = function (e, n, i, a, o, s) {
30339      null != a && null != o && null != s || (a = e.sourceLayer, o = e.nodeIndex, s = e.tensorIndex);
30340      var l = a.inboundNodes[o];
30341      if (-1 !== i.indexOf(l)) throw new RuntimeError("The tensor " + e.name + ' at layer "' + a.name + '" is part of a cycle.');
30342
30343      if (-1 === n.indexOf(l)) {
30344        r.containerNodes.add(t.nodeKey(a, o)), (a.id in b) || (b[a.id] = Object.keys(b).length), -1 === i.indexOf(l) && i.push(l);
30345
30346        for (var u = l.inboundLayers.length, c = 0; c < u; c++) {
30347          var p = l.inputTensors[c],
30348              h = l.inboundLayers[c],
30349              d = l.nodeIndices[c],
30350              f = l.tensorIndices[c];
30351          z(p, n, i, h, d, f);
30352        }
30353
30354        for (n.push(l); i.indexOf(l) >= 0;) i.splice(i.indexOf(l), 1);
30355
30356        w.push(l);
30357      }
30358    }, S = [], A = [], _ = 0, I = r.outputs; _ < I.length; _++) {
30359      var C = I[_];
30360      z(C, S, A);
30361    }
30362
30363    for (var E = 0, N = w.slice().reverse(); E < N.length; E++) {
30364      m[(K = N[E]).id] = K, K.id in g || (g[K.id] = 0);
30365      var k = g[K.id],
30366          x = null == y[K.outboundLayer.id] ? 0 : y[K.outboundLayer.id];
30367      k = Math.max(k, x), y[K.outboundLayer.id] = k, v[K.outboundLayer.id] = K.outboundLayer, g[K.id] = k;
30368
30369      for (h = 0; h < K.inboundLayers.length; h++) {
30370        var L = K.inboundLayers[h],
30371            T = (l = K.nodeIndices[h], L.inboundNodes[l]),
30372            D = null == g[T.id] ? 0 : g[T.id];
30373        g[T.id] = Math.max(k + 1, D), m[T.id] = T;
30374      }
30375    }
30376
30377    var O = {};
30378
30379    for (var R in g) {
30380      (k = g[R]) in O || (O[k] = []), O[k].push(m[R]);
30381    }
30382
30383    var M = {};
30384
30385    for (var P in y) {
30386      (k = y[P]) in M || (M[k] = []), M[k].push(v[P]);
30387    }
30388
30389    var F = Object.keys(M).map(function (e) {
30390      return parseInt(e, 10);
30391    }).sort(reverseNumberCompare);
30392    r.layers = [];
30393
30394    for (var V = 0, B = F; V < B.length; V++) {
30395      var U = M[k = B[V]];
30396      U.sort(function (e, t) {
30397        var n = b[e.id],
30398            r = b[t.id];
30399        return n < r ? -1 : n > r ? 1 : 0;
30400      });
30401
30402      for (var j = 0, W = U; j < W.length; j++) {
30403        (s = W[j]) instanceof t && r.internalContainerRefs.push(s), r.layers.push(s);
30404      }
30405    }
30406
30407    r.layersByDepth = M, F = Object.keys(O).map(function (e) {
30408      return parseInt(e, 10);
30409    }).sort(reverseNumberCompare);
30410
30411    for (var $ = r.inputs.slice(), q = [], G = 0, H = F; G < H.length; G++) for (var J = 0, Z = O[k = H[G]]; J < Z.length; J++) {
30412      var K;
30413
30414      if (null != (s = (K = Z[J]).outboundLayer)) {
30415        for (var Y = 0, X = K.inputTensors; Y < X.length; Y++) {
30416          C = X[Y];
30417          if (-1 === $.indexOf(C)) throw new RuntimeError("Graph disconnected: cannot obtain value for tensor " + C + ' at layer "' + s.name + '". The following previous layers were accessed without issue: ' + q);
30418        }
30419
30420        for (var Q = 0, ee = K.outputTensors; Q < ee.length; Q++) {
30421          C = ee[Q];
30422          $.push(C);
30423        }
30424
30425        q.push(s.name);
30426      }
30427    }
30428
30429    r.nodesByDepth = O;
30430
30431    for (var te = r.layers.map(function (e) {
30432      return e.name;
30433    }), ne = function (e) {
30434      var t = te.filter(function (t) {
30435        return t === e;
30436      }).length;
30437      if (1 !== t) throw new RuntimeError('The name "' + e + '" is used ' + t + " times in the model. All layer names should be unique. Layer names: " + JSON.stringify(te));
30438    }, re = 0, ie = te; re < ie.length; re++) {
30439      ne(ie[re]);
30440    }
30441
30442    return r.outboundNodes = [], r.inboundNodes = [], new Node({
30443      outboundLayer: r,
30444      inboundLayers: [],
30445      nodeIndices: [],
30446      tensorIndices: [],
30447      inputTensors: r.inputs,
30448      outputTensors: r.outputs,
30449      inputMasks: r.inputs.map(function (e) {
30450        return null;
30451      }),
30452      outputMasks: r.outputs.map(function (e) {
30453        return null;
30454      }),
30455      inputShapes: r.inputs.map(function (e) {
30456        return e.shape;
30457      }),
30458      outputShapes: r.outputs.map(function (e) {
30459        return e.shape;
30460      })
30461    }), r.built = !0, r._refCount = 1, r;
30462  }
30463
30464  return __extends(t, e), t.prototype.assertNotDisposed = function () {
30465    if (0 === this._refCount) throw new Error("Container '" + this.name + "' is already disposed.");
30466  }, t.prototype.dispose = function () {
30467    this.assertNotDisposed();
30468    var e = {
30469      refCountAfterDispose: null,
30470      numDisposedVariables: 0
30471    };
30472
30473    if (0 == --this._refCount) {
30474      for (var t = 0, n = this.layers; t < n.length; t++) {
30475        var r = n[t];
30476        e.numDisposedVariables += r.dispose().numDisposedVariables;
30477      }
30478
30479      for (var i = 0, a = this.internalContainerRefs; i < a.length; i++) {
30480        var o = a[i];
30481        e.numDisposedVariables += o.dispose().numDisposedVariables;
30482      }
30483    }
30484
30485    return e.refCountAfterDispose = this._refCount, e;
30486  }, Object.defineProperty(t.prototype, "trainable", {
30487    get: function () {
30488      return this.trainable_;
30489    },
30490    set: function (e) {
30491      this.layers.forEach(function (t) {
30492        t._trainableWeights.forEach(function (t) {
30493          return t.trainable = e;
30494        });
30495      }), this.trainable_ = e;
30496    },
30497    enumerable: !0,
30498    configurable: !0
30499  }), Object.defineProperty(t.prototype, "trainableWeights", {
30500    get: function () {
30501      if (this._trainableWeights.length > 0) throw new ValueError("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array.");
30502      if (!this.trainable) return [];
30503
30504      for (var e = [], t = 0, n = this.layers; t < n.length; t++) {
30505        var r = n[t];
30506        e = e.concat(r.trainableWeights);
30507      }
30508
30509      return e;
30510    },
30511    enumerable: !0,
30512    configurable: !0
30513  }), Object.defineProperty(t.prototype, "nonTrainableWeights", {
30514    get: function () {
30515      for (var e = [], t = 0, n = this.layers; t < n.length; t++) {
30516        var r = n[t];
30517        e.push.apply(e, r.nonTrainableWeights);
30518      }
30519
30520      if (!this.trainable) {
30521        for (var i = [], a = 0, o = this.layers; a < o.length; a++) {
30522          r = o[a];
30523          i.push.apply(i, r.trainableWeights);
30524        }
30525
30526        return i.concat(e);
30527      }
30528
30529      return e;
30530    },
30531    enumerable: !0,
30532    configurable: !0
30533  }), Object.defineProperty(t.prototype, "weights", {
30534    get: function () {
30535      return this.trainableWeights.concat(this.nonTrainableWeights);
30536    },
30537    enumerable: !0,
30538    configurable: !0
30539  }), t.prototype.loadWeights = function (e, t) {
30540    void 0 === t && (t = !0);
30541
30542    for (var n = {}, r = 0, i = 0, a = this.layers; i < a.length; i++) for (var o = 0, s = a[i].weights; o < s.length; o++) {
30543      var l = s[o];
30544      if (null != n[l.originalName]) throw new ValueError("Duplicate weight name: " + l.originalName);
30545      n[l.originalName] = l, r++;
30546    }
30547
30548    var u = [];
30549
30550    for (var c in e) {
30551      if (null != n[c]) u.push([n[c], e[c]]);else if (t) throw new ValueError("Provided weight data has no target variable: " + c);
30552      delete n[c];
30553    }
30554
30555    if (t) {
30556      var p = [];
30557
30558      for (var h in n) p.push(h);
30559
30560      if (p.length > 0) throw new ValueError(p.length + " of " + r + " weights are not set: " + p);
30561    }
30562
30563    batchSetValue(u);
30564  }, t.prototype.updatedConfig = function () {
30565    var e = this.getConfig(),
30566        t = {};
30567    return t.className = this.getClassName(), t.config = e, t.kerasVersion = "tfjs-layers " + version, t.backend = "TensorFlow.js", t;
30568  }, t.prototype.toJSON = function (e, t) {
30569    void 0 === t && (t = !0);
30570    var n = convertTsToPythonic(this.updatedConfig());
30571    return t ? JSON.stringify(n) : n;
30572  }, t.prototype.call = function (e, t) {
30573    var n = this;
30574    return (0, _tfjsCore.tidy)(function () {
30575      e = toList(e);
30576
30577      for (var r = new FeedDict(), i = 0; i < n.inputs.length; ++i) r.add(n.inputs[i], e[i]);
30578
30579      return execute(n.outputs, r, t);
30580    });
30581  }, t.prototype.computeMask = function (e, t) {
30582    var n = this;
30583    return (0, _tfjsCore.tidy)(function () {
30584      var r;
30585      return e = toList(e), r = null == t ? pyListRepeat(null, e.length) : toList(t), n.runInternalGraph(e, r)[1];
30586    });
30587  }, t.prototype.computeOutputShape = function (e) {
30588    var t = normalizeShapeList(e);
30589    if (t.length !== this.inputLayers.length) throw new ValueError("Invalid inputShape argument " + e + ": model has " + this.inputLayers.length + " tensor inputs.");
30590
30591    for (var n = {}, r = 0; r < t.length; r++) {
30592      var i = this.inputLayers[r],
30593          a = t[r];
30594      n[A = i.name + "_0_0"] = a;
30595    }
30596
30597    var o = Object.keys(this.nodesByDepth).map(function (e) {
30598      return parseInt(e, 10);
30599    }).sort(reverseNumberCompare);
30600    if (o.length > 1) for (var s = 0, l = o; s < l.length; s++) for (var u = l[s], c = 0, p = this.nodesByDepth[u]; c < p.length; c++) {
30601      var h = p[c];
30602      i = h.outboundLayer;
30603
30604      if (-1 === this.inputLayers.map(function (e) {
30605        return e.id;
30606      }).indexOf(i.id)) {
30607        for (var d = [], f = 0; f < h.inboundLayers.length; f++) {
30608          var g = h.inboundLayers[f],
30609              m = h.nodeIndices[f],
30610              y = h.tensorIndices[f],
30611              v = n[A = g.name + "_" + m + "_" + y];
30612          d.push(v);
30613        }
30614
30615        var b = normalizeShapeList(i.computeOutputShape(singletonOrArray(d))),
30616            w = i.inboundNodes.indexOf(h);
30617
30618        for (f = 0; f < b.length; f++) {
30619          n[A = i.name + "_" + w + "_" + f] = b[f];
30620        }
30621      }
30622    }
30623    var z = [],
30624        S = [];
30625
30626    for (r = 0; r < this.outputLayers.length; r++) {
30627      i = this.outputLayers[r], w = this.outputLayersNodeIndices[r], y = this.outputLayersTensorIndices[r];
30628      var A = i.name + "_" + w + "_" + y;
30629      S.push(A);
30630    }
30631
30632    for (r = 0; r < S.length; r++) {
30633      var _ = S[r];
30634      assert(_ in n), z.push(n[_]);
30635    }
30636
30637    return singletonOrArray(z);
30638  }, t.prototype.runInternalGraph = function (e, t) {
30639    null == t && (t = pyListRepeat(null, e.length));
30640
30641    for (var n = {}, r = 0; r < this.inputs.length; ++r) {
30642      var i = this.inputs[r],
30643          a = e[r],
30644          o = t[r];
30645      n[i.id] = [a, o];
30646    }
30647
30648    for (var s = 0, l = Object.keys(this.nodesByDepth).map(function (e) {
30649      return parseInt(e, 10);
30650    }).sort(reverseNumberCompare); s < l.length; s++) for (var u = l[s], c = 0, p = this.nodesByDepth[u]; c < p.length; c++) {
30651      for (var h = p[c], d = h.outboundLayer, f = h.inputTensors, g = h.outputTensors, m = new Array(), y = 0, v = f; y < v.length; y++) {
30652        (i = v[y]).id in n && m.push(n[i.id]);
30653      }
30654
30655      if (m.length === f.length) {
30656        var b = {},
30657            w = void 0,
30658            z = void 0,
30659            S = void 0,
30660            A = void 0;
30661
30662        if (null != h.callArgs && (b = h.callArgs), 1 === m.length) {
30663          var _ = m[0],
30664              I = _[0],
30665              C = _[1];
30666          null == b.mask && (b.mask = C), S = toList(d.call(I, b)), A = toList(d.computeMask(I, C)), w = [I], z = [C];
30667        } else w = m.map(function (e) {
30668          return e[0];
30669        }), z = m.map(function (e) {
30670          return e[1];
30671        }), null == b.mask && (b.mask = z), S = toList(d.call(w, b)), A = toList(d.computeMask(w, z));
30672
30673        if (d.activityRegularizer) throw new NotImplementedError("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet.");
30674
30675        for (r = 0; r < g.length; ++r) {
30676          i = g[r], a = S[r], o = A[r];
30677          n[i.id] = [a, o];
30678        }
30679      }
30680    }
30681
30682    for (var E = [], N = [], k = [], x = 0, L = this.outputs; x < L.length; x++) {
30683      assert((i = L[x]).id in n, "Could not compute output " + i.name + " : " + i.id);
30684      var T = n[i.id],
30685          D = T[0];
30686      o = T[1];
30687      k.push(D.shape), E.push(D), N.push(o);
30688    }
30689
30690    return [E, N, k];
30691  }, t.prototype.buildNodeConversionMap = function (e) {
30692    for (var n, r = {}, i = 0, a = this.layers; i < a.length; i++) {
30693      var o = a[i];
30694      n = o instanceof t ? 1 : 0;
30695
30696      for (var s = 0; s < o.inboundNodes.length; s++) {
30697        var l = t.nodeKey(o, s);
30698        this.containerNodes.has(l) && (r[l] = n, n += 1);
30699      }
30700    }
30701
30702    return r;
30703  }, t.prototype.getLayer = function (e, t) {
30704    if (null != t) {
30705      if (this.layers.length <= t) throw new ValueError("Was asked to retrieve layer at index " + t + ", but model only has " + this.layers.length + " layer(s).");
30706      return this.layers[t];
30707    }
30708
30709    if (null == e) throw new ValueError("Provide either a layer name or layer index");
30710
30711    for (var n = 0, r = this.layers; n < r.length; n++) {
30712      var i = r[n];
30713      if (i.name === e) return i;
30714    }
30715
30716    throw new ValueError("No such layer: " + e);
30717  }, t.prototype.calculateLosses = function () {
30718    var e = this;
30719    return (0, _tfjsCore.tidy)(function () {
30720      for (var n = [], r = 0, i = e.layers; r < i.length; r++) for (var a = i[r], o = 0; o < a.inboundNodes.length; ++o) {
30721        var s = t.nodeKey(a, o);
30722        e.containerNodes.has(s) && n.push.apply(n, a.calculateLosses());
30723      }
30724
30725      return n;
30726    });
30727  }, t.prototype.getConfig = function () {
30728    for (var e = {
30729      name: this.name
30730    }, n = this.buildNodeConversionMap(this.layers), r = [], i = 0, a = this.layers; i < a.length; i++) {
30731      for (var o = (w = a[i]).getClassName(), s = w.getConfig(), l = [], u = 0; u < w.inboundNodes.length; u++) {
30732        var c = w.inboundNodes[u],
30733            p = t.nodeKey(w, u),
30734            h = {};
30735
30736        if (this.containerNodes.has(p)) {
30737          if (c.callArgs) try {
30738            JSON.stringify(c.callArgs), h = c.callArgs;
30739          } catch (e) {
30740            console.warn("Layer " + w.name + " was passed non-serializable keyword arguments: " + c.callArgs + ". They will not be included in the serialized model (and thus will be missing at deserialization time)."), h = {};
30741          }
30742
30743          if (c.inboundLayers.length > 0) {
30744            for (var d = [], f = 0; f < c.inboundLayers.length; f++) {
30745              var g = c.inboundLayers[f],
30746                  m = c.nodeIndices[f],
30747                  y = c.tensorIndices[f];
30748              null == (S = n[t.nodeKey(g, m)]) && (S = 0), d.push([g.name, S, y, h]);
30749            }
30750
30751            l.push(d);
30752          }
30753        }
30754      }
30755
30756      var v = {};
30757      v.name = w.name, v.className = o, v.config = s, v.inboundNodes = l, r.push(v);
30758    }
30759
30760    e.layers = r;
30761    var b = [];
30762
30763    for (f = 0; f < this.inputLayers.length; f++) {
30764      var w = this.inputLayers[f];
30765      m = this.inputLayersNodeIndices[f], p = t.nodeKey(w, m);
30766
30767      if (this.containerNodes.has(p)) {
30768        null !== (S = n[p]) && void 0 !== S || (S = 0);
30769        y = this.inputLayersTensorIndices[f];
30770        b.push([w.name, S, y]);
30771      }
30772    }
30773
30774    e.inputLayers = b;
30775    var z = [];
30776
30777    for (f = 0; f < this.outputLayers.length; f++) {
30778      w = this.outputLayers[f], m = this.outputLayersNodeIndices[f], p = t.nodeKey(w, m);
30779
30780      if (this.containerNodes.has(p)) {
30781        var S;
30782        null !== (S = n[p]) && void 0 !== S || (S = 0);
30783        y = this.outputLayersTensorIndices[f];
30784        z.push([w.name, S, y]);
30785      }
30786    }
30787
30788    return e.outputLayers = z, e;
30789  }, t.fromConfig = function (e, t, n, r) {
30790    void 0 === n && (n = {}), void 0 === r && (r = !1);
30791    var i = {},
30792        a = {};
30793
30794    function o(e, t) {
30795      e.name in a ? a[e.name].push(t) : a[e.name] = [t];
30796    }
30797
30798    function s(e, t) {
30799      for (var n, r = [], a = 0, s = t; a < s.length; a++) {
30800        var l = s[a],
30801            u = l[0],
30802            c = l[1],
30803            p = l[2];
30804        if (n = null == l[3] ? {} : l[3], !(u in i)) return void o(e, t);
30805        var h = i[u];
30806        if (h.inboundNodes.length <= c) return void o(e, t);
30807        var d = h.inboundNodes[c];
30808        r.push(d.outputTensors[p]);
30809      }
30810
30811      r.length > 0 && e.apply(singletonOrArray(r), n);
30812    }
30813
30814    function l(e) {
30815      var n = e.name,
30816          a = deserialize(e, null != t.customObjects ? t.customObjects : {});
30817      a.setFastWeightInitDuringBuild(r), i[n] = a, e.inboundNodes.forEach(function (e) {
30818        if (!(e instanceof Array)) throw new ValueError("Corrupted configuration, expected array for nodeData: " + e);
30819        o(a, e);
30820      });
30821    }
30822
30823    for (var u = t.name, c = t.layers, p = 0, h = c; p < h.length; p++) {
30824      l(g = h[p]);
30825    }
30826
30827    for (; !isObjectEmpty(a);) for (var d = 0, f = c; d < f.length; d++) {
30828      var g = f[d];
30829
30830      if ((k = i[g.name]).name in a) {
30831        var m = a[k.name];
30832        delete a[k.name];
30833
30834        for (var y = 0, v = m; y < v.length; y++) {
30835          s(k, v[y]);
30836        }
30837      }
30838    }
30839
30840    for (var b = [], w = [], z = 0, S = t.inputLayers; z < S.length; z++) {
30841      var A = (g = S[z])[0],
30842          _ = g[1],
30843          I = g[2];
30844      assert(A in i);
30845      var C = (k = i[A]).inboundNodes[_].outputTensors;
30846      b.push(C[I]);
30847    }
30848
30849    for (var E = 0, N = t.outputLayers; E < N.length; E++) {
30850      A = (g = N[E])[0], _ = g[1], I = g[2];
30851      assert(A in i);
30852      var k;
30853      C = (k = i[A]).inboundNodes[_].outputTensors;
30854      w.push(C[I]);
30855    }
30856
30857    return new e({
30858      inputs: b,
30859      outputs: w,
30860      name: u
30861    });
30862  }, Object.defineProperty(t.prototype, "stateful", {
30863    get: function () {
30864      if (this._stateful) throw new ValueError("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false.");
30865
30866      for (var e = 0, t = this.layers; e < t.length; e++) {
30867        if (t[e].stateful) return !0;
30868      }
30869
30870      return !1;
30871    },
30872    enumerable: !0,
30873    configurable: !0
30874  }), t.prototype.resetStates = function () {
30875    var e = this;
30876    (0, _tfjsCore.tidy)(function () {
30877      e.layers.forEach(function (e) {
30878        e.stateful && e.resetStates();
30879      });
30880    });
30881  }, t;
30882}(Layer);
30883
30884function standardizeSampleOrClassWeights(e, t, n) {
30885  var r = t.length;
30886  if (null == e || Array.isArray(e) && 0 === e.length) return t.map(function (e) {
30887    return null;
30888  });
30889  if (1 === r) return Array.isArray(e) && 1 === e.length ? e : "object" == typeof e && t[0] in e ? [e[t[0]]] : [e];
30890
30891  if (Array.isArray(e)) {
30892    if (e.length !== r) throw new Error("Provided " + n + " is an array of " + e.length + " element(s), but the model has " + r + " outputs. Make sure a set of weights is provided for each model output.");
30893    return e;
30894  }
30895
30896  if ("object" == typeof e && Object.keys(e).length > 0 && "object" == typeof e[Object.keys(e)[0]]) {
30897    var i = [];
30898    return t.forEach(function (t) {
30899      t in e ? i.push(e[t]) : i.push(null);
30900    }), i;
30901  }
30902
30903  throw new Error("The model has multiple (" + r + ") outputs, so " + n + " must be either an array with " + r + " elements or an object with " + t + " keys. Provided " + n + " not understood: " + JSON.stringify(e));
30904}
30905
30906function standardizeClassWeights(e, t) {
30907  return standardizeSampleOrClassWeights(e, t, "classWeight");
30908}
30909
30910function standardizeWeights(e, t, n, r) {
30911  return __awaiter(this, void 0, void 0, function () {
30912    var i, a, o, s, l;
30913    return __generator(this, function (u) {
30914      switch (u.label) {
30915        case 0:
30916          if (null != t || null != r) throw new Error("Support sampleWeight is not implemented yet");
30917          return null == n ? [3, 2] : (i = (0, _tfjsCore.tidy)(function () {
30918            if (1 === e.shape.length) return e.clone();
30919
30920            if (2 === e.shape.length) {
30921              if (e.shape[1] > 1) {
30922                return e.argMax(1);
30923              }
30924
30925              if (1 === e.shape[1]) return e.reshape([e.shape[0]]);
30926              throw new Error("Encountered unexpected last-dimension size (" + e.shape[1] + ") during handling of class weights. The size is expected to be >= 1.");
30927            }
30928
30929            throw new Error("Unexpected rank of target (y) tensor (" + e.rank + ") during handling of class weights. The rank is expected to be 1 or 2.");
30930          }), s = (o = Array).from, [4, i.data()]);
30931
30932        case 1:
30933          return a = s.apply(o, [u.sent()]), (0, _tfjsCore.dispose)(i), l = [], a.forEach(function (e) {
30934            if (null == n[e]) throw new Error("classWeight must contain all classes in the training data. The class " + e + " exists in the data but not in classWeight");
30935            l.push(n[e]);
30936          }), [2, (0, _tfjsCore.tensor1d)(l, "float32")];
30937
30938        case 2:
30939          return [2, null];
30940      }
30941    });
30942  });
30943}
30944
30945function computeWeightedLoss(e, t) {
30946  return (0, _tfjsCore.mul)(e, t);
30947}
30948
30949var DEFAULT_VALIDATION_BATCH_SIZE = 32;
30950
30951function standardizeDataIteratorOutput(e, t) {
30952  var n,
30953      r,
30954      i = t;
30955  n = i.xs, r = i.ys, _tfjsCore.util.assert(null != n && null != r, function () {
30956    return "A Dataset iterator for fitDataset() is expected to generate objects of the form `{xs: xVal, ys: yVal}`, where the two values may be `tf.Tensor`, an array of Tensors, or a map of string to Tensor.  The provided Dataset instead generates " + t;
30957  });
30958  var a = flattenTensorOrArrayOrMap("input", e.inputNames, n),
30959      o = flattenTensorOrArrayOrMap("output", e.outputNames, r),
30960      s = a[0].shape[0];
30961  _tfjsCore.util.assert(a.length === e.inputs.length, function () {
30962    return "LayersModel has " + e.inputs.length + " inputs, but the dataset provides " + a.length + " inputs.  (Expected input keys: " + JSON.stringify(e.inputNames) + ")";
30963  }), _tfjsCore.util.assert(o.length === e.outputs.length, function () {
30964    return "LayersModel has " + e.outputs.length + " outputs, but the dataset provides " + o.length + " outputs.  (Expected output keys: " + JSON.stringify(e.outputNames) + ")";
30965  });
30966
30967  for (var l = function (t) {
30968    _tfjsCore.util.assert(a[t].shape[0] === s, function () {
30969      return "Batch size mismatch: input " + e.inputNames[t] + " has " + a[t].shape[0] + "; expected  " + s + " based on input " + e.inputNames[0] + ".";
30970    });
30971  }, u = 0; u < a.length; u++) l(u);
30972
30973  for (var c = function (t) {
30974    _tfjsCore.util.assert(o[t].shape[0] === s, function () {
30975      return "Batch size mismatch: output " + e.outputNames[t] + " has " + o[t].shape[0] + "; expected  " + s + " based on input " + e.inputNames[0] + ".";
30976    });
30977  }, p = 0; p < o.length; p++) c(p);
30978
30979  return {
30980    xs: a,
30981    ys: o
30982  };
30983}
30984
30985function flattenTensorOrArrayOrMap(e, t, n) {
30986  if (n instanceof _tfjsCore.Tensor) return [n];
30987  if (Array.isArray(n)) return _tfjsCore.util.assert(n.length === t.length, function () {
30988    return "Received an array of " + n.length + " Tensors, but expected " + t.length + " to match the " + e + " keys " + t + ".";
30989  }), n;
30990
30991  for (var r = [], i = 0, a = t; i < a.length; i++) {
30992    var o = a[i];
30993    if (null == n[o]) throw new ValueError("The feature data generated by the dataset lacks the required " + e + " key '" + o + "'.");
30994    r.push(n[o]);
30995  }
30996
30997  return r;
30998}
30999
31000function standardizeTensorValidationData(e) {
31001  if (3 === e.length) throw new NotImplementedError("Validation with sample weights is not implemented yet.");
31002  return {
31003    xs: e[0],
31004    ys: e[1]
31005  };
31006}
31007
31008function fitDataset(e, t, n) {
31009  return __awaiter(this, void 0, void 0, function () {
31010    var r, i, a, o, s, l, u, c, p, h, d, f, g, m, y, v, b, w, z, S, A, _, I, C, E, N, k, x, L, T, D, O, R, M;
31011
31012    return __generator(this, function (P) {
31013      switch (P.label) {
31014        case 0:
31015          if (r = null != n.batchesPerEpoch, _tfjsCore.util.assert(null != e.optimizer, function () {
31016            return "You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).";
31017          }), _tfjsCore.util.assert(null != n, function () {
31018            return "For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.";
31019          }), _tfjsCore.util.assert(null != n.epochs && n.epochs > 0 && Number.isInteger(n.epochs), function () {
31020            return "For fitDataset(), config.epochs is expected to be a positive integer, but got " + n.epochs;
31021          }), _tfjsCore.util.assert(!r || n.batchesPerEpoch > 0 && Number.isInteger(n.batchesPerEpoch), function () {
31022            return "For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got " + n.batchesPerEpoch;
31023          }), _tfjsCore.util.assert(null == n.validationSplit, function () {
31024            return "`validationSplit` is not supported by `fitDataset()`. Use validationData instead.";
31025          }), e.isTraining) throw new Error("Cannot start training because another fit() call is ongoing.");
31026          e.isTraining = !0, P.label = 1;
31027
31028        case 1:
31029          return P.trys.push([1,, 26, 27]), i = null != n.validationData, a = void 0, o = void 0, i && (isDatasetObject(n.validationData) ? _tfjsCore.util.assert(null == n.validationBatches || n.validationBatches > 0 && Number.isInteger(n.validationBatches), function () {
31030            return "For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got " + n.validationBatches;
31031          }) : (s = standardizeTensorValidationData(n.validationData), a = s.xs, o = s.ys)), l = e.makeTrainFunction(), u = e.getDedupedMetricsNames(), c = void 0, c = i ? u.slice().concat(u.map(function (e) {
31032            return "val_" + e;
31033          })) : u.slice(), p = standardizeCallbacks(n.callbacks, n.yieldEvery), h = null == n.verbose ? 1 : n.verbose, d = configureCallbacks(p, h, n.epochs, null, null, getStepsPerEpoch(t, n), null, i, c), f = d.callbackList, g = d.history, f.setModel(e), e.history = g, [4, f.onTrainBegin()];
31034
31035        case 2:
31036          return P.sent(), e.stopTraining_ = !1, m = null == n.initialEpoch ? 0 : n.initialEpoch, [4, t.iterator()];
31037
31038        case 3:
31039          y = P.sent(), P.label = 4;
31040
31041        case 4:
31042          return m < n.epochs ? (v = {}, [4, f.onEpochBegin(m)]) : [3, 23];
31043
31044        case 5:
31045          return P.sent(), b = 0, w = 0, r ? [3, 7] : [4, t.iterator()];
31046
31047        case 6:
31048          y = P.sent(), P.label = 7;
31049
31050        case 7:
31051          return !r || b < n.batchesPerEpoch ? [4, y.next()] : [3, 21];
31052
31053        case 8:
31054          return z = P.sent(), r && z.done ? (console.warn("You provided `batchesPerEpoch` as " + n.batchesPerEpoch + ", but your dataset iterator ran out of data after " + b + " batches; interrupting training. Make sure that your dataset can generate at least `batchesPerEpoch * epochs` batches (in this case, " + n.batchesPerEpoch * n.epochs + " batches). You may need to use the repeat() function when building your dataset."), [3, 21]) : null == z.value ? [3, 15] : (S = standardizeDataIteratorOutput(e, z.value), A = S.xs, _ = S.ys, (I = {}).batch = w, I.size = A[0].shape[0], [4, f.onBatchBegin(w, I)]);
31055
31056        case 9:
31057          if (P.sent(), C = [], null == n.classWeight) return [3, 13];
31058          E = standardizeClassWeights(n.classWeight, e.outputNames), M = 0, P.label = 10;
31059
31060        case 10:
31061          return M < E.length ? (k = (N = C).push, [4, standardizeWeights(_[M], null, E[M])]) : [3, 13];
31062
31063        case 11:
31064          k.apply(N, [P.sent()]), P.label = 12;
31065
31066        case 12:
31067          return ++M, [3, 10];
31068
31069        case 13:
31070          for (x = A.concat(_).concat(C), L = l(x), (0, _tfjsCore.dispose)(x), M = 0; M < u.length; ++M) T = u[M], D = L[M], I[T] = D, (0, _tfjsCore.keep)(D);
31071
31072          return [4, f.onBatchEnd(w, I)];
31073
31074        case 14:
31075          P.sent(), disposeTensorsInLogs(I), w++, b++, P.label = 15;
31076
31077        case 15:
31078          return (r ? b >= n.batchesPerEpoch : z.done) ? i ? (O = void 0, isDatasetObject(n.validationData) ? (R = toList, [4, e.evaluateDataset(n.validationData, {
31079            batches: n.validationBatches
31080          })]) : [3, 17]) : [3, 19] : [3, 20];
31081
31082        case 16:
31083          return O = R.apply(void 0, [P.sent()]), [3, 18];
31084
31085        case 17:
31086          O = toList(e.evaluate(a, o, {
31087            batchSize: null == n.validationBatchSize ? DEFAULT_VALIDATION_BATCH_SIZE : n.validationBatchSize,
31088            verbose: 0
31089          })), P.label = 18;
31090
31091        case 18:
31092          for (M = 0; M < e.metricsNames.length; ++M) v["val_" + e.metricsNames[M]] = O[M];
31093
31094          P.label = 19;
31095
31096        case 19:
31097          return [3, 21];
31098
31099        case 20:
31100          return e.stopTraining_ ? [3, 21] : [3, 7];
31101
31102        case 21:
31103          return [4, f.onEpochEnd(m, v)];
31104
31105        case 22:
31106          return P.sent(), m++, e.stopTraining_ ? [3, 23] : [3, 4];
31107
31108        case 23:
31109          return [4, f.onTrainEnd()];
31110
31111        case 24:
31112          return P.sent(), [4, e.history.syncData()];
31113
31114        case 25:
31115          return P.sent(), [2, e.history];
31116
31117        case 26:
31118          return e.isTraining = !1, [7];
31119
31120        case 27:
31121          return [2];
31122      }
31123    });
31124  });
31125}
31126
31127function getStepsPerEpoch(e, t) {
31128  var n = null;
31129  return null != t.batchesPerEpoch ? n = t.batchesPerEpoch : Number.isFinite(e.size) && (n = e.size), n;
31130}
31131
31132function isDatasetObject(e) {
31133  return "function" == typeof e.iterator;
31134}
31135
31136function isLazyIteratorObject(e) {
31137  return "function" == typeof e.next;
31138}
31139
31140function evaluateDataset(e, t, n) {
31141  return __awaiter(this, void 0, void 0, function () {
31142    var r, i, a, o, s, l, u, c, p, h;
31143    return __generator(this, function (d) {
31144      switch (d.label) {
31145        case 0:
31146          if (r = null != (n = n || {}).batches, i = e.testFunction, a = [], n.verbose > 0) throw new NotImplementedError("Verbose mode is not implemented yet.");
31147          return _tfjsCore.util.assert(!r || n.batches > 0 && Number.isInteger(n.batches), function () {
31148            return "Test loop expects `batches` to be a positive integer, but received " + JSON.stringify(n.batches);
31149          }), isLazyIteratorObject(t) ? (s = t, [3, 3]) : [3, 1];
31150
31151        case 1:
31152          return [4, t.iterator()];
31153
31154        case 2:
31155          s = d.sent(), d.label = 3;
31156
31157        case 3:
31158          o = s, l = 0, u = 0, c = function () {
31159            var t;
31160            return __generator(this, function (s) {
31161              switch (s.label) {
31162                case 0:
31163                  return [4, o.next()];
31164
31165                case 1:
31166                  return t = s.sent(), a = (0, _tfjsCore.tidy)(function () {
31167                    if (t.value) {
31168                      var n = standardizeDataIteratorOutput(e, t.value),
31169                          r = n.xs,
31170                          o = n.ys,
31171                          s = r.concat(o),
31172                          c = (0, _tfjsCore.tidy)(function () {
31173                        return i(s);
31174                      });
31175                      if ((0, _tfjsCore.dispose)(s), 0 === u) for (var p = 0; p < c.length; ++p) a.push((0, _tfjsCore.scalar)(0));
31176
31177                      var h = s[0].shape[0],
31178                          d = function (e) {
31179                        var t = c[e],
31180                            n = a[e];
31181                        a[e] = (0, _tfjsCore.tidy)(function () {
31182                          return (0, _tfjsCore.add)(a[e], (0, _tfjsCore.mul)(h, t));
31183                        }), u > 0 && (0, _tfjsCore.dispose)(n);
31184                      };
31185
31186                      for (p = 0; p < c.length; ++p) d(p);
31187
31188                      (0, _tfjsCore.dispose)(c), l += h, ++u;
31189                    }
31190
31191                    return a;
31192                  }), t.done ? (r && console.warn("Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least `batches` batches (in this case, " + n.batches + " batches). You may need to use the repeat() function when building your dataset."), [2, "break"]) : [2];
31193              }
31194            });
31195          }, d.label = 4;
31196
31197        case 4:
31198          return !r || u < n.batches ? [5, c()] : [3, 6];
31199
31200        case 5:
31201          return "break" === d.sent() ? [3, 6] : [3, 4];
31202
31203        case 6:
31204          for (p = 0; p < a.length; ++p) h = a[p], a[p] = (0, _tfjsCore.div)(a[p], l), (0, _tfjsCore.dispose)(h);
31205
31206          return [2, singletonOrArray(a)];
31207      }
31208    });
31209  });
31210}
31211
31212function checkBatchSize(e) {
31213  _tfjsCore.util.assert(e > 0 && Number.isInteger(e), function () {
31214    return "batchSize is required to be a positive integer, but got " + e;
31215  });
31216}
31217
31218function sliceArrays(e, t, n) {
31219  return null == e ? [null] : Array.isArray(e) ? e.map(function (e) {
31220    return sliceAlongFirstAxis(e, t, n - t);
31221  }) : sliceAlongFirstAxis(e, t, n - t);
31222}
31223
31224function sliceArraysByIndices(e, t) {
31225  return (0, _tfjsCore.tidy)(function () {
31226    return null == e ? null : Array.isArray(e) ? e.map(function (e) {
31227      return sliceArraysByIndices(e, t);
31228    }) : gather$1(e, "int32" === t.dtype ? t : t.toInt());
31229  });
31230}
31231
31232function makeBatches(e, t) {
31233  for (var n = [], r = 0, i = null; r < e;) (i = r + t) >= e && (i = e), n.push([r, i]), r = i;
31234
31235  return n;
31236}
31237
31238function fitLoop(e, t, n, r, i, a, o, s, l, u, c, p, h, d, f) {
31239  return __awaiter(this, void 0, void 0, function () {
31240    var g, m, y, v, b, w, z, S;
31241    return __generator(this, function (A) {
31242      switch (A.label) {
31243        case 0:
31244          if (null == i && (i = 32), null == a && (a = 1), null == c && (c = !0), null == h && (h = 0), g = !1, null != l && null != u && (g = !0), null != f && (g = !0, null == d)) throw new ValueError("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set.");
31245          return null != (m = e.checkNumSamples(n, i, d, "steps_per_epoch")) && (y = range(0, m)), null == o && (o = 1), v = configureCallbacks(s, o, a, h, m, d, i, g, p), b = v.callbackList, w = v.history, b.setModel(e), e.history = w, [4, b.onTrainBegin()];
31246
31247        case 1:
31248          A.sent(), e.stopTraining_ = !1, z = function (a) {
31249            var o, s, p, h, f;
31250            return __generator(this, function (v) {
31251              switch (v.label) {
31252                case 0:
31253                  return [4, b.onEpochBegin(a)];
31254
31255                case 1:
31256                  if (v.sent(), o = {}, null == d) return [3, 2];
31257                  throw new NotImplementedError("stepsPerEpoch mode is not implemented yet.");
31258
31259                case 2:
31260                  if ("batch" === c) throw new NotImplementedError("batch shuffling is not implemneted yet");
31261                  c && _tfjsCore.util.shuffle(y), s = (0, _tfjsCore.tensor1d)(y), p = makeBatches(m, i), h = function (a) {
31262                    var c;
31263                    return __generator(this, function (h) {
31264                      switch (h.label) {
31265                        case 0:
31266                          return c = {}, [4, b.onBatchBegin(a, c)];
31267
31268                        case 1:
31269                          return h.sent(), (0, _tfjsCore.tidy)(function () {
31270                            var h = p[a][0],
31271                                d = p[a][1],
31272                                f = sliceAlongFirstAxis(s, h, d - h);
31273                            c.batch = a, c.size = d - h;
31274
31275                            for (var m = sliceArraysByIndices(n, f), y = t(m), v = 0; v < r.length; ++v) {
31276                              var b = r[v],
31277                                  w = y[v];
31278                              c[b] = w, (0, _tfjsCore.keep)(w);
31279                            }
31280
31281                            if (a === p.length - 1 && g) {
31282                              var z = e.testLoop(l, u, i);
31283
31284                              for (v = 0; v < r.length; ++v) {
31285                                b = r[v], w = z[v];
31286                                (0, _tfjsCore.keep)(w), o["val_" + b] = w;
31287                              }
31288                            }
31289                          }), [4, b.onBatchEnd(a, c)];
31290
31291                        case 2:
31292                          return h.sent(), disposeTensorsInLogs(c), e.stopTraining_ ? [2, "break"] : [2];
31293                      }
31294                    });
31295                  }, f = 0, v.label = 3;
31296
31297                case 3:
31298                  return f < p.length ? [5, h(f)] : [3, 6];
31299
31300                case 4:
31301                  if ("break" === v.sent()) return [3, 6];
31302                  v.label = 5;
31303
31304                case 5:
31305                  return ++f, [3, 3];
31306
31307                case 6:
31308                  s.dispose(), v.label = 7;
31309
31310                case 7:
31311                  return [4, b.onEpochEnd(a, o)];
31312
31313                case 8:
31314                  return v.sent(), e.stopTraining_ ? [2, "break"] : [2];
31315              }
31316            });
31317          }, S = h, A.label = 2;
31318
31319        case 2:
31320          return S < a ? [5, z(S)] : [3, 5];
31321
31322        case 3:
31323          if ("break" === A.sent()) return [3, 5];
31324          A.label = 4;
31325
31326        case 4:
31327          return ++S, [3, 2];
31328
31329        case 5:
31330          return [4, b.onTrainEnd()];
31331
31332        case 6:
31333          return A.sent(), [4, e.history.syncData()];
31334
31335        case 7:
31336          return A.sent(), [2, e.history];
31337      }
31338    });
31339  });
31340}
31341
31342function fitTensors(e, t, n, r) {
31343  return void 0 === r && (r = {}), __awaiter(this, void 0, void 0, function () {
31344    var i, a, o, s, l, u, c, p, h, d, f, g, m, y, v, b, w, z, S, A, _, I;
31345
31346    return __generator(this, function (C) {
31347      switch (C.label) {
31348        case 0:
31349          if (e.isTraining) throw new Error("Cannot start training because another fit() call is ongoing.");
31350          e.isTraining = !0, C.label = 1;
31351
31352        case 1:
31353          return C.trys.push([1,, 7, 8]), checkBatchSize(p = null == r.batchSize ? 32 : r.batchSize), h = !1, [4, e.standardizeUserData(t, n, r.sampleWeight, r.classWeight, h, p)];
31354
31355        case 2:
31356          if (d = C.sent(), i = d[0], a = d[1], c = d[2], f = !1, g = void 0, !(null != r.validationData && r.validationData.length > 0)) return [3, 4];
31357          if (f = !0, 2 !== r.validationData.length) throw 3 === r.validationData.length ? new NotImplementedError("validationData including sample weights is not supported yet.") : new ValueError("When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items;
31357 " + r.validationData + " is invalid.");
31358          return o = r.validationData[0], s = r.validationData[1], m = !0, [4, e.standardizeUserData(o, s, null, null, m, p)];
31359
31360        case 3:
31361          return y = C.sent(), l = y[0], u = y[1], g = l.concat(u), [3, 5];
31362
31363        case 4:
31364          null != r.validationSplit && r.validationSplit > 0 && r.validationSplit < 1 ? (f = !0, v = Math.floor(i[0].shape[0] * (1 - r.validationSplit)), b = i[0].shape[0], l = sliceArrays(i, v, b), i = sliceArrays(i, 0, v), u = sliceArrays(a, v, b), a = sliceArrays(a, 0, v), g = l.concat(u)) : null != r.validationSteps && (f = !0), C.label = 5;
31365
31366        case 5:
31367          return w = i.concat(a).concat(c), e.checkTrainableWeightsConsistency(), z = e.makeTrainFunction(), S = e.getDedupedMetricsNames(), A = void 0, _ = void 0, f ? (e.makeTestFunction(), A = e.testFunction, _ = S.slice().concat(S.map(function (e) {
31368            return "val_" + e;
31369          }))) : (A = null, g = [], _ = S.slice()), I = standardizeCallbacks(r.callbacks, r.yieldEvery), [4, fitLoop(e, z, w, S, p, r.epochs, r.verbose, I, A, g, r.shuffle, _, r.initialEpoch, null, null)];
31370
31371        case 6:
31372          return [2, C.sent()];
31373
31374        case 7:
31375          return e.isTraining = !1, disposeNewTensors(i, t), disposeNewTensors(a, n), disposeNewTensors(l, o), disposeNewTensors(u, s), null != c && (0, _tfjsCore.dispose)(c), [7];
31376
31377        case 8:
31378          return [2];
31379      }
31380    });
31381  });
31382}
31383
31384function ensureTensorsRank2OrHigher(e) {
31385  var t = [];
31386  e instanceof _tfjsCore.Tensor && (e = [e]);
31387
31388  for (var n = 0; n < e.length; ++n) {
31389    var r = e[n];
31390    if (1 === r.rank) t.push(expandDims$1(r, 1));else {
31391      if (0 === r.rank) throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar).");
31392      t.push(r);
31393    }
31394  }
31395
31396  return t;
31397}
31398
31399function disposeNewTensors(e, t) {
31400  if (null != e) {
31401    var n = [];
31402    if (t instanceof _tfjsCore.Tensor) n.push(t.id);else if (Array.isArray(t)) t.forEach(function (e) {
31403      return n.push(e.id);
31404    });else if (null != t) for (var r in t) {
31405      var i = t[r];
31406      n.push(i.id);
31407    }
31408    var a = [];
31409    if (e instanceof _tfjsCore.Tensor) -1 === n.indexOf(e.id) && a.push(e);else if (Array.isArray(e)) e.forEach(function (e) {
31410      -1 === n.indexOf(e.id) && a.push(e);
31411    });else if (null != e) for (var o in e) {
31412      var s = e[o];
31413      -1 === n.indexOf(s.id) && a.push(s);
31414    }
31415    a.forEach(function (e) {
31416      e.isDisposed || e.dispose();
31417    });
31418  }
31419}
31420
31421function isDataTensor(e) {
31422  return e instanceof _tfjsCore.Tensor;
31423}
31424
31425function isDataArray(e) {
31426  return Array.isArray(e);
31427}
31428
31429function isDataDict(e) {
31430  return !isDataTensor(e) && !isDataArray(e);
31431}
31432
31433function standardizeInputData(e, t, n, r, i) {
31434  if (void 0 === r && (r = !0), void 0 === i && (i = ""), null == t || 0 === t.length) {
31435    if (null != e) {
31436      var a = !1;
31437      if (isDataArray(e) && e.length > 0) a = !0;else if (isDataDict(e)) {
31438        for (var o in e) if (e.hasOwnProperty(o)) {
31439          a = !0;
31440          break;
31441        }
31442      } else a = !0;
31443      if (a) throw new ValueError("Error when checking model " + i + " expected no data, but got " + e);
31444    }
31445
31446    return [];
31447  }
31448
31449  if (null == e) return t.map(function (e) {
31450    return null;
31451  });
31452  var s;
31453
31454  if (isDataDict(e)) {
31455    e = e, s = [];
31456
31457    for (var l = 0, u = t; l < u.length; l++) {
31458      var c = u[l];
31459      if (null == e[c]) throw new ValueError('No data provided for "' + c + '". Need data for each key in: ' + t);
31460      s.push(e[c]);
31461    }
31462  } else if (isDataArray(e)) {
31463    if ((e = e).length !== t.length) throw new ValueError("Error when checking model " + i + ": the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see " + t.length + " Tensor(s), but instead got the following list of Tensor(s): " + e);
31464    s = e;
31465  } else {
31466    if (e = e, t.length > 1) throw new ValueError("The model " + i + " expects " + t.length + " Tensor(s), but only received one Tensor. Found: Tensor with shape " + e.shape);
31467    s = [e];
31468  }
31469
31470  if (s = ensureTensorsRank2OrHigher(s), null != n) for (var p = 0; p < t.length; ++p) if (null != n[p]) {
31471    var h = s[p];
31472    if (h.shape.length !== n[p].length) throw new ValueError("Error when checking " + i + ": expected " + t[p] + " to have " + n[p].length + " dimension(s). but got array with shape " + h.shape);
31473
31474    for (var d = 0; d < n[p].length; ++d) if (0 !== d || r) {
31475      var f = h.shape[d],
31476          g = n[p][d];
31477      if (null != g && g >= 0 && f !== g) throw new ValueError("Error when checking " + i + ": expected " + t[p] + " to have shape [" + n[p] + "], but got array with shape [" + h.shape + "].");
31478    }
31479  }
31480  return s;
31481}
31482
31483function checkArrayLengths(e, t, n) {
31484  var r = unique(e.map(function (e) {
31485    return e.shape[0];
31486  }));
31487  r.sort();
31488  var i = unique(t.map(function (e) {
31489    return e.shape[0];
31490  }));
31491  if (i.sort(), r.length > 1) throw new ValueError("All input Tensors (x) should have the same number of samples. Got array shapes: " + JSON.stringify(e.map(function (e) {
31492    return e.shape;
31493  })));
31494  if (i.length > 1) throw new ValueError("All target Tensors (y) should have the same number of samples. Got array shapes: " + JSON.stringify(t.map(function (e) {
31495    return e.shape;
31496  })));
31497  if (r.length > 0 && i.length > 0 && !_tfjsCore.util.arraysEqual(r, i)) throw new ValueError("Input Tensors should have the same number of samples as target Tensors. Found " + r[0] + " input sample(s) and " + i[0] + " target sample(s).");
31498}
31499
31500function checkLossAndTargetCompatibility(e, t, n) {
31501  for (var r = [meanSquaredError, binaryCrossentropy, categoricalCrossentropy], i = 0; i < e.length; ++i) {
31502    var a = e[i],
31503        o = t[i],
31504        s = n[i];
31505
31506    if (null != o) {
31507      if (o === categoricalCrossentropy && 1 === a.shape[a.shape.length - 1]) throw new ValueError("You are passing a target array of shape " + a.shape + " while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].");
31508      if (-1 !== r.indexOf(o)) for (var l = a.shape.slice(1), u = s.slice(1), c = 0; c < l.length; ++c) {
31509        var p = l[c],
31510            h = u[c];
31511        if (null != h && p !== h) throw new ValueError("A target Tensor with shape " + a.shape + " was passed for an output of shape " + s + ", while using a loss function that expects targets to have the same shape as the output.");
31512      }
31513    }
31514  }
31515}
31516
31517function checkInputData(e, t, n, r, i) {
31518  var a;
31519
31520  if (void 0 === r && (r = !0), void 0 === i && (i = ""), Array.isArray(e)) {
31521    if (e.length !== t.length) throw new ValueError("Error when checking model " + i + ": the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see " + t.length + " Tensor(s), but instead got " + e.length + " Tensors(s).");
31522    a = e;
31523  } else {
31524    if (t.length > 1) throw new ValueError("The model expects " + t.length + " " + i + " Tensors, but only received one Tensor. Found: array with shape " + JSON.stringify(e.shape) + ".");
31525    a = [e];
31526  }
31527
31528  if (null != n) for (var o = 0; o < t.length; ++o) if (null != n[o]) {
31529    var s = a[o];
31530    if (s.shape.length !== n[o].length) throw new ValueError("Error when checking " + i + ": expected " + t[o] + " to have " + n[o].length + " dimension(s), but got array with shape " + JSON.stringify(s.shape));
31531
31532    for (var l = 0; l < n[o].length; ++l) if (0 !== l || r) {
31533      var u = s.shape[l],
31534          c = n[o][l];
31535      if (null != c && c !== u) throw new ValueError("Error when checking " + i + ": expected " + t[o] + " to have shape " + JSON.stringify(n[o]) + " but got array with shape " + JSON.stringify(s.shape) + ".");
31536    }
31537  }
31538}
31539
31540function collectMetrics(e, t) {
31541  if (null == e || Array.isArray(e) && 0 === e.length) return t.map(function (e) {
31542    return [];
31543  });
31544  var n;
31545  if ("string" == typeof e || "function" == typeof e) n = [e];else {
31546    if (!Array.isArray(e) && "object" != typeof e) throw new TypeError("Type of metrics argument not understood. Expected an string,function, Array, or Object, found: " + e);
31547    n = e;
31548  }
31549  if (Array.isArray(n)) return t.map(function (e) {
31550    return n;
31551  });
31552
31553  for (var r = [], i = 0, a = t; i < a.length; i++) {
31554    var o = a[i],
31555        s = n.hasOwnProperty(o) ? n[o] : [];
31556    Array.isArray(s) || (s = [s]), r.push(s);
31557  }
31558
31559  return r;
31560}
31561
31562var LAYERS_MODEL_FORMAT_NAME = "layers-model",
31563    LayersModel = function (e) {
31564  function t(t) {
31565    var n = e.call(this, t) || this;
31566    return n.isTraining = !1, n;
31567  }
31568
31569  return __extends(t, e), t.prototype.summary = function (e, t, n) {
31570    if (void 0 === n && (n = console.log), !this.built) throw new ValueError("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data).");
31571    printSummary(this, e, t, n);
31572  }, t.prototype.compile = function (e) {
31573    var t = this;
31574    if (null == e.loss && (e.loss = []), this.loss = e.loss, "string" == typeof e.o
31574ptimizer) this.optimizer_ = getOptimizer(e.optimizer), this.isOptimizerOwned = !0;else {
31575      if (!(e.optimizer instanceof _tfjsCore.Optimizer)) throw new ValueError("User-defined optimizer must be an instance of tf.Optimizer.");
31576      this.optimizer_ = e.optimizer, this.isOptimizerOwned = !1;
31577    }
31578    var n = [];
31579    if (Array.isArray(e.loss) || "string" == typeof e.loss || "function" == typeof e.loss) {
31580      if (Array.isArray(e.loss)) {
31581        if (e.loss.length !== this.outputs.length) throw new ValueError("When passing an Array as loss, it should have one entry per model output. The model has " + this.outputs.length + " output(s), but you passed loss=" + e.loss + ".");
31582        var r = e.loss;
31583        n = r.map(function (e) {
31584          return get(e);
31585        });
31586      } else {
31587        var i = get(e.loss);
31588        this.outputs.forEach(function (e) {
31589          n.push(i);
31590        });
31591      }
31592    } else {
31593      for (var a in e.loss = e.loss, e.loss) if (-1 === this.outputNames.indexOf(a)) throw new ValueError('Unknown entry in loss dictionary: "' + a + '". Only expected the following keys: ' + this.outputNames);
31594
31595      for (var o = 0, s = this.outputNames; o < s.length; o++) {
31596        var l = s[o];
31597        null == e.loss[l] && console.warn('Output "' + l + '" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ' + l + " during training"), n.push(get(e.loss[l]));
31598      }
31599    }
31600    this.lossFunctions = n, this.feedOutputNames = [], this.feedOutputShapes = [], this.feedLossFns = [];
31601
31602    for (var u = 0; u < this.outputs.length; ++u) {
31603      var c = this.internalOutputShapes[u],
31604          p = this.outputNames[u];
31605      this.feedOutputNames.push(p), this.feedOutputShapes.push(c), this.feedLossFns.push(this.lossFunctions[u]);
31606    }
31607
31608    var h = [];
31609    this.metrics = e.metrics, this.metricsNames = ["loss"], this.metricsTensors = [], nameScope("loss", function () {
31610      for (var e = 0; e < t.outputs.length; ++e) if (-1 === h.indexOf(e)) {
31611        var n = t.lossFunctions[e];
31612        t.outputs.length > 1 && (t.metricsTensors.push([n, e]), t.metricsNames.push(t.outputNames[e] + "_loss"));
31613      }
31614    });
31615    var d = collectMetrics(e.metrics, this.outputNames);
31616    nameScope("metric", function () {
31617      for (var e = function (e) {
31618        if (-1 !== h.indexOf(e)) return "continue";
31619        !function (n) {
31620          for (var r, i, a, o = function (n) {
31621            if ("string" == typeof n && -1 !== ["accuracy", "acc", "crossentropy", "ce"].indexOf(n)) {
31622              var o = t.internalOutputShapes[e];
31623              1 === o[o.length - 1] || t.lossFunctions[e] === binaryCrossentropy ? -1 !== ["accuracy", "acc"].indexOf(n) ? i = binaryAccuracy : -1 !== ["crossentropy", "ce"].indexOf(n) && (i = binaryCrossentropy$1) : t.lossFunctions[e] === sparseCategoricalCrossentropy ? -1 !== ["accuracy", "acc"].indexOf(n) ? i = sparseCategoricalAccuracy : -1 !== ["crossentropy", "ce"].indexOf(n) && (i = sparseCategoricalCrossentropy$1) : -1 !== ["accuracy", "acc"].indexOf(n) ? i = categoricalAccuracy : -1 !== ["crossentropy", "ce"].indexOf(n) && (i = categoricalCrossentropy$1);
31624              var s = void 0;
31625              -1 !== ["accuracy", "acc"].indexOf(n) ? s = "acc" : -1 !== ["crossentropy", "ce"].indexOf(n) && (s = "ce"), a = i, r = "" + s;
31626            } else {
31627              var l = get$1(n);
31628              a = l, r = "" + getLossOrMetricName(n);
31629            }
31630
31631            var u;
31632            nameScope(r, function () {
31633              u = a;
31634            }), function (e, n, r) {
31635              t.outputNames.length > 1 && (n = t.outputNames[e] + "_" + n), t.metricsNames.push(n), t.metricsTensors.push([r, e]);
31636            }(e, r, u);
31637          }, s = 0, l = n; s < l.length; s++) o(l[s]);
31638        }(d[e]);
31639      }, n = 0; n < t.outputs.length; ++n) e(n);
31640    }), this.collectedTrainableWeights = this.trainableWeights;
31641  }, t.prototype.checkTrainableWeightsConsistency = function () {
31642    null != this.collectedTrainableWeights && this.trainableWeights.length !== this.collectedTrainableWeights.length && console.warn("Discrepancy between trainableweights and collected trainable weights. Did 
31642you set `model.trainable` without calling `model.compile()` afterwards?");
31643  }, t.prototype.evaluate = function (e, t, n) {
31644    void 0 === n && (n = {});
31645    var r = null == n.batchSize ? 32 : n.batchSize;
31646    checkBatchSize(r);
31647    var i = this.standardizeUserDataXY(e, t, !0, r);
31648
31649    try {
31650      var a = i[0].concat(i[1]);
31651      this.makeTestFunction();
31652      var o = this.testFunction;
31653      return singletonOrArray(this.testLoop(o, a, r, n.verbose, n.steps));
31654    } finally {
31655      disposeNewTensors(i[0], e), disposeNewTensors(i[1], t);
31656    }
31657  }, t.prototype.evaluateDataset = function (e, t) {
31658    return __awaiter(this, void 0, void 0, function () {
31659      return __generator(this, function (n) {
31660        return this.makeTestFunction(), [2, evaluateDataset(this, e, t)];
31661      });
31662    });
31663  }, t.prototype.checkNumSamples = function (e, t, n, r) {
31664    var i;
31665
31666    if (void 0 === r && (r = "steps"), null != n) {
31667      if (i = null, null != t) throw new ValueError("If " + r + " is set, batchSize must be null or undefined.Got batchSize = " + t);
31668    } else {
31669      if (null == e) throw new ValueError("Either the input data should have a defined shape, or " + r + " shoud be specified.");
31670      i = Array.isArray(e) ? e[0].shape[0] : e.shape[0];
31671    }
31672
31673    return i;
31674  }, t.prototype.execute = function (e, t) {
31675    if (Array.isArray(t) && 0 === t.length) throw new ValueError("`outputs` is an empty Array, which is not allowed.");
31676    var n = Array.isArray(t),
31677        r = n ? t : [t],
31678        i = this.retrieveSymbolicTensors(r),
31679        a = new FeedDict();
31680
31681    if (e instanceof _tfjsCore.Tensor && (e = [e]), Array.isArray(e)) {
31682      if (e.length !== this.inputs.length) throw new ValueError("The number of inputs provided (" + e.length + ") does not match the number of inputs of this model (" + this.inputs.length + ").");
31683
31684      for (var o = 0; o < this.inputs.length; ++o) a.add(this.inputs[o], e[o]);
31685    } else for (var s = 0, l = this.inputs; s < l.length; s++) {
31686      var u = l[s],
31687          c = e[u.name];
31688      if (null == c) throw new ValueError("No value is provided for the model's input " + u.name);
31689      a.add(u, c);
31690    }
31691
31692    var p = execute(i, a);
31693    return n ? p : p[0];
31694  }, t.prototype.retrieveSymbolicTensors = function (e) {
31695    for (var t = pyListRepeat(null, e.length), n = e.length, r = 0, i = this.layers; r < i.length; r++) {
31696      for (var a = i[r], o = Array.isArray(a.output) ? a.output : [a.output], s = o.map(function (e) {
31697        return e.name;
31698      }), l = 0; l < e.length; ++l) {
31699        var u = s.indexOf(e[l]);
31700        if (-1 !== u && (t[l] = o[u], n--), 0 === n) break;
31701      }
31702
31703      if (0 === n) break;
31704    }
31705
31706    if (n > 0) {
31707      var c = [];
31708      throw t.forEach(function (t, n) {
31709        null == t && c.push(e[n]);
31710      }), new ValueError("Cannot find SymbolicTensors for output name(s): " + JSON.stringify(c));
31711    }
31712
31713    return t;
31714  }, t.prototype.predictLoop = function (e, t, n) {
31715    var r = this;
31716    return void 0 === t && (t = 32), void 0 === n && (n = !1), (0, _tfjsCore.tidy)(function () {
31717      var i = r.checkNumSamples(e);
31718      if (n) throw new NotImplementedError("Verbose predictLoop() is not implemented yet.");
31719
31720      for (var a = makeBatches(i, t), o = r.outputs.map(function (e) {
31721        return [];
31722      }), s = function (t) {
31723        (0, _tfjsCore.tidy)(function () {
31724          var n = a[t][0],
31725              i = a[t][1],
31726              o = sliceArrays(e, n, i),
31727              s = [];
31728          if (Array.isArray(o)) for (var l = 0; l < o.length; ++l) s.push({
31729            key: r.inputs[l],
31730            value: o[l]
31731          });else s.push({
31732            key: r.inputs[0],
31733            value: o
31734          });
31735          var u = new FeedDict(s);
31736          return execute(r.outputs, u);
31737        }
31737).forEach(function (e, t) {
31738          return o[t].push(e);
31739        });
31740      }, l = 0; l < a.length; ++l) s(l);
31741
31742      return singletonOrArray(o.map(function (e) {
31743        return (0, _tfjsCore.concat)(e, 0);
31744      }));
31745    });
31746  }, t.prototype.predict = function (e, t) {
31747    void 0 === t && (t = {});
31748    var n = ensureTensorsRank2OrHigher(e);
31749    checkInputData(n, this.inputNames, this.feedInputShapes, !1);
31750
31751    try {
31752      var r = null == t.batchSize ? 32 : t.batchSize;
31753      return checkBatchSize(r), this.predictLoop(n, r);
31754    } finally {
31755      disposeNewTensors(n, e);
31756    }
31757  }, t.prototype.predictOnBatch = function (e) {
31758    checkInputData(e, this.inputNames, this.feedInputShapes, !0);
31759    var t = (Array.isArray(e) ? e[0] : e).shape[0];
31760    return this.predictLoop(e, t);
31761  }, t.prototype.standardizeUserDataXY = function (e, t, n, r) {
31762    if (void 0 === n && (n = !0), null == this.optimizer_) throw new RuntimeError("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs).");
31763
31764    for (var i = [], a = 0; a < this.feedOutputShapes.length; ++a) {
31765      var o = this.feedOutputShapes[a];
31766      this.feedLossFns[a] === sparseCategoricalCrossentropy ? i.push(o.slice(0, o.length - 1).concat([1])) : i.push(o);
31767    }
31768
31769    if (checkArrayLengths(e = standardizeInputData(e, this.feedInputNames, this.feedInputShapes, !1, "input"), t = standardizeInputData(t, this.feedOutputNames, i, !1, "target"), null), checkLossAndTargetCompatibility(t, this.feedLossFns, this.feedOutputShapes), this.stateful && null != r && r > 0 && e[0].shape[0] % r != 0) throw new ValueError("In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size " + r + ". Found: " + e[0].shape[0] + " sample(s).");
31770    return [e, t];
31771  }, t.prototype.standardizeUserData = function (e, t, n, r, i, a) {
31772    return void 0 === i && (i = !0), __awaiter(this, void 0, void 0, function () {
31773      var o, s, l, u, c, p, h, d;
31774      return __generator(this, function (f) {
31775        switch (f.label) {
31776          case 0:
31777            if (o = this.standardizeUserDataXY(e, t, i, a), s = o[0], l = o[1], null != n) throw new Error("sample weight is not supported yet.");
31778            if (u = null, null == r) return [3, 4];
31779            c = standardizeClassWeights(r, this.outputNames), u = [], p = 0, f.label = 1;
31780
31781          case 1:
31782            return p < c.length ? (d = (h = u).push, [4, standardizeWeights(l[p], null, c[p])]) : [3, 4];
31783
31784          case 2:
31785            d.apply(h, [f.sent()]), f.label = 3;
31786
31787          case 3:
31788            return ++p, [3, 1];
31789
31790          case 4:
31791            return [2, [s, l, u]];
31792        }
31793      });
31794    });
31795  }, t.prototype.testLoop = function (e, t, n, r, i) {
31796    var a = this;
31797    return void 0 === r && (r = 0), (0, _tfjsCore.tidy)(function () {
31798      var o = a.checkNumSamples(t, n, i, "steps"),
31799          s = [];
31800      if (r > 0) throw new NotImplementedError("Verbose mode is not implemented yet.");
31801      if (null != i) throw new NotImplementedError("steps mode in testLoop() is not implemented yet");
31802
31803      for (var l = makeBatches(o, n), u = (0, _tfjsCore.tensor1d)(range(0, o)), c = 0; c < l.length; ++c) {
31804        var p = l[c][0],
31805            h = l[c][1],
31806            d = sliceAlongFirstAxis(u, p, h - p),
31807            f = sliceArraysByIndices(t, d),
31808            g = e(f);
31809        if (0 === c) for (var m = 0; m < g.length; ++m) s.push((0, _tfjsCore.scalar)(0));
31810
31811        for (m = 0; m < g.length; ++m) {
31812          var y = g[m];
31813          s[m] = (0, _tfjsCore.add)(s[m], (0, _tfjsCore.mul)(h - p, y));
31814        }
31815      }
31816
31817      for (m = 0; m < s.length; ++m) s[m] = (0, _tfjsCore.div)(s[m], o);
31818
31819      return s;
31820    });
31821  }, t.prototype.getDedupedMetricsNames = function () {
31822    for (var e = this.metricsNames, t = [], n = 0; n < e.length; ++n) {
31823      var r = e[n],
31824          i = r;
31825      if (count(e, r) > 1) i += "_" + count(e.slice(0, n), r);
31826      t.push(i);
31827    }
31828
31829    return t;
31830  }, t.prototype.makeTrainFunction = function () {
31831    var e = this;
31832    return function (t) {
31833      var n = [],
31834          r = t.slice(0, e.inputs.length),
31835          i = t.slice(e.inputs.length, e.inputs.length + e.outputs.length),
31836          a = t.slice(e.inputs.length + e.outputs.length, e.inputs.length + 2 * e.outputs.length),
31837          o = [],
31838          s = e.collectedTrainableWeights.map(function (e) {
31839        return e.read();
31840      });
31841      return [e.optimizer_.minimize(function () {
31842        for (var t = [], s = 0; s < e.inputs.length; ++s) t.push({
31843          key: e.inputs[s],
31844          value: r[s]
31845        });
31846
31847        var l,
31848            u = new FeedDict(t),
31849            c = execute(e.outputs, u, {
31850          training: !0
31851        });
31852
31853        for (s = 0; s < e.lossFunctions.length; ++s) {
31854          var p = (0, e.lossFunctions[s])(i[s], c[s]);
31855          null != a[s] && (p = computeWeightedLoss(p, a[s]));
31856          var h = (0, _tfjsCore.mean)(p);
31857          n.push(h), l = 0 === s ? p : (0, _tfjsCore.add)(l, p);
31858        }
31859
31860        for (s = 0; s < e.metricsTensors.length; ++s) {
31861          var d = void 0;
31862          if (e.outputs.length > 1 && s < e.outputs.length) d = n[s];else {
31863            var f = e.metricsTensors[s][0],
31864                g = e.metricsTensors[s][1];
31865            d = (0, _tfjsCore.mean)(f(i[g], c[g]));
31866          }
31867          (0, _tfjsCore.keep)(d), o.push(d);
31868        }
31869
31870        return l = (0, _tfjsCore.mean)(l), e.calculateLosses().forEach(function (e) {
31871          l = (0, _tfjsCore.add)(l, e);
31872        }), l;
31873      }, !0, s)].concat(o);
31874    };
31875  }, t.prototype.makeTestFunction = function () {
31876    var e = this;
31877
31878    this.testFunction = function (t) {
31879      return (0, _tfjsCore.tidy)(function () {
31880        for (var n, r = [], i = t.slice(0, e.inputs.length), a = t.slice(e.inputs.length, e.inputs.length + e.outputs.length), o = [], s = 0; s < e.inputs.length; ++s) o.push({
31881          key: e.inputs[s],
31882          value: i[s]
31883        });
31884
31885        var l = new FeedDict(o),
31886            u = execute(e.outputs, l);
31887
31888        for (s = 0; s < e.lossFunctions.length; ++s) {
31889          var c = e.lossFunctions[s],
31890              p = (0, _tfjsCore.mean)(c(a[s], u[s]));
31891          n = 0 === s ? p : (0, _tfjsCore.add)(n, p), r.push(n);
31892        }
31893
31894        for (s = 0; s < e.metricsTensors.length; ++s) {
31895          var h = e.metricsTensors[s][0],
31896              d = e.metricsTensors[s][1],
31897              f = (0, _tfjsCore.mean)(h(a[d], u[d]));
31898          r.push(f);
31899        }
31900
31901        return r;
31902      });
31903    };
31904  }, t.prototype.fit = function (e, t, n) {
31905    return void 0 === n && (n = {}), __awaiter(this, void 0, void 0, function () {
31906      return __generator(this, function (r) {
31907        return [2, fitTensors(this, e, t, n)];
31908      });
31909    });
31910  }, t.prototype.fitDataset = function (e, t) {
31911    return __awaiter(this, void 0, void 0, function () {
31912      return __generator(this, function (n) {
31913        return [2, fitDataset(this, e, t)];
31914      });
31915    });
31916  }, t.prototype.trainOnBatch = function (e, t) {
31917    return __awaiter(this, void 0, void 0, function () {
31918      var n, r, i, a, o, s, l, u, c;
31919      return __generator(this, function (p) {
31920        switch (p.label) {
31921          case 0:
31922            return [4, this.standardizeUserData(e, t)];
31923
31924          case 1:
31925            n = p.sent(), r = n[0], i = n[1], a = this.makeTrainFunction(), o = a(r.concat(i)), s = [], l = 0, u = o, p.label = 2;
31926
31927          case 2:
31928            return l < u.length ? [4, u[l].data()] : [3, 5];
31929
31930          case 3:
31931            c = p.sent(), s.push(c[0]), p.label = 4;
31932
31933          case 4:
31934            return l++, [3, 2];
31935
31936          case 5:
31937            return (0, _tfjsCore.dispose)(o), [2, singletonOrArray(s)];
31938        }
31939      });
31940    });
31941  }, t.prototype.getNamedWeights = function (e) {
31942    for (var t = [], n = null != e && e.trainableOnly, r = n ? this.trainableWeights : this.weights, i = this.getWeights(n), a = 0; a < r.length; ++a) n && !r[a].trainable || t.push({
31943      name: r[a].originalName,
31944      tensor: i[a]
31945    });
31946
31947    return t;
31948  }, Object.defineProperty(t.prototype, "stopTraining", {
31949    get: function () {
31950      return this.stopTraining_;
31951    },
31952    set: function (e) {
31953      this.stopTraining_ = e;
31954    },
31955    enumerable: !0,
31956    configurable: !0
31957  }), Object.defineProperty(t.prototype, "optimizer", {
31958    get: function () {
31959      return this.optimizer_;
31960    },
31961    set: function (e) {
31962      this.optimizer_ !== e && (this.optimizer_ = e, this.isOptimizerOwned 
31962= !1);
31963    },
31964    enumerable: !0,
31965    configurable: !0
31966  }), t.prototype.dispose = function () {
31967    var t = e.prototype.dispose.call(this);
31968
31969    if (0 === t.refCountAfterDispose && null != this.optimizer && this.isOptimizerOwned) {
31970      var n = (0, _tfjsCore.memory)().numTensors;
31971      this.optimizer_.dispose(), t.numDisposedVariables += n - (0, _tfjsCore.memory)().numTensors;
31972    }
31973
31974    return t;
31975  }, t.prototype.getLossIdentifiers = function () {
31976    var e;
31977    if ("string" == typeof this.loss) e = toSnakeCase(this.loss);else if (Array.isArray(this.loss)) {
31978      for (var t = 0, n = this.loss; t < n.length; t++) {
31979        if ("string" != typeof n[t]) throw new Error("Serialization of non-string loss is not supported.");
31980      }
31981
31982      e = this.loss.map(function (e) {
31983        return toSnakeCase(e);
31984      });
31985    } else {
31986      var r = Object.keys(this.loss);
31987      e = {};
31988
31989      for (var i = this.loss, a = 0, o = r; a < o.length; a++) {
31990        var s = o[a];
31991        if ("string" != typeof i[s]) throw new Error("Serialization of non-string loss is not supported.");
31992        e[s] = toSnakeCase(i[s]);
31993      }
31994    }
31995    return e;
31996  }, t.prototype.getMetricIdentifiers = function () {
31997    if ("string" == typeof this.metrics || "function" == typeof this.metrics) return [toSnakeCase(getLossOrMetricName(this.metrics))];
31998    if (Array.isArray(this.metrics)) return this.metrics.map(function (e) {
31999      return toSnakeCase(getLossOrMetricName(e));
32000    });
32001    var e = {};
32002
32003    for (var t in this.metrics) e[t] = toSnakeCase(getLossOrMetricName(this.metrics[t]));
32004
32005    return e;
32006  }, t.prototype.getTrainingConfig = function () {
32007    return {
32008      loss: this.getLossIdentifiers(),
32009      metrics: this.getMetricIdentifiers(),
32010      optimizer_config: {
32011        class_name: this.optimizer.getClassName(),
32012        config: this.optimizer.getConfig()
32013      }
32014    };
32015  }, t.prototype.loadTrainingConfig = function (e) {
32016    if (null != e.weighted_metrics) throw new Error("Loading weight_metrics is not supported yet.");
32017    if (null != e.loss_weights) throw new Error("Loading loss_weights is not supported yet.");
32018    if (null != e.sample_weight_mode) throw new Error("Loading sample_weight_mode is not supported yet.");
32019    var t,
32020        n,
32021        r = deserialize(convertPythonicToTs(e.optimizer_config));
32022    if ("string" == typeof e.loss) t = toCamelCase(e.loss);else if (Array.isArray(e.loss)) t = e.loss.map(function (e) {
32023      return toCamelCase(e);
32024    });else if (null != e.loss) for (var i in t = {}, e.loss) t[i] = toCamelCase(e.loss[i]);
32025    if (Array.isArray(e.metrics)) n = e.metrics.map(function (e) {
32026      return toCamelCase(e);
32027    });else if (null != e.metrics) for (var i in n = {}, e.metrics) n[i] = toCamelCase(e.metrics[i]);
32028    this.compile({
32029      loss: t,
32030      metrics: n,
32031      optimizer: r
32032    });
32033  }, t.prototype.save = function (e, t) {
32034    return __awaiter(this, void 0, void 0, function () {
32035      var n, r, i, a, o, s, l, u, c, p, h, d, f, g;
32036      return __generator(this, function (m) {
32037        switch (m.label) {
32038          case 0:
32039            if ("string" == typeof e) {
32040              if (0 === (n = _tfjsCore.io.getSaveHandlers(e)).length) throw new ValueError("Cannot find any save handlers for URL '" + e + "'");
32041              if (n.length > 1) throw new ValueError("Found more than one (" + n.length + ") save handlers for URL '" + e + "'");
32042              e = n[0];
32043            }
32044
32045            if (null == e.save) throw new ValueError("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");
32046            return [4, _tfjsCore.io.encodeWeights(this.getNamedWeights(t))];
32047
32048          case 1:
32049            return r = m.sent(), i = !1, a = null, o = this.toJSON(a, i), s = {
32050              modelTopology: o,
32051              format: LAYERS_MODEL_FORMAT_NAME,
32052              generatedBy: "TensorFlow.js tfjs-layers v" + version,
32053              convertedBy: null
32054            }, null != t && t.includeOptimizer && null != this.optimizer ? (s.trainingConfig = this.getTrainingConfig(), l = "optimizer", d = (h = _tfjsCore.io).encodeWeights, [4, this.optimizer.getWeights()]) : [3, 4];
32055
32056          case 2:
32057            return [4, d.apply(h, [m.sent(), l])];
32058
32059          case 3:
32060            u = m.sent(), c = u.data, p = u.specs, (g = r.specs).push.apply(g, p), r.data = _tfjsCore.io.concatenateArrayBuffers([r.data, c]), m.label = 4;
32061
32062          case 4:
32063            return null != this.userDefinedMetadata && (f = !0, checkUserDefinedMetadata(this.userDefinedMetadata, this.name, f), s.userDefinedMetadata = this.userDefinedMetadata), s.weightData = r.data, s.weightSpecs = r.specs, [2, e.save(s)];
32064        }
32065      });
32066    });
32067  }, t.prototype.setUserDefinedMetadata = function (e) {
32068    checkUserDefinedMetadata(e, this.name), this.userDefinedMetadata = e;
32069  }, t.prototype.getUserDefinedMetadata = function () {
32070    return this.userDefinedMetadata;
32071  }, t.className = "Model", t;
32072}(Container);
32073
32074exports.LayersModel = LayersModel;
32075
32076function modelFromJSON(e, t) {
32077  return __awaiter(this, void 0, void 0, function () {
32078    var n, r, i, a, o, s, l, u;
32079    return __generator(this, function (c) {
32080      switch (c.label) {
32081        case 0:
32082          return "modelTopology" in e || (e = {
32083            modelTopology: e
32084          }), null != (n = (e = e).modelTopology).model_config && (n = n.model_config), r = convertPythonicToTs(n), i = deserialize(r, t), null == e.weightsManifest ? [3, 2] : [4, _tfjsCore.io.loadWeights(e.weightsManifest, e.pathPrefix, i.weights.map(function (e) {
32085            return e.originalName;
32086          }))];
32087
32088        case 1:
32089          for (a = c.sent(), o = {}, s = 0, l = i.weights; s < l.length; s++) u = l[s], o[u.originalName] = a[u.originalName];
32090
32091          i.loadWeights(o), (0, _tfjsCore.dispose)(a), c.label = 2;
32092
32093        case 2:
32094          return [2, i];
32095      }
32096    });
32097  });
32098}
32099
32100function loadLayersModelInternal(e, t) {
32101  return __awaiter(this, void 0, void 0, function () {
32102    var n;
32103    return __generator(this, function (r) {
32104      if (null == t && (t = {}), "string" == typeof e) {
32105        if (0 === (n = _tfjsCore.io.getLoadHandlers(e, t.onProgress)).length) n.push(_tfjsCore.io.browserHTTPRequest(e, t));else if (n.length > 1) throw new ValueError("Found more than one (" + n.length + ") load handlers for URL '" + e + "'");
32106        e = n[0];
32107      }
32108
32109      return [2, loadLayersModelFromIOHandler(e, void 0, t)];
32110    });
32111  });
32112}
32113
32114function loadLayersModelFromIOHandler(e, t, n) {
32115  return __awaiter(this, void 0, void 0, function () {
32116    var r, i, a, o, s, l, u, c, p;
32117    return __generator(this, function (h) {
32118      switch (h.label) {
32119        case 0:
32120          if (null == n && (n = {}), null == e.load) throw new ValueError("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");
32121          return [4, e.load()];
32122
32123        case 1:
32124          if (r = h.sent(), null != (i = r.modelTopology).model_config && (i = i.model_config), a = null == n.strict || n.strict, o = null != r.weightData && null != r.weightSpecs && a, s = deserialize(convertPythonicToTs(i), t, o), null != (l = r.trainingConfig) && s.loadTrainingConfig(l), null != r.userDefinedMetadata && s.setUserDefinedMetadata(r.userDefinedMetadata), null == r.weightData) return [3, 4];
32125          if (null == r.weightSpecs) throw new ValueError("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed.");
32126          return u = decodeModelAndOptimizerWeights(r.weightData, r.weightSpecs), c = u.modelWeights, p = u.optimizerWeights, s.loadWeights(c, a), null != s.optimizer && p.length > 0 ? [4, s.optimizer.setWeights(p)] : [3, 3];
32127
32128        case 2:
32129          h.sent(), h.label = 3;
32130
32131        case 3:
32132          (0, _tfjsCore.dispose)(c), (0, _tfjsCore.dispose)(p.map(function (e) {
32133            return e.tensor;
32134          })), h.label = 4;
32135
32136        case 4:
32137          return [2, s];
32138      }
32139    });
32140  });
32141}
32142
32143function decodeModelAndOptimizerWeights(e, t) {
32144  var n = _tfjsCore.io.decodeWeights(e, t),
32145      r = {},
32146      i = [];
32147
32148  return t.forEach(function (e) {
32149    "optimizer" === e.group ? i.push({
32150      name: e.name,
32151      tensor: n[e.name]
32152    }) : r[e.name] = n[e.name];
32153  }), {
32154    modelWeights: r,
32155    optimizerWeights: i
32156  };
32157}
32158
32159_tfjsCore.serialization.registerClass(LayersModel);
32160
32161var Sequential = function (e) {
32162  function t(t) {
32163    var n = e.call(this, {
32164      inputs: [],
32165      outputs: []
32166    }) || this;
32167    if (t = t || {}, n.trainable = !0, n.built = !1, n.name = null != t.name ? t.name : getUid("sequential_"), null != t.layers
32167) for (var r = 0, i = t.layers; r < i.length; r++) {
32168      var a = i[r];
32169      n.add(a);
32170    }
32171    return n;
32172  }
32173
32174  return __extends(t, e), t.prototype.checkShape = function (e) {
32175    if (e.inboundNodes[0].outputTensors[0].shape.some(function (e) {
32176      return e < 0;
32177    })) throw new ValueError("Negative dimension size caused by adding layer " + e.name + " with input shape [" + e.inboundNodes[0].inputTensors[0].shape + "]");
32178  }, t.prototype.add = function (e) {
32179    var n,
32180        r = e instanceof t || e instanceof LayersModel;
32181
32182    if (r) {
32183      if (1 !== (n = e).outputs.length) throw new ValueError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");
32184      if (1 !== n.inputs.length) throw new ValueError("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.");
32185    }
32186
32187    if (0 === this.outputs.length) {
32188      if (0 === e.inboundNodes.length) {
32189        if (null == e.batchInputShape) throw new ValueError("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument.");
32190        var i = Input({
32191          batchShape: e.batchInputShape,
32192          dtype: e.dtype,
32193          name: e.name + "_input"
32194        });
32195        e.apply(i);
32196      }
32197
32198      if (r) this.outputs = n.outputs, this.inputs = n.inputs;else {
32199        if (1 !== e.inboundNodes.length) throw new ValueError("A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer " + e.name + " which has " + e.inboundNodes.length + " pre-existing inbound connections.");
32200        if (1 !== e.inboundNodes[0].outputTensors.length) throw new ValueError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");
32201        this.checkShape(e), this.outputs = [e.inboundNodes[0].outputTensors[0]], this.inputs = getSourceInputs(this.outputs[0]);
32202      }
32203      this.inboundNodes = [], new Node({
32204        outboundLayer: this,
32205        inboundLayers: [],
32206        nodeIndices: [],
32207        tensorIndices: [],
32208        inputTensors: this.inputs,
32209        outputTensors: this.outputs,
32210        inputMasks: pyListRepeat(null, this.inputs.length),
32211        outputMasks: [null],
32212        inputShapes: this.inputs.map(function (e) {
32213          return e.shape;
32214        }),
32215        outputShapes: this.outputs[0].shape
32216      });
32217    } else {
32218      var a = e.apply(this.outputs[0]);
32219      if (Array.isArray(a)) throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API.");
32220      this.checkShape(e), this.outputs = [a], this.inboundNodes[0].outputTensors = this.outputs, this.inboundNodes[0].outputShapes = [this.outputs[0].shape];
32221    }
32222
32223    this.layers.push(e), this.built = !1;
32224  }, t.prototype.pop = function () {
32225    if (0 === this.layers.length) throw new TypeError("There are no layers in the model.");
32226    if (this.layers.pop(), 0 === this.layers.length) this.outputs = [], this.inboundNodes = [], this.outboundNodes = [];else {
32227      var e = this.layers.length - 1;
32228      this.layers[e].outboundNodes = [], this.outputs = [this.layers[e].output], this.inboundNodes[0].outputTensors = this.outputs, this.inboundNodes[0].outputShapes = [this.outputs[0].shape];
32229    }
32230  }, t.prototype.call = function (e, t) {
32231    return null == this.model && this.build(), this.model.call(e, t);
32232  }, t.prototype.build = function (e) {
32233    if (getExactlyOneShape(e), 0 === this.inputs.length || 0 === this.outputs.length) throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first.");
32234    this.model = new LayersModel({
32235      inputs: this.inputs,
32236      outputs: this.outputs[0],
32237      name: this.name + "_model"
32238    }), this.model.trainable = this.trainable, this.supportsMasking = this.model.supp
32238ortsMasking, this.inputLayers = this.model.inputLayers, this.inputLayersNodeIndices = this.model.inputLayersNodeIndices, this.inputLayersTensorIndices = this.model.inputLayersTensorIndices, this.outputLayers = this.model.outputLayers, this.outputLayersNodeIndices = this.model.outputLayersNodeIndices, this.outputLayersTensorIndices = this.model.outputLayersTensorIndices, this.nodesByDepth = this.model.nodesByDepth, this.containerNodes = this.model.containerNodes, this.outputNames = this.model.outputNames, this.inputNames = this.model.inputNames, this.built = !0;
32239  }, t.prototype.countParams = function () {
32240    return this.built || this.build(), e.prototype.countParams.call(this);
32241  }, t.prototype.summary = function (t, n, r) {
32242    void 0 === r && (r = console.log), this.built || this.build(), e.prototype.summary.call(this, t, n, r);
32243  }, t.prototype.setWeights = function (e) {
32244    null == this.model && this.build(), this.model.setWeights(e);
32245  }, t.prototype.evaluate = function (e, t, n) {
32246    if (void 0 === n && (n = {}), !this.built) throw new RuntimeError("The model needs to be compiled before being used.");
32247    return this.model.evaluate(e, t, n);
32248  }, t.prototype.evaluateDataset = function (e, t) {
32249    return __awaiter(this, void 0, void 0, function () {
32250      return __generator(this, function (n) {
32251        if (!this.built) throw new RuntimeError("The model needs to be compiled before being used.");
32252        return [2, this.model.evaluateDataset(e, t)];
32253      });
32254    });
32255  }, t.prototype.predict = function (e, t) {
32256    return void 0 === t && (t = {}), null == this.model && this.build(), this.model.predict(e, t);
32257  }, t.prototype.predictOnBatch = function (e) {
32258    return null == this.model && this.build(), this.model.predictOnBatch(e);
32259  }, t.prototype.compile = function (e) {
32260    this.build(), this.model.compile(e), this.optimizer_ = this.model.optimizer, this.isOptimizerOwned = this.model.isOptimizerOwned, this.loss = this.model.loss, this.metrics = this.model.metrics, this.metricsTensors = this.model.metricsTensors, this.metricsNames = this.model.metricsNames;
32261  }, Object.defineProperty(t.prototype, "optimizer", {
32262    get: function () {
32263      return null == this.model ? void 0 : this.model.optimizer;
32264    },
32265    set: function (e) {
32266      this.model.optimizer = e;
32267    },
32268    enumerable: !0,
32269    configurable: !0
32270  }), t.prototype.fit = function (e, t, n) {
32271    return void 0 === n && (n = {}), __awaiter(this, void 0, void 0, function () {
32272      return __generator(this, function (r) {
32273        if (!this.built) throw new RuntimeError("The model needs to be compiled before being used.");
32274        return [2, this.model.fit(e, t, n)];
32275      });
32276    });
32277  }, t.prototype.fitDataset = function (e, t) {
32278    return __awaiter(this, void 0, void 0, function () {
32279      return __generator(this, function (n) {
32280        if (!this.built) throw new RuntimeError("The model needs to be compiled before being used.");
32281        return [2, this.model.fitDataset(e, t)];
32282      });
32283    });
32284  }, t.prototype.trainOnBatch = function (e, t) {
32285    return __awaiter(this, void 0, void 0, function () {
32286      return __generator(this, function (n) {
32287        return [2, this.model.trainOnBatch(e, t)];
32288      });
32289    });
32290  }, t.fromConfig = function (e, n, r, i) {
32291    var a;
32292    void 0 === r && (r = {}), void 0 === i && (i = !1);
32293    var o = {};
32294
32295    if (n instanceof Array) {
32296      if (null == n[0].className || "Merge" === n[0].className) throw new ValueError("Legacy serialization format not supported yet.");
32297      a = n;
32298    } else _tfjsCore.util.assert(null != n.layers, function () {
32299      return "When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.";
32300    }), a = n.layers, delete n.layers, o = n;
32301
32302    var s = new e(o);
32303    if (!(s instanceof t)) throw new NotImplementedError("Sequential.fromConfig called on non-Sequential input: " + s);
32304
32305    for (var l = 0, u = a; l < u.length; l++) {
32306      var c = deserialize(u[l], void 0, i);
32307      i && c.setFastWeightInitDuringBuild(!0), s.add(c);
32308    }
32309
32310    return s;
32311  }, Object.defineProperty(t.prototype, "stopTraining", {
32312    get: function () {
32313      if (null == this.model) throw new ValueError("Cannot get the stopTraining property of a sequential model before it is compiled.");
32314      return this.model.stopTraining;
32315    },
32316    set: function (e) {
32317      if (null == this.model) throw new ValueError("Cannot set the stopTraining property of a sequential model before it is compiled.");
32318      this.model.stopTraining = e;
32319    },
32320    enumerable: !0,
32321    configurable: !0
32322  }), t.prototype.getConfig = function () {
32323    for (var e = [], t = 0, n = this.layers; t < n.length; t++) {
32324      var r = n[t],
32325          i = {};
32326      i.className = r.getClassName(), i.config = r.getConfig(), e.push(i);
32327    }
32328
32329    return {
32330      name: this.name,
32331      layers: e
32332    };
32333  }, t.className = "Sequential", t;
32334}(LayersModel);
32335
32336exports.Sequential = Sequential;
32337
32338function model(e) {
32339  return new LayersModel(e);
32340}
32341
32342function sequential(e) {
32343  return new Sequential(e);
32344}
32345
32346function loadLayersModel(e, t) {
32347  return null == t && (t = {}), loadLayersModelInternal(e, t);
32348}
32349
32350function input(e) {
32351  return Input(e);
32352}
32353
32354function registerCallbackConstructor(e, t) {
32355  CallbackConstructorRegistry.registerCallbackConstructor(e, t);
32356}
32357
32358_tfjsCore.serialization.registerClass(Sequential);
32359
32360var Activation = function (e) {
32361  function t() {
32362    return null !== e && e.apply(this, arguments) || this;
32363  }
32364
32365  return __extends(t, e), t.prototype.getConfig = function () {
32366    return {};
32367  }, t;
32368}(_tfjsCore.serialization.Serializable),
32369    Elu = function (e) {
32370  function t() {
32371    return null !== e && e.apply(this, arguments) || this;
32372  }
32373
32374  return __extends(t, e), t.prototype.apply = function (e, t) {
32375    return void 0 === t && (t = 1), elu$1(e, t);
32376  }, t.className = "elu", t;
32377}(Activation);
32378
32379_tfjsCore.serialization.registerClass(Elu);
32380
32381var Selu = function (e) {
32382  function t() {
32383    return null !== e && e.apply(this, arguments) || this;
32384  }
32385
32386  return __extends(t, e), t.prototype.apply = function (e) {
32387    return (0, _tfjsCore.selu)(e);
32388  }, t.className = "selu", t;
32389}(Activation);
32390
32391_tfjsCore.serialization.registerClass(Selu);
32392
32393var Relu = function (e) {
32394  function t() {
32395    return null !== e && e.apply(this, arguments) || this;
32396  }
32397
32398  return __extends(t, e), t.prototype.apply = function (e) {
32399    return (0, _tfjsCore.relu)(e);
32400  }, t.className = "relu", t;
32401}(Activation);
32402
32403_tfjsCore.serialization.registerClass(Relu);
32404
32405var Relu6 = function (e) {
32406  function t() {
32407    return null !== e && e.apply(this, arguments) || this;
32408  }
32409
32410  return __extends(t, e), t.prototype.apply = function (e) {
32411    return (0, _tfjsCore.tidy)(function () {
32412      return (0, _tfjsCore.minimum)(6, (0, _tfjsCore.relu)(e));
32413    });
32414  }, t.className = "relu6", t;
32415}(Activation);
32416
32417_tfjsCore.serialization.registerClass(Relu6);
32418
32419var Linear = function (e) {
32420  function t() {
32421    return null !== e && e.apply(this, arguments) || this;
32422  }
32423
32424  return __extends(t, e), t.prototype.apply = function (e) {
32425    return e;
32426  }, t.className = "linear", t;
32427}(Activation);
32428
32429_tfjsCore.serialization.registerClass(Linear);
32430
32431var Sigmoid = function (e) {
32432  function t() {
32433    return null !== e && e.apply(this, arguments) || this;
32434  }
32435
32436  return __extends(t, e), t.prototype.apply = function (e) {
32437    return (0, _tfjsCore.sigmoid)(e);
32438  }, t.className = "sigmoid", t;
32439}(Activation);
32440
32441_tfjsCore.serialization.registerClass(Sigmoid);
32442
32443var HardSigmoid = function (e) {
32444  function t() {
32445    return null !== e && e.apply(this, arguments) || this;
32446  }
32447
32448  return __extends(t, e), t.prototype.apply = function (e) {
32449    return hardSigmoid(e);
32450  }, t.className = "hardSigmoid", t;
32451}(Activation);
32452
32453_tfjsCore.serialization.registerClass(HardSigmoid);
32454
32455var Softplus = function (e) {
32456  function t() {
32457    return null !== e && e.apply(this, arguments) || this;
32458  }
32459
32460  return __extends(t, e), t.prototype.apply = function (e) {
32461    return (0, _tfjsCore.softplus)(e);
32462  }, t.className = "softplus", t;
32463}(Activation);
32464
32465_tfjsCore.serialization.registerClass(Softplus);
32466
32467var Softsign = function (e) {
32468  function t() {
32469    return null !== e && e.apply(this, arguments) || this;
32470  }
32471
32472  return __extends(t, e), t.prototype.apply = function (e) {
32473    return softsign(e);
32474  }, t.className = "softsign", t;
32475}(Activation);
32476
32477_tfjsCore.serialization.registerClass(Softsign);
32478
32479var Tanh = function (e) {
32480  function t() {
32481    return null !== e && e.apply(this, arguments) || this;
32482  }
32483
32484  return __extends(t, e), t.prototype.apply = function (e) {
32485    return (0, _tfjsCore.tanh)(e);
32486  }, t.className = "tanh", t;
32487}(Activation);
32488
32489_tfjsCore.serialization.registerClass(Tanh);
32490
32491var Softmax = function (e) {
32492  function t() {
32493    return null !== e && e.apply(this, arguments) || this;
32494  }
32495
32496  return __extends(t, e), t.prototype.apply = function (e, t) {
32497    return void 0 === t && (t = -1), (0, _tfjsCore.softmax)(e, t);
32498  }, t.className = "softmax", t;
32499}(Activation);
32500
32501_tfjsCore.serialization.registerClass(Softmax);
32502
32503var LogSoftmax = function (e) {
32504  function t() {
32505    return null !== e && e.apply(this, arguments) || this;
32506  }
32507
32508  return __extends(t, e), t.prototype.apply = function (e, t) {
32509    return void 0 === t && (t = -1), (0, _tfjsCore.logSoftmax)(e, t);
32510  }, t.className = "logSoftmax", t;
32511}(Activation);
32512
32513function serializeActivation(e) {
32514  return e.getClassName();
32515}
32516
32517function deserializeActivation(e, t) {
32518  return void 0 === t && (t = {}), deserializeKerasObject(e, _tfjsCore.serialization.SerializationMap.getMap().classNameMap, t, "activation");
32519}
32520
32521function getActivation(e) {
32522  var t;
32523  return null == e ? deserializeActivation(t = {
32524    className: "linear",
32525    config: {}
32526  }) : "string" == typeof e ? ((t = {}).className = e, t.config = {}, deserializeActivation(t)) : e instanceof Activation ? e : deserializeActivation(e);
32527}
32528
32529function assertObjectArgs(e) {
32530  if (null != e && "object" != typeof e) throw new Error("Argument to L1L2 regularizer's constructor is expected to be an object, but received: " + e);
32531}
32532
32533_tfjsCore.serialization.registerClass(LogSoftmax);
32534
32535var Regularizer = function (e) {
32536  function t() {
32537    return null !== e && e.apply(this, arguments) || this;
32538  }
32539
32540  return __extends(t, e), t;
32541}(_tfjsCore.serialization.Serializable),
32542    L1L2 = function (e) {
32543  function t(t) {
32544    var n = e.call(this) || this;
32545    return assertObjectArgs(t), n.l1 = null == t || null == t.l1 ? .01 : t.l1, n.l2 = null == t || null == t.l2 ? .01 : t.l2, n.hasL1 = 0 !== n.l1, n.hasL2 = 0 !== n.l2, n;
32546  }
32547
32548  return __extends(t, e), t.prototype.apply = function (e) {
32549    var t = this;
32550    return (0, _tfjsCore.tidy)(function () {
32551      var n = (0, _tfjsCore.zeros)([1]);
32552      return t.hasL1 && (n = (0, _tfjsCore.add)(n, (0, _tfjsCore.sum)((0, _tfjsCore.mul)(t.l1, (0, _tfjsCore.abs)(e))))), t.hasL2 && (n = (0, _tfjsCore.add)(n, (0, _tfjsCore.sum)((0, _tfjsCore.mul)(t.l2, square(e)))
32552)), n.asScalar();
32553    });
32554  }, t.prototype.getConfig = function () {
32555    return {
32556      l1: this.l1,
32557      l2: this.l2
32558    };
32559  }, t.fromConfig = function (e, t) {
32560    return new e({
32561      l1: t.l1,
32562      l2: t.l2
32563    });
32564  }, t.className = "L1L2", t;
32565}(Regularizer);
32566
32567function l1(e) {
32568  return assertObjectArgs(e), new L1L2({
32569    l1: null != e ? e.l1 : null,
32570    l2: 0
32571  });
32572}
32573
32574function l2(e) {
32575  return assertObjectArgs(e), new L1L2({
32576    l2: null != e ? e.l2 : null,
32577    l1: 0
32578  });
32579}
32580
32581_tfjsCore.serialization.registerClass(L1L2);
32582
32583var REGULARIZER_IDENTIFIER_REGISTRY_SYMBOL_MAP = {
32584  l1l2: "L1L2"
32585};
32586
32587function serializeRegularizer(e) {
32588  return serializeKerasObject(e);
32589}
32590
32591function deserializeRegularizer(e, t) {
32592  return void 0 === t && (t = {}), deserializeKerasObject(e, _tfjsCore.serialization.SerializationMap.getMap().classNameMap, t, "regularizer");
32593}
32594
32595function getRegularizer(e) {
32596  return null == e ? null : "string" == typeof e ? deserializeRegularizer({
32597    className: e in REGULARIZER_IDENTIFIER_REGISTRY_SYMBOL_MAP ? REGULARIZER_IDENTIFIER_REGISTRY_SYMBOL_MAP[e] : e,
32598    config: {}
32599  }) : e instanceof Regularizer ? e : deserializeRegularizer(e);
32600}
32601
32602var ReLU = function (e) {
32603  function t(t) {
32604    var n = e.call(this, null == t ? {} : t) || this;
32605    return n.supportsMasking = !0, null != t && (n.maxValue = t.maxValue), n;
32606  }
32607
32608  return __extends(t, e), t.prototype.call = function (e, t) {
32609    e = getExactlyOneTensor(e);
32610    var n = (0, _tfjsCore.relu)(e);
32611    return null != this.maxValue && (n = (0, _tfjsCore.clipByValue)(n, 0, this.maxValue)), n;
32612  }, t.prototype.computeOutputShape = function (e) {
32613    return e;
32614  }, t.prototype.getConfig = function () {
32615    var t = {
32616      maxValue: this.maxValue
32617    },
32618        n = e.prototype.getConfig.call(this);
32619    return Object.assign(t, n), t;
32620  }, t.className = "ReLU", t;
32621}(Layer);
32622
32623_tfjsCore.serialization.registerClass(ReLU);
32624
32625var LeakyReLU = function (e) {
32626  function t(t) {
32627    var n = e.call(this, null == t ? {} : t) || this;
32628    return n.DEFAULT_ALPHA = .3, null == t && (t = {}), n.alpha = null == t.alpha ? n.DEFAULT_ALPHA : t.alpha, n;
32629  }
32630
32631  return __extends(t, e), t.prototype.call = function (e, t) {
32632    var n = getExactlyOneTensor(e);
32633    return (0, _tfjsCore.leakyRelu)(n, this.alpha);
32634  }, t.prototype.computeOutputShape = function (e) {
32635    return e;
32636  }, t.prototype.getConfig = function () {
32637    var t = {
32638      alpha: this.alpha
32639    },
32640        n = e.prototype.getConfig.call(this);
32641    return Object.assign(t, n), t;
32642  }, t.className = "LeakyReLU", t;
32643}(Layer);
32644
32645_tfjsCore.serialization.registerClass(LeakyReLU);
32646
32647var PReLU = function (e) {
32648  function t(t) {
32649    var n = e.call(this, null == t ? {} : t) || this;
32650    if (n.DEFAULT_ALPHA_INITIALIZER = "zeros", null == t && (t = {}), n.supportsMasking = !0, n.alphaInitializer = getInitializer(t.alphaInitializer || n.DEFAULT_ALPHA_INITIALIZER), n.alphaRegularizer = getRegularizer(t.alphaRegularizer), n.alphaConstraint = getConstraint(t.alphaConstraint), null == t.sharedAxes) n.sharedAxes = null;else if (Array.isArray(t.sharedAxes)) n.sharedAxes = t.sharedAxes;else {
32651      if ("number" != typeof t.sharedAxes) throw new ValueError("Expected sharedAxes to be a number or an array of numbers, but got " + t.sharedAxes);
32652      n.sharedAxes = [t.sharedAxes];
32653    }
32654    return n;
32655  }
32656
32657  return __extends(t, e), t.prototype.build = function (e) {
32658    var t = (e = getExactlyOneShape(e)).slice(1);
32659    if (null != this.sharedAxes) for (var n = 0, r = this.sharedAxes; n < r.length; n++) {
32660      t[(a = r[n]) - 1] = 1;
32661    }
32662    this.alpha = this.addWeight("alpha", t, "float32", this.alphaInitializer, this.alphaRegularizer, !0, this.alphaConstraint);
32663    var i = {};
32664    if (null != this.sharedAxes) for (var a = 1; a < e.length; ++a) i[a] = e[a];
32665    this.inputSpec = [new InputSpec({
32666      ndim: e.length,
32667      axes: i
32668    })], this.built = !0;
32669  }, t.prototype.call = function (e, t) {
32670    return e = getExactlyOneTensor(e), (0, _tfjsCore.prelu)(e, this.alpha.read());
32671  }, t.prototype.getConfig = function () {
32672    var t = {
32673      alphaInitializer: serializeInitializer(this.alphaInitializer),
32674      alphaRegularizer: serializeRegularizer(this.alphaRegularizer),
32675      alphaConstraint: serializeConstraint(this.alphaConstraint),
32676      sharedAxes: this.sharedAxes
32677    },
32678        n = e.prototype.getConfig.call(this);
32679    return Object.assign(t, n), t;
32680  }, t.className = "PReLU", t;
32681}(Layer);
32682
32683_tfjsCore.serialization.registerClass(PReLU);
32684
32685var ELU = function (e) {
32686  function t(t) {
32687    var n = e.call(this, null == t ? {} : t) || this;
32688    if (n.DEFAULT_ALPHA = 1, null == t && (t = {}), null != t.alpha && t.alpha !== n.DEFAULT_ALPHA) throw new NotImplementedError("Non-default alpha value (" + t.alpha + ") is not supported by the ELU layer yet.");
32689    return n.alpha = null == t.alpha ? n.DEFAULT_ALPHA : t.alpha, n;
32690  }
32691
32692  return __extends(t, e), t.prototype.call = function (e, t) {
32693    var n = getExactlyOneTensor(e);
32694    return (0, _tfjsCore.elu)(n);
32695  }, t.prototype.computeOutputShape = function (e) {
32696    return e;
32697  }, t.prototype.getConfig = function () {
32698    var t = {
32699      alpha: this.alpha
32700    },
32701        n = e.prototype.getConfig.call(this);
32702    return Object.assign(t, n), t;
32703  }, t.className = "ELU", t;
32704}(Layer);
32705
32706_tfjsCore.serialization.registerClass(ELU);
32707
32708var ThresholdedReLU = function (e) {
32709  function t(t) {
32710    var n = e.call(this, null == t ? {} : t) || this;
32711    return n.DEFAULT_THETA = 1, null == t && (t = {}), n.theta = null == t.theta ? n.DEFAULT_THETA : t.theta, n;
32712  }
32713
32714  return __extends(t, e), t.prototype.call = function (e, t) {
32715    var n = getExactlyOneTensor(e);
32716    return n.mul(cast$1(n.greater(this.theta), "float32"));
32717  }, t.prototype.computeOutputShape = function (e) {
32718    return e;
32719  }, t.prototype.getConfig = function () {
32720    var t = {
32721      theta: this.theta
32722    },
32723        n = e.prototype.getConfig.call(this);
32724    return Object.assign(t, n), t;
32725  }, t.className = "ThresholdedReLU", t;
32726}(Layer);
32727
32728_tfjsCore.serialization.registerClass(ThresholdedReLU);
32729
32730var Softmax$1 = function (e) {
32731  function t(t) {
32732    var n = e.call(this, null == t ? {} : t) || this;
32733    return n.DEFAULT_AXIS = 1, null == t && (t = {}), n.softmax = new Softmax().apply, n.axis = null == t.axis ? n.DEFAULT_AXIS : t.axis, n;
32734  }
32735
32736  return __extends(t, e), t.prototype.call = function (e, t) {
32737    var n = getExactlyOneTensor(e);
32738    return this.softmax(n, this.axis);
32739  }, t.prototype.computeOutputShape = function (e) {
32740    return e;
32741  }, t.prototype.getConfig = function () {
32742    var t = {
32743      axis: this.axis
32744    },
32745        n = e.prototype.getConfig.call(this);
32746    return Object.assign(t, n), t;
32747  }, t.className = "Softmax", t;
32748}(Layer);
32749
32750function normalizeArray(e, t, n) {
32751  if ("number" == typeof e) return pyListRepeat(e, t);
32752  if (e.length !== t) throw new ValueError("The " + n + " argument must be an integer or tuple of " + t + " integers. Received: " + e.length + " elements.");
32753
32754  for (var r = 0; r < t; ++r) {
32755    var i = e[r];
32756    if (!isInteger(i)) throw new ValueError("The " + n + " argument must be an integer or tuple of " + t + " integers. Received: " + JSON.stringify(e) + " including a non-integer number " + i);
32757  }
32758
32759  return e;
32760}
32761
32762function convOutputLength(e, t, n, r, i) {
32763  return void 0 === i && (i = 1), null == e ? e : (a = "same" === n ? e : e - (t + (t - 1) * (i - 1)) + 1, Math.floor((a + r - 1) / r));
32764  var a;
32765}
32766
32767function deconvLength(e, t, n, r) {
32768  if (null == e) return null;
32769  if ("valid" === r) e = e * t + max$1([n - t, 0]);else {
32770    if ("same" !== r) throw new ValueError("Unsupport padding mode: " + r + ".");
32771    e *= t;
32772  }
32773  return e;
32774}
32775
32776function preprocessConv2DInput(e, t) {
32777  return (0, _tfjsCore.tidy)(function () {
32778    return checkDataFormat(t), "channelsFirst" === t ? (0, _tfjsCore.transpose)(e, [0, 2, 3, 1]) : e;
32779  });
32780}
32781
32782function preprocessConv3DInput(e, t) {
32783  return (0, _tfjsCore.tidy)(function () {
32784    return checkDataFormat(t), "channelsFirst" === t ? (0, _tfjsCore.transpose)(e, [0, 2, 3, 4, 1]) : e;
32785  });
32786}
32787
32788function conv1dWithBias(e, t, n, r, i, a, o) {
32789  return void 0 === r && (r = 1), void 0 === i && (i = "valid"), void 0 === o && (o = 1), (0, _tfjsCore.tidy)(function () {
32790    if (null == a && (a = imageDataFormat()), checkDataFormat(a), 3 !== e.shape.length) throw new ValueError("The input of a conv1dWithBias operation should be 3, but is " + e.shape.length + " instead.");
32791    if (3 !== t.shape.length) throw new ValueError("The kernel for a conv1dWithBias operation should be 3, but is " + t.shape.length + " instead");
32792    if (null != n && 1 !== n.shape.length) throw new ValueError("The bias for a conv1dWithBias operation should be 1, but is " + t.shape.length + " instead");
32793    if ("channelsFirst" === a && (e = (0, _tfjsCore.transpose)(e, [0, 2, 1])), "causal" === i) throw new NotImplementedError("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");
32794    var s = (0, _tfjsCore.conv1d)(e, t, r, "same" === i ? "same" : "valid", "NWC", o);
32795    return null != n && (s = biasAdd(s, n)), s;
32796  });
32797}
32798
32799function conv2dWithBiasActivation(e, t, n, r, i, a, o, s) {
32800  return void 0 === r && (r = [1, 1]), void 0 === i && (i = "valid"), void 0 === s && (s = null), (0, _tfjsCore.tidy)(function () {
32801    if (null == a && (a = imageDataFormat()), checkDataFormat(a), 3 !== e.rank && 4 !== e.rank) throw new ValueError("conv2dWithBiasActivation expects input to be of rank 3 or 4, but received " + e.rank + ".");
32802    if (3 !== t.rank && 4 !== t.rank) throw new ValueError("conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received " + e.rank + ".");
32803    var l = preprocessConv2DInput(e, a);
32804    if ("causal" === i) throw new NotImplementedError("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet.");
32805    return l = _tfjsCore.fused.conv2d({
32806      x: l,
32807      filter: t,
32808      strides: r,
32809      pad: "same" === i ? "same" : "valid",
32810      dilations: o,
32811      dataFormat: "NHWC",
32812      bias: n,
32813      activation: s
32814    }), "channelsFirst" === a && (l = (0, _tfjsCore.transpose)(l, [0, 3, 1, 2])), l;
32815  });
32816}
32817
32818function conv3dWithBias(e, t, n, r, i, a, o) {
32819  return void 0 === r && (r = [1, 1, 1]), void 0 === i && (i = "valid"), (0, _tfjsCore.tidy)(function () {
32820    if (null == a && (a = imageDataFormat()), checkDataFormat(a), 4 !== e.rank && 5 !== e.rank) throw new ValueError("conv3dWithBias expects input to be of rank 4 or 5, but received " + e.rank + ".");
32821    if (4 !== t.rank && 5 !== t.rank) throw new ValueError("conv3dWithBias expects kernel to be of rank 4 or 5, but received " + e.rank + ".");
32822    var s = preprocessConv3DInput(e, a);
32823    if ("causal" === i) throw new NotImplementedError("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet.");
32824    return s = (0, _tfjsCore.conv3d)(s, t, r, "same" === i ? "same" : "valid", "NDHWC", o), null != n && (s = biasAdd(s, n)), "channelsFirst" === a && (s = (0, _tfjsCore.transpose)(s, [0, 4, 1, 2, 3])), s;
32825  });
32826}
32827
32828_tfjsCore.serialization.registerClass(Softmax$1);
32829
32830var BaseConv = function (e) {
32831  function t(n, r) {
32832    var i = e.call(this, r) || this;
32833    if (i.bias = null, i.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", i.DEFAULT_BIAS_INITIALIZER = "zeros", t.verifyArgs(r), i.rank = n, assertPositiveInteger(i.rank, "rank"), 1 !== i.rank && 2 !== i.rank && 3 !== i.rank) throw new NotImplementedError("Convolution layer for rank other than 1, 2, or 3 (" + i.rank + ") is not implemented yet.");
32834    if (i.kernelSize = normalizeArray(r.kernelSize, n, "kernelSize"), i.strides = normalizeArray(null == r.strides ? 1 : r.strides, n, "strides"), i.padding = null == r.padding ? "valid" : r.padding, checkPaddingMode(i.padding), i.dataFormat = null == r.dataFormat ? "channelsLast" : r.dataFormat, checkDataFormat(i.dataFormat), i.activation = getActivation(r.activation), i.useBias = null == r.useBias || r.useBias, i.biasInitializer = getInitializer(r.biasInitializer || i.DEFAULT_BIAS_INITIALIZER), i.biasConstraint = getConstraint(r.biasConstraint), i.biasRegularizer = getRegularizer(r.biasRegularizer), i.activityRegularizer = getRegularizer(r.activityRegularizer), i.dilationRate = normalizeArray(null == r.dilationRate ? 1 : r.dilationRate, n, "dilationRate"), 1 === i.rank && Array.isArray(i.dilationRate) && 1 !== i.dilationRate.length) throw new ValueError("dilationRate must be a number or an array of a single number for 1D convolution, but received " + JSON.stringify(i.dilationRate));
32835
32836    if (2 === i.rank) {
32837      if ("number" == typeof i.dilationRate) i.dilationRate = [i.dilationRate, i.dilationRate];else if (2 !== i.dilationRate.length) throw new ValueError("dilationRate must be a number or array of two numbers for 2D convolution, but received " + JSON.stringify(i.dilationRate));
32838    } else if (3 === i.rank) if ("number" == typeof i.dilationRate) i.dilationRate = [i.dilationRate, i.dilationRate, i.dilationRate];else if (3 !== i.dilationRate.length) throw new ValueError("dilationRate must be a number or array of three numbers for 3D convolution, but received " + JSON.stringify(i.dilationRate));
32839
32840    return i;
32841  }
32842
32843  return __extends(t, e), t.verifyArgs = function (e) {
32844    if (assert("kernelSize" in e, "required key 'kernelSize' not in config"), "number" != typeof e.kernelSize && !checkArrayTypeAndLength(e.kernelSize, "number", 1, 3)) throw new ValueError("BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received " + JSON.stringify(e.kernelSize) + ".");
32845  }, t.prototype.getConfig = function () {
32846    var t = {
32847      kernelSize: this.kernelSize,
32848      strides: this.strides,
32849      padding: this.padding,
32850      dataFormat: this.dataFormat,
32851      dilationRate: this.dilationRate,
32852      activation: serializeActivation(this.activation),
32853      useBias: this.useBias,
32854      biasInitializer: serializeInitializer(this.biasInitializer),
32855      biasRegularizer: serializeRegularizer(this.biasRegularizer),
32856      activityRegularizer: serializeRegularizer(this.activityRegularizer),
32857      biasConstraint: serializeConstraint(this.biasConstraint)
32858    },
32859        n = e.prototype.getConfig.call(this);
32860    return Object.assign(t, n), t;
32861  }, t;
32862}(Layer),
32863    Conv = function (e) {
32864  function t(n, r) {
32865    var i = e.call(this, n, r) || this;
32866    return i.kernel = null, t.verifyArgs(r), i.filters = r.filters, assertPositiveInteger(i.filters, "filters"), i.kernelInitializer = getInitializer(r.kernelInitializer || i.DEFAULT_KERNEL_INITIALIZER), i.kernelConstraint = getConstraint(r.kernelConstraint), i.kernelRegularizer = getRegularizer(r.kernelRegularizer), i;
32867  }
32868
32869  return __extends(t, e), t.prototype.build = function (e) {
32870    var t;
32871    e = getExactlyOneShape(e);
32872    var n = "channelsFirst" === this.dataFormat ? 1 : e.length - 1;
32873    if (null == e[n]) throw new ValueError("The channel dimension of the input should be defined. Found " + e[n]);
32874    var r = e[n],
32875        i = this.kernelSize.concat([r, this.filters]);
32876    this.kernel = this.addWeight("kernel", i, null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.filters], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint)), this.inputSpec = [{
32877      ndim: this.rank + 2,
32878      axes: (t = {}, t[n] = r, t)
32879    }], this.built = !0;
32880  }, t.prototype.call = function (e, t) {
32881    var n = this;
32882    return (0, _tfjsCore.tidy)(function () {
32883      var t;
32884      e = getExactlyOneTensor(e);
32885      var r = null == n.bias ? null : n.bias.read(),
32886          i = mapActivationToFusedKernel(n.activation.getClassName());
32887      if (null != i && 2 === n.rank) t = conv2dWithBiasActivation(e, n.kernel.read(), r, n.strides, n.padding, n.dataFormat, n.dilationRate, i);else {
32888        if (1 === n.rank) t = conv1dWithBias(e, n.kernel.read(), r, n.strides[0], n.padding, n.dataFormat, n.dilationRate[0]);else if (2 === n.rank) t = conv2dWithBiasActivation(e, n.kernel.read(), r, n.strides, n.padding, n.dataFormat, n.dilationRate);else {
32889          if (3 !== n.rank) throw new NotImplementedError("convolutions greater than 3D are not implemented yet.");
32890          t = conv3dWithBias(e, n.kernel.read(), r, n.strides, n.padding, n.dataFormat, n.dilationRate);
32891        }
32892        null != n.activation && (t = n.activation.apply(t));
32893      }
32894      return t;
32895    });
32896  }, t.prototype.computeOutputShape = function (e) {
32897    e = getExactlyOneShape(e);
32898
32899    for (var t = [], n = "channelsLast" === this.dataFormat ? e.slice(1, e.length - 1) : e.slice(2), r = 0; r < n.length; ++r) {
32900      var i = convOutputLength(n[r], this.kernelSize[r], this.padding, this.strides[r], "number" == typeof this.dilationRate ? this.dilationRate : this.dilationRate[r]);
32901      t.push(i);
32902    }
32903
32904    var a = [e[0]];
32905    return "channelsLast" === this.dataFormat ? (a = a.concat(t)).push(this.filters) : (a.push(this.filters), a = a.concat(t)), a;
32906  }, t.prototype.getConfig = function () {
32907    var t = {
32908      filters: this.filters,
32909      kernelInitializer: serializeInitializer(this.kernelInitializer),
32910      kernelRegularizer: serializeRegularizer(this.kernelRegularizer),
32911      kernelConstraint: serializeConstraint(this.kernelConstraint)
32912    },
32913        n = e.prototype.getConfig.call(this);
32914    return Object.assign(t, n), t;
32915  }, t.verifyArgs = function (e) {
32916    if (!("filters" in e) || "number" != typeof e.filters || e.filters < 1) throw new ValueError("Convolution layer expected config.filters to be a 'number' > 0 but got " + JSON.stringify(e.filters));
32917  }, t;
32918}(BaseConv),
32919    Conv2D = function (e) {
32920  function t(n) {
32921    var r = e.call(this, 2, n) || this;
32922    return t.verifyArgs(n), r;
32923  }
32924
32925  return __extends(t, e), t.prototype.getConfig = function () {
32926    var t = e.prototype.getConfig.call(this);
32927    return delete t.rank, t;
32928  }, t.verifyArgs = function (e) {
32929    if ("number" != typeof e.kernelSize && !checkArrayTypeAndLength(e.kernelSize, "number", 1, 2)) throw new ValueError("Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received " + JSON.stringify(e.kernelSize) + ".");
32930  }, t.className = "Conv2D", t;
32931}(Conv);
32932
32933_tfjsCore.serialization.registerClass(Conv2D);
32934
32935var Conv3D = function (e) {
32936  function t(n) {
32937    var r = e.call(this, 3, n) || this;
32938    return t.verifyArgs(n), r;
32939  }
32940
32941  return __extends(t, e), t.prototype.getConfig = function () {
32942    var t = e.prototype.getConfig.call(this);
32943    return delete t.rank, t;
32944  }, t.verifyArgs = function (e) {
32945    if ("number" != typeof e.kernelSize && (!Array.isArray(e.kernelSize) || 1 !== e.kernelSize.length && 3 !== e.kernelSize.length)) throw new ValueError("Conv3D expects config.kernelSize to be number or [number, number, number], but received " + JSON.stringify(e.kernelSize) + ".");
32946  }, t.className = "Conv3D", t;
32947}(Conv);
32948
32949_tfjsCore.serialization.registerClass(Conv3D);
32950
32951var Conv2DTranspose = function (e) {
32952  function t(t) {
32953    var n = e.call(this, t) || this;
32954    if (n.inputSpec = [new InputSpec({
32955      ndim: 4
32956    })], "same" !== n.padding && "valid" !== n.padding) throw new ValueError("Conv2DTranspose currently supports only padding modes '
32956same' and 'valid', but received padding mode " + n.padding);
32957    return n;
32958  }
32959
32960  return __extends(t, e), t.prototype.build = function (e) {
32961    var t;
32962    if (4 !== (e = getExactlyOneShape(e)).length) throw new ValueError("Input should have rank 4; Received input shape: " + JSON.stringify(e));
32963    var n = "channelsFirst" === this.dataFormat ? 1 : e.length - 1;
32964    if (null == e[n]) throw new ValueError("The channel dimension of the inputs should be defined. Found `None`.");
32965    var r = e[n],
32966        i = this.kernelSize.concat([this.filters, r]);
32967    this.kernel = this.addWeight("kernel", i, "float32", this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.filters], "float32", this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint)), this.inputSpec = [new InputSpec({
32968      ndim: 4,
32969      axes: (t = {}, t[n] = r, t)
32970    })], this.built = !0;
32971  }, t.prototype.call = function (e, t) {
32972    var n = this;
32973    return (0, _tfjsCore.tidy)(function () {
32974      var t = getExactlyOneTensor(e);
32975      if (4 !== t.shape.length) throw new ValueError("Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-" + t.shape.length);
32976      var r,
32977          i,
32978          a = t.shape,
32979          o = a[0];
32980      "channelsFirst" === n.dataFormat ? (r = 2, i = 3) : (r = 1, i = 2);
32981      var s = a[r],
32982          l = a[i],
32983          u = n.kernelSize[0],
32984          c = n.kernelSize[1],
32985          p = n.strides[0],
32986          h = n.strides[1],
32987          d = [o, deconvLength(s, p, u, n.padding), deconvLength(l, h, c, n.padding), n.filters];
32988      "channelsLast" !== n.dataFormat && (t = (0, _tfjsCore.transpose)(t, [0, 2, 3, 1]));
32989      var f = (0, _tfjsCore.conv2dTranspose)(t, n.kernel.read(), d, n.strides, n.padding);
32990      return "channelsLast" !== n.dataFormat && (f = (0, _tfjsCore.transpose)(f, [0, 3, 1, 2])), null != n.bias && (f = biasAdd(f, n.bias.read(), n.dataFormat)), null != n.activation && (f = n.activation.apply(f)), f;
32991    });
32992  }, t.prototype.computeOutputShape = function (e) {
32993    var t,
32994        n,
32995        r,
32996        i = (e = getExactlyOneShape(e)).slice();
32997    "channelsFirst" === this.dataFormat ? (t = 1, n = 2, r = 3) : (t = 3, n = 1, r = 2);
32998    var a = this.kernelSize[0],
32999        o = this.kernelSize[1],
33000        s = this.strides[0],
33001        l = this.strides[1];
33002    return i[t] = this.filters, i[n] = deconvLength(i[n], s, a, this.padding), i[r] = deconvLength(i[r], l, o, this.padding), i;
33003  }, t.prototype.getConfig = function () {
33004    var t = e.prototype.getConfig.call(this);
33005    return delete t.dilationRate, t;
33006  }, t.className = "Conv2DTranspose", t;
33007}(Conv2D);
33008
33009_tfjsCore.serialization.registerClass(Conv2DTranspose);
33010
33011var SeparableConv = function (e) {
33012  function t(t, n) {
33013    var r = e.call(this, t, n) || this;
33014    if (r.DEFAULT_DEPTHWISE_INITIALIZER = "glorotUniform", r.DEFAULT_POINTWISE_INITIALIZER = "glorotUniform", r.depthwiseKernel = null, r.pointwiseKernel = null, null == n.filters) throw new ValueError("The `filters` configuration field is required by SeparableConv, but is unspecified.");
33015    if (null != n.kernelInitializer || null != n.kernelRegularizer || null != n.kernelConstraint) throw new ValueError("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead.");
33016    if (null != n.padding && "same" !== n.padding && "valid" !== n.padding) throw new ValueError("SeparableConv" + r.rank + "D supports only padding modes: 'same' and 'valid', but received " + JSON.stringify(n.padding));
33017    return r.depthMultiplier = null == n.depthMultiplier ? 1 : n.depthMultiplier, r.depthwiseInitializer = getInitializer(n.depthwiseInitializer || r.DEFAULT_DEPTHWISE_INITIALIZER), r.depthwiseRegularizer = getRegularizer(n.depthwiseRegularizer), r.depthwiseConstraint = getConstraint(n.depthwiseConstraint), r.pointwiseInitializer = getInitializer(n.depthwiseInitializer || r.DEFAULT_POINTWISE_INITIALIZER), r.pointwiseRegularizer = getRegularizer(n.pointwiseRegularizer), r.pointwiseConstraint = getConstraint(n.pointwiseConstraint), r;
33018  }
33019
33020  return __extends(t, e), t.prototype.build = function (e) {
33021    var t;
33022    if ((e = getExactlyOneShape(e)).length < this.rank + 2) throw new ValueError("Inputs to SeparableConv" + this.rank + "D should have rank " + (this.rank + 2) + ", but received input shape: " + JSON.stringify(e));
33023    var n = "channelsFirst" === this.dataFormat ? 1 : e.length - 1;
33024    if (null == e[n] || e[n] < 0) throw new ValueError("The channel dimension of the inputs should be defined, but found " + JSON.stringify(e[n]));
33025
33026    for (var r = e[n], i = this.kernelSize.concat([r, this.depthMultiplier]), a = [], o = 0; o < this.rank; ++o) a.push(1);
33027
33028    a.push(r * this.depthMultiplier, this.filters);
33029    this.depthwiseKernel = this.addWeight("depthwise_kernel", i, "float32", this.depthwiseInitializer, this.depthwiseRegularizer, !0, this.depthwiseConstraint), this.pointwiseKernel = this.addWeight("pointwise_kernel", a, "float32", this.pointwiseInitializer, this.pointwiseRegularizer, !0, this.pointwiseConstraint), this.useBias ? this.bias = this.addWeight("bias", [this.filters], "float32", this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.inputSpec = [new InputSpec({
33030      ndim: this.rank + 2,
33031      axes: (t = {}, t[n] = r, t)
33032    })], this.built = !0;
33033  }, t.prototype.call = function (e, t) {
33034    var n = this;
33035    return (0, _tfjsCore.tidy)(function () {
33036      var t;
33037      if (e = getExactlyOneTensor(e), 1 === n.rank) throw new NotImplementedError("1D separable convolution is not implemented yet.");
33038      return 2 === n.rank && ("channelsFirst" === n.dataFormat && (e = (0, _tfjsCore.transpose)(e, [0, 2, 3, 1])), t = (0, _tfjsCore.separableConv2d)(e, n.depthwiseKernel.read(), n.pointwiseKernel.read(), n.strides, n.padding, n.dilationRate, "NHWC")), n.useBias && (t = biasAdd(t, n.bias.read(), n.dataFormat)), null != n.activation && (t = n.activation.apply(t)), "channelsFirst" === n.dataFormat && (t = (0, _tfjsCore.transpose)(t, [0, 3, 1, 2])), t;
33039    });
33040  }, t.prototype.getConfig = function () {
33041    var t = e.prototype.getConfig.call(this);
33042    return delete t.rank, delete t.kernelInitializer, delete t.kernelRegularizer, delete t.kernelConstraint, t.depthwiseInitializer = serializeInitializer(this.depthwiseInitializer), t.pointwiseInitializer = serializeInitializer(this.pointwiseInitializer), t.depthwiseRegularizer = serializeRegularizer(this.depthwiseRegularizer), t.pointwiseRegularizer = serializeRegularizer(this.pointwiseRegularizer), t.depthwiseConstraint = serializeConstraint(this.depthwiseConstraint), t.pointwiseConstraint = serializeConstraint(this.pointwiseConstraint), t;
33043  }, t.className = "SeparableConv", t;
33044}(Conv),
33045    SeparableConv2D = function (e) {
33046  function t(t) {
33047    return e.call(this, 2, t) || this;
33048  }
33049
33050  return __extends(t, e), t.className = "SeparableConv2D", t;
33051}(SeparableConv);
33052
33053_tfjsCore.serialization.registerClass(SeparableConv2D);
33054
33055var Conv1D = function (e) {
33056  function t(n) {
33057    var r = e.call(this, 1, n) || this;
33058    return t.verifyArgs(n), r.inputSpec = [{
33059      ndim: 3
33060    }], r;
33061  }
33062
33063  return __extends(t, e), t.prototype.getConfig = function () {
33064    var t = e.prototype.getConfig.call(this);
33065    return delete t.rank, delete t.dataFormat, t;
33066  }, t.verifyArgs = function (e) {
33067    if ("number" != typeof e.kernelSize && !checkArrayTypeAndLength(e.kernelSize, "number", 1, 1)) throw new ValueError("Conv1D expects config.kernelSize to be number or number[] with length 1, but received " + JSON.stringify(e.kernelSize) + ".");
33068  }, t.className = "Conv1D", t;
33069}(Conv);
33070
33071_tfjsCore.serialization.registerClass(Conv1D);
33072
33073var Cropping2D = function (e) {
33074  function t(t) {
33075    var n = e.call(this, t) || this;
33076    return "number" == typeof t.cropping ? n.cropping = [[t.cropping, t.cropping], [t.cropping, t.cropping]] : "number" == typeof t.cropping[0] ? n.cropping = [[t.cropping[0], t.cropping[0]], [t.cropping[1], t.cropping[1]]] : n.cropping = t.cropping, n.dataFormat = void 0 === t.dataFormat ? "channelsLast" : t.dataFormat, n.inputSpec = [{
33077      ndim: 4
33078    }], n;
33079  }
33080
33081  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
33082    return "channelsFirst" === this.dataFormat ? [e[0], e[1], e[2] - this.cropping[0][0] - this.cropping[0][1], e[3] - this.cropping[1][0] - this.cropping[1][1]] : [e[0], e[1] - this.cropping[0][0] - this.cropping[0][1], e[2] - this.cropping[1][0] - this.cropping[1][1], e[3]];
33083  }, t.prototype.call = function (e, t) {
33084    var n = this;
33085    return (0, _tfjsCore.tidy)(function () {
33086      return e = getExactlyOneTensor(e), "channelsLast" === n.dataFormat ? sliceAlongAxis(sliceAlongAxis(e, n.cropping[0][0], e.shape[1] - n.cropping[0][0] - n.cropping[0][1], 2), n.cropping[1][0], e.shape[2] - n.cropping[1][1] - n.cropping[1][0], 3) : sliceAlongAxis(sliceAlongAxis(e, n.cropping[0][0], e.shape[2] - n.cropping[0][0] - n.cropping[0][1], 3), n.cropping[1][0], e.shape[3] - n.cropping[1][1] - n.cropping[1][0], 4);
33087    });
33088  }, t.prototype.getConfig = function () {
33089    var t = {
33090      cropping: this.cropping,
33091      dataFormat: this.dataFormat
33092    },
33093        n = e.prototype.getConfig.call(this);
33094    return Object.assign(t, n), t;
33095  }, t.className = "Cropping2D", t;
33096}(Layer);
33097
33098_tfjsCore.serialization.registerClass(Cropping2D);
33099
33100var UpSampling2D = function (e) {
33101  function t(t) {
33102    var n = e.call(this, t) || this;
33103    return n.DEFAULT_SIZE = [2, 2], n.inputSpec = [{
33104      ndim: 4
33105    }], n.size = null == t.size ? n.DEFAULT_SIZE : t.size, n.dataFormat = null == t.dataFormat ? "channelsLast" : t.dataFormat, n;
33106  }
33107
33108  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
33109    if ("channelsFirst" === this.dataFormat) {
33110      var t = null == e[2] ? null : this.size[0] * e[2],
33111          n = null == e[3] ? null : this.size[1] * e[3];
33112      return [e[0], e[1], t, n];
33113    }
33114
33115    t = null == e[1] ? null : this.size[0] * e[1], n = null == e[2] ? null : this.size[1] * e[2];
33116    return [e[0], t, n, e[3]];
33117  }, t.prototype.call = function (e, t) {
33118    var n = this;
33119    return (0, _tfjsCore.tidy)(function () {
33120      var t = getExactlyOneTensor(e),
33121          r = t.shape;
33122
33123      if ("channelsFirst" === n.dataFormat) {
33124        t = (0, _tfjsCore.transpose)(t, [0, 2, 3, 1]);
33125        var i = n.size[0] * r[2],
33126            a = n.size[1] * r[3],
33127            o = t.resizeNearestNeighbor([i, a]);
33128        return (0, _tfjsCore.transpose)(o, [0, 3, 1, 2]);
33129      }
33130
33131      i = n.size[0] * r[1], a = n.size[1] * r[2];
33132      return t.resizeNearestNeighbor([i, a]);
33133    });
33134  }, t.prototype.getConfig = function () {
33135    var t = {
33136      size: this.size,
33137      dataFormat: this.dataFormat
33138    },
33139        n = e.prototype.getConfig.call(this);
33140    return Object.assign(t, n), t;
33141  }, t.className = "UpSampling2D", t;
33142}(Layer);
33143
33144function depthwiseConv2d$1(e, t, n, r, i, a) {
33145  return void 0 === n && (n = [1, 1]), void 0 === r && (r = "valid"), (0, _tfjsCore.tidy)(function () {
33146    null == i && (i = imageDataFormat()), checkDataFormat(i);
33147    var o = preprocessConv2DInput(e, i);
33148    if (4 !== e.rank) throw new ValueError("Input for depthwiseConv2d is required to be 4-D, but is instead " + e.rank + "-D");
33149    if (4 !== t.rank) throw new ValueError("depthwiseKernel is required to be 4-D, but is instead " + t.rank + "-D");
33150    return o = (0, _tfjsCore.depthwiseConv2d)(o, t, n, "same" === r ? "same" : "valid", "NHWC", a), "channelsFirst" === i && (o = (0, _tfjsCore.transpose)(o, [0, 3, 1, 2])), o;
33151  });
33152}
33153
33154_tfjsCore.serialization.registerClass(UpSampling2D);
33155
33156var DepthwiseConv2D = function (e) {
33157  function t(t) {
33158    var n = e.call(this, 2, t) || this;
33159    return n.depthwiseKernel = null, n.depthMultiplier = null == t.depthMultiplier ? 1 : t.depthMultiplier, n.depthwiseInitializer = getInitializer(t.depthwiseInitializer || n.DEFAULT_KERNEL_INITIALIZER), n.depthwiseConstraint = getConstraint(t.depthwiseConstraint), n.depthwiseRegularizer = getRegularizer(t.depthwiseRegularizer), n;
33160  }
33161
33162  return __extends(t, e), t.prototype.build = function (e) {
33163    if ((e = getExactlyOneShape(e)).length < 4) throw new ValueError("Inputs to DepthwiseConv2D should have rank 4. Received input shape: " + JSON.stringify(e) + ".");
33164    var t = "channelsFirst" === this.dataFormat ? 1 : 3;
33165    if (null == e[t] || e[t] < 0) throw new ValueError("The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (" + e[t] + ").");
33166    var n = e[t],
33167        r = [this.kernelSize[0], this.kernelSize[1], n, this.depthMultiplier];
33168    this.depthwiseKernel = this.addWeight("depthwise_kernel", r, null, this.depthwiseInitializer, this.depthwiseRegularizer, !0, this.depthwiseConstraint), this.useBias ? this.bias = this.addWeight("bias", [n * this.depthMultiplier], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.built = !0;
33169  }, t.prototype.call = function (e, t) {
33170    var n = this;
33171    return (0, _tfjsCore.tidy)(function () {
33172      var t = depthwiseConv2d$1(e = getExactlyOneTensor(e), n.depthwiseKernel.read(), n.strides, n.padding, n.dataFormat, null);
33173      return n.useBias && (t = biasAdd(t, n.bias.read(), n.dataFormat)), null != n.activation && (t = n.activation.apply(t)), t;
33174    });
33175  }, t.prototype.computeOutputShape = function (e) {
33176    e = getExactlyOneShape(e);
33177    var t = "channelsFirst" === this.dataFormat ? e[2] : e[1],
33178        n = "channelsFirst" === this.dataFormat ? e[3] : e[2],
33179        r = "channelsFirst" === this.dataFormat ? e[1] * this.depthMultiplier : e[3] * this.depthMultiplier,
33180        i = convOutputLength(t, this.kernelSize[0], this.padding, this.strides[0]),
33181        a = convOutputLength(n, this.kernelSize[1], this.padding, this.strides[1]);
33182    return "channelsFirst" === this.dataFormat ? [e[0], r, i, a] : [e[0], i, a, r];
33183  }, t.prototype.getConfig = function () {
33184    var t = e.prototype.getConfig.call(this);
33185    return t.depthMultiplier = this.depthMultiplier, t.depthwiseInitializer = serializeInitializer(this.depthwiseInitializer), t.depthwiseRegularizer = serializeRegularizer(this.depthwiseRegularizer), t.depthwiseConstraint = serializeConstraint(this.depthwiseRegularizer), t;
33186  }, t.className = "DepthwiseConv2D", t;
33187}(BaseConv);
33188
33189_tfjsCore.serialization.registerClass(DepthwiseConv2D);
33190
33191var Dropout = function (e) {
33192  function t(t) {
33193    var n = e.call(this, t) || this;
33194    return n.rate = Math.max(Math.min(t.rate, 1), 0), n.noiseShape = t.noiseShape, n.seed = t.seed, n.supportsMasking = !0, n;
33195  }
33196
33197  return __extends(t, e), t.prototype.getNoiseShape = function (e) {
33198    if (null == this.noiseShape) return this.noiseShape;
33199
33200    for (var t = e.shape, n = [], r = 0; r < this.noiseShape.length; ++r) n.push(null == this.noiseShape[r] ? t[r] : this.noiseShape[r]);
33201
33202    return n;
33203  }, t.prototype.call = function (e, t) {
33204    var n = this;
33205    return (0, _tfjsCore.tidy)(function () {
33206      n.invokeCallHook(e, t);
33207      var r = getExactlyOneTensor(e);
33208
33209      if (0 < n.rate && n.rate < 1) {
33210        var i = null != t.training && t.training,
33211            a = n.getNoiseShape(r);
33212        return inTrainPhase(function () {
33213          return dropout$1(r, n.rate, a, n.seed);
33214        }, function () {
33215          return r;
33216        }, i);
33217      }
33218
33219      return e;
33220    });
33221  }, t.prototype.getConfig = function () {
33222    var t = {
33223      rate: this.rate,
33224      noiseShape: this.noiseShape,
33225      seed: this.seed
33226    },
33227        n = e.prototype.getConfig.call(this);
33228    return Object.assign(t, n), t;
33229  }, t.prototype.dispose = function () {
33230    return e.prototype.dispose.call(this);
33231  }, t.className = "Dropout", t;
33232}(Layer);
33233
33234_tfjsCore.serialization.registerClass(Dropout);
33235
33236var SpatialDropout1D = function (e) {
33237  function t(t) {
33238    var n = e.call(this, t) || this;
33239    return n.inputSpec = [{
33240      ndim: 3
33241    }], n;
33242  }
33243
33244  return __extends(t, e), t.prototype.getNoiseShape = function (e) {
33245    var t = e.shape;
33246    return [t[0], 1, t[2]];
33247  }, t.className = "SpatialDropout1D", t;
33248}(Dropout);
33249
33250_tfjsCore.serialization.registerClass(SpatialDropout1D);
33251
33252var Dense = function (e) {
33253  function t(t) {
33254    var n = e.call(this, t) || this;
33255
33256    if (n.activation = null, n.useBias = !0, n.kernel = null, n.bias = null, n.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", n.DEFAULT_BIAS_INITIALIZER = "zeros", null == t.batchInputShape && null == t.inputShape && null != t.inputDim) {
33257      var r = null;
33258      null != t.batchSize && (r = t.batchSize), n.batchInputShape = [r, t.inputDim];
33259    }
33260
33261    return n.units = t.units, assertPositiveInteger(n.units, "units"), n.activation = getActivation(t.activation), null != t.useBias && (n.useBias = t.useBias), n.kernelInitializer = getInitializer(t.kernelInitializer || n.DEFAULT_KERNEL_INITIALIZER), n.bi
33261asInitializer = getInitializer(t.biasInitializer || n.DEFAULT_BIAS_INITIALIZER), n.kernelConstraint = getConstraint(t.kernelConstraint), n.biasConstraint = getConstraint(t.biasConstraint), n.kernelRegularizer = getRegularizer(t.kernelRegularizer), n.biasRegularizer = getRegularizer(t.biasRegularizer), n.activityRegularizer = getRegularizer(t.activityRegularizer), n.supportsMasking = !0, n.inputSpec = [{
33262      minNDim: 2
33263    }], n;
33264  }
33265
33266  return __extends(t, e), t.prototype.build = function (e) {
33267    var t,
33268        n = (e = getExactlyOneShape(e))[e.length - 1];
33269    null == this.kernel && (this.kernel = this.addWeight("kernel", [n, this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.units], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint))), this.inputSpec = [{
33270      minNDim: 2,
33271      axes: (t = {}, t[-1] = n, t)
33272    }], this.built = !0;
33273  }, t.prototype.computeOutputShape = function (e) {
33274    var t = (e = getExactlyOneShape(e)).slice();
33275    return t[t.length - 1] = this.units, t;
33276  }, t.prototype.call = function (e, t) {
33277    var n = this;
33278    return (0, _tfjsCore.tidy)(function () {
33279      n.invokeCallHook(e, t);
33280      var r,
33281          i = getExactlyOneTensor(e),
33282          a = mapActivationToFusedKernel(n.activation.getClassName());
33283      return null != a ? r = dot(i, n.kernel.read(), a, n.bias ? n.bias.read() : null) : (r = dot(i, n.kernel.read()), null != n.bias && (r = biasAdd(r, n.bias.read())), null != n.activation && (r = n.activation.apply(r))), r;
33284    });
33285  }, t.prototype.getConfig = function () {
33286    var t = {
33287      units: this.units,
33288      activation: serializeActivation(this.activation),
33289      useBias: this.useBias,
33290      kernelInitializer: serializeInitializer(this.kernelInitializer),
33291      biasInitializer: serializeInitializer(this.biasInitializer),
33292      kernelRegularizer: serializeRegularizer(this.kernelRegularizer),
33293      biasRegularizer: serializeRegularizer(this.biasRegularizer),
33294      activityRegularizer: serializeRegularizer(this.activityRegularizer),
33295      kernelConstraint: serializeConstraint(this.kernelConstraint),
33296      biasConstraint: serializeConstraint(this.biasConstraint)
33297    },
33298        n = e.prototype.getConfig.call(this);
33299    return Object.assign(t, n), t;
33300  }, t.className = "Dense", t;
33301}(Layer);
33302
33303_tfjsCore.serialization.registerClass(Dense);
33304
33305var Flatten = function (e) {
33306  function t(t) {
33307    var n = this;
33308    return t = t || {}, (n = e.call(this, t) || this).inputSpec = [{
33309      minNDim: 3
33310    }], n.dataFormat = t.dataFormat, n;
33311  }
33312
33313  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
33314    for (var t = 0, n = (e = getExactlyOneShape(e)).slice(1); t < n.length; t++) {
33315      if (null == n[t]) throw new ValueError('The shape of the input to "Flatten" is not fully defined (got ' + e.slice(1) + '). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.');
33316    }
33317
33318    return [e[0], arrayProd(e, 1)];
33319  }, t.prototype.call = function (e, t) {
33320    var n = this;
33321    return (0, _tfjsCore.tidy)(function () {
33322      n.invokeCallHook(e, t);
33323      var r = getExactlyOneTensor(e);
33324
33325      if ("channelsFirst" === n.dataFormat && r.rank > 1) {
33326        for (var i = [0], a = 2; a < r.rank; ++a) i.push(a);
33327
33328        i.push(1), r = r.transpose(i);
33329      }
33330
33331      return batchFlatten(r);
33332    });
33333  }, t.prototype.getConfig = function () {
33334    var t = {};
33335    null != this.dataFormat && (t.dataFormat = this.dataFormat);
33336    var n = e.prototype.getConfig.call(this);
33337    return Object.assign(t, n), t;
33338  }, t.className = "Flatten", t;
33339}(Layer);
33340
33341_tfjsCore.serialization.registerClass(Flatten);
33342
33343var Activation$1 = function (e) {
33344  function t(t) {
33345    var n = e.call(this, t) || this;
33346    return n.supportsMasking = !0, n.activation = getActivation(t.activation), n;
33347  }
33348
33349  return __extends(t, e), t.prototype.call = function (e, t) {
33350    var n = this;
33351    return (0, _tfjsCore.tidy)(function () {
33352      n.invokeCallHook(e, t);
33353      var r = getExactlyOneTensor(e);
33354      return n.activation.apply(r);
33355    });
33356  }, t.prototype.getConfig = function () {
33357    var t = {
33358      activation: serializeActivation(this.activation)
33359    },
33360        n = e.prototype.getConfig.call(this);
33361    return Object.assign(t, n), t;
33362  }, t.className = "Activation", t;
33363}(Layer);
33364
33365_tfjsCore.serialization.registerClass(Activation$1);
33366
33367var RepeatVector = function (e) {
33368  function t(t) {
33369    var n = e.call(this, t) || this;
33370    return n.n = t.n, n.inputSpec = [{
33371      ndim: 2
33372    }], n;
33373  }
33374
33375  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
33376    return [e[0], this.n, e[1]];
33377  }, t.prototype.call = function (e, t) {
33378    var n = this;
33379    return (0, _tfjsCore.tidy)(function () {
33380      return repeat(e = getExactlyOneTensor(e), n.n);
33381    });
33382  }, t.prototype.getConfig = function () {
33383    var t = {
33384      n: this.n
33385    },
33386        n = e.prototype.getConfig.call(this);
33387    return Object.assign(t, n), t;
33388  }, t.className = "RepeatVector", t;
33389}(Layer);
33390
33391_tfjsCore.serialization.registerClass(RepeatVector);
33392
33393var Reshape = function (e) {
33394  function t(t) {
33395    var n = e.call(this, t) || this;
33396    n.targetShape = t.targetShape;
33397
33398    for (var r = 0; r < n.targetShape.length; ++r) n.isUnknown(n.targetShape[r]) && (n.targetShape[r] = null);
33399
33400    return n;
33401  }
33402
33403  return __extends(t, e), t.prototype.isUnknown = function (e) {
33404    return e < 0 || null == e;
33405  }, t.prototype.fixUnknownDimension = function (e, t) {
33406    for (var n = "Total size of new array must be unchanged.", r = t.slice(), i = 1, a = null, o = 0; o < r.length; ++o) {
33407      var s = r[o];
33408
33409      if (this.isUnknown(s)) {
33410        if (null !== a) throw new ValueError("Can only specifiy one unknown dimension.");
33411        a = o;
33412      } else i *= s;
33413    }
33414
33415    var l = arrayProd(e);
33416
33417    if (null !== a) {
33418      if (0 === i || l % i != 0) throw new ValueError(n);
33419      r[a] = l / i;
33420    } else if (l !== i) throw new ValueError(n);
33421
33422    return r;
33423  }, t.prototype.computeOutputShape = function (e) {
33424    for (var t = !1, n = 0; n < e.length; ++n) if (this.isUnknown(e[n])) {
33425      t = !0;
33426      break;
33427    }
33428
33429    return t ? e.slice(0, 1).concat(this.targetShape) : e.slice(0, 1).concat(this.fixUnknownDimension(e.slice(1), this.targetShape));
33430  }, t.prototype.call = function (e, t) {
33431    var n = this;
33432    return (0, _tfjsCore.tidy)(function () {
33433      n.invokeCallHook(e, t);
33434      var r = getExactlyOneTensor(e),
33435          i = r.shape,
33436          a = i.slice(0, 1).concat(n.fixUnknownDimension(i.slice(1), n.targetShape));
33437      return r.reshape(a);
33438    });
33439  }, t.prototype.getConfig = function () {
33440    var t = {
33441      targetShape: this.targetShape
33442    },
33443        n = e.prototype.getConfig.call(this);
33444    return Object.assign(t, n), t;
33445  }, t.className = "Reshape", t;
33446}(Layer);
33447
33448_tfjsCore.serialization.registerClass(Reshape);
33449
33450var Permute = function (e) {
33451  function t(t) {
33452    var n = e.call(this, t) || this;
33453    if (null == t.dims) throw new Error("Required configuration field `dims` is missing during Permute constructor call.");
33454    if (!Array.isArray(t.dims)) throw new Error("Permute constructor requires `dims` to be an Array, but received " + t.dims + " instead.");
33455    var r = range(1, t.dims.length + 1);
33456    if (!_tfjsCore.util.arraysEqual(t.dims.slice().sort(), r)) throw new Error("Invalid permutation `dims`: " + JSON.stringify(t.dims) + " `dims` must contain consecutive integers starting from 1.");
33457    return n.dims = t.dims, n.dimsIncludingBatch = [0].concat(n.dims), n.inputSpec = [new InputSpec({
33458      ndim: n.dims.length + 1
33459    })], n;
33460  }
33461
33462  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
33463    var t = (e = getExactlyOneShape(e)).slice();
33464    return this.dims.forEach(function (n, r) {
33465      t[r + 1] = e[n];
33466    }), t;
33467  }, t.prototype.call = function (e, t) {
33468    return (0, _tfjsCore.transpose)(getExactlyOneTensor(e), this.dimsIncludingBatch);
33469  }, t.prototype.getConfig = function () {
33470    var t = {
33471      dims: this.dims
33472    },
33473        n = e.prototype.getConfig.call(this);
33474    return Object.assign(t, n), t;
33475  }, t.className = "Permute", t;
33476}(Layer);
33477
33478_tfjsCore.serialization.registerClass(Permute);
33479
33480var Masking = function (e) {
33481  function t(t) {
33482    var n = e.call(this, null == t ? {} : t) || this;
33483    return n.supportsMasking = !0, n.maskValue = null != t ? null == t.maskValue ? 0 : t.maskValue : 0, n;
33484  }
33485
33486  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
33487    return e;
33488  }, t.prototype.getConfig = function () {
33489    var t = e.prototype.getConfig.call(this),
33490        n = {
33491      maskValue: this.maskValue
33492    };
33493    return Object.assign(n, t), n;
33494  }, t.prototype.computeMask = function (e, t) {
33495    var n = getExactlyOneTensor(e);
33496    return (0, _tfjsCore.any)((0, _tfjsCore.notEqual)(n, this.maskValue), -1);
33497  }, t.prototype.call = function (e, t) {
33498    var n = this;
33499    return (0, _tfjsCore.tidy)(function () {
33500      n.invokeCallHook(e, t);
33501      var r = getExactlyOneTensor(e),
33502          i = (0, _tfjsCore.any)((0, _tfjsCore.notEqual)(r, n.maskValue), -1, !0);
33503      return r.mul(i.asType(r.dtype));
33504    });
33505  }, t.className = "Masking", t;
33506}(Layer);
33507
33508_tfjsCore.serialization.registerClass(Masking);
33509
33510var Embedding = function (e) {
33511  function t(t) {
33512    var n = e.call(this, t) || this;
33513
33514    if (n.embeddings = null, n.DEFAULT_EMBEDDINGS_INITIALIZER = "randomUniform", null == t.batchInputShape && null == t.inputShape) {
33515      var r = null;
33516      null != t.batchSize && (r = t.batchSize), null == t.inputLength ? n.batchInputShape = [r, null] : n.batchInputShape = [r].concat(toList(t.inputLength));
33517    }
33518
33519    return n.inputDim = t.inputDim, assertPositiveInteger(n.inputDim, "inputDim"), n.outputDim = t.outputDim, assertPositiveInteger(n.outputDim, "outputDim"), n.embeddingsInitializer = getInitializer(t.embeddingsInitializer || n.DEFAULT_EMBEDDINGS_INITIALIZER), n.embeddingsRegularizer = getRegularizer(t.embeddingsRegularizer), n.activityRegularizer = getRegularizer(t.activityRegularizer), n.embeddingsConstraint = getConstraint(t.embeddingsConstraint), n.maskZero = t.maskZero, n.supportsMasking = t.maskZero, n.inputLength = t.inputLength, n;
33520  }
33521
33522  return __extends(t, e), t.prototype.build = function (e) {
33523    this.embeddings = this.addWeight("embeddings", [this.inputDim, this.outputDim], this.dtype, this.embeddingsInitializer, this.embeddingsRegularizer, !0, this.embeddingsConstraint), this.built = !0;
33524  }, t.prototype.warnOnIncompatibleInputShape = function (e) {}, t.prototype.computeMask = function (e, t) {
33525    var n = this;
33526    return (0, _tfjsCore.tidy)(function () {
33527      return n.maskZero ? (e = getExactlyOneTensor(e), (0, _tfjsCore.notEqual)(e, (0, _tfjsCore.zerosLike)(e))) : null;
33528    });
33529  }, t.prototype.computeOutputShape = function (e) {
33530    if (e = getExactlyOneShape(e), null == this.inputLength) return e.concat([this.outputDim]);
33531    var t = toList(this.inputLength);
33532    if (t.length !== e.length - 1) throw new ValueError('"inputLength" is ' + this.inputLength + ", but received input shape has shape " + e);
33533
33534    for (var n = 0, r = 0; r < t.length; ++r) {
33535      var i = t[r],
33536          a = e[r + 1];
33537      if (null != i && null != a && i !== a) throw new ValueError('"inputLength" is ' + this.inputLength + ", but received input shape has shape " + e);
33538      null == i && (t[n] = a), n++;
33539    }
33540
33541    return [e[0]].concat(t, [this.outputDim]);
33542  }, t.prototype.call = function (e, t) {
33543    var n = this;
33544    return (0, _tfjsCore.tidy)(function () {
33545      n.invokeCallHook(e, t);
33546      var r = getExactlyOneTensor(e);
33547      return "int32" !== r.dtype && (r = cast$1(r, "int32")), gather$1(n.embeddings.read(), r.as1D()).reshape(getExactlyOneShape(n.computeOutputShape(r.shape)));
33548    });
33549  }, t.prototype.getConfig = function () {
33550    var t = {
33551      inputDim: this.inputDim,
33552      outputDim: this.outputDim,
33553      embeddingsInitializer: serializeInitializer(this.embeddingsInitializer),
33554      embeddingsRegularizer: serializeRegularizer(this.embeddingsRegularizer),
33555      activityRegularizer: serializeRegularizer(this.activityRegularizer),
33556      embeddingsConstraint: serializeConstraint(this.embeddingsConstraint),
33557      maskZero: this.maskZero,
33558      inputLength: this.inputLength
33559    },
33560        n = e.prototype.getConfig.call(this);
33561    return Object.assign(t, n), t;
33562  }, t.className = "Embedding", t;
33563}(Layer);
33564
33565_tfjsCore.serialization.registerClass(Embedding);
33566
33567var Merge = function (e) {
33568  function t(t) {
33569    var n = e.call(this, t || {}) || this;
33570    return n.supportsMasking = !0, n;
33571  }
33572
33573  return __extends(t, e), t.prototype.mergeFunction = function (e) {
33574    throw new NotImplementedError();
33575  }, t.prototype.computeElementwiseOpOutputShape = function (e, t) {
33576    if (null == e || null == t) return null;
33577    if (e.length < t.length) return this.computeElementwiseOpOutputShape(t, e);
33578    if (0 === t.length) return e;
33579
33580    for (var n = e.slice(0, e.length - t.length), r = 0; r < t.length; ++r) {
33581      var i = e[e.length - t.length + r],
33582          a = t[r];
33583      if (null == i || null == a || i < 0 || a < 0) n.push(null);else if (1 === i) n.push(a);else if (1 === a) n.push(i);else {
33584        if (i !== a) throw new ValueError("Operands could not be broadcast together with shapes " + JSON.stringify(e) + " " + JSON.stringify(t));
33585        n.push(i);
33586      }
33587    }
33588
33589    return n;
33590  }, t.prototype.build = function (e) {
33591    if (Array.isArray(e) && !Array.isArray(e[0]) && (e = [getExactlyOneShape(e)]), (e = e).length < 2) throw new ValueError("A merge layer should be called on an Array of at least 2 inputs. Got " + e.length + " input(s).");
33592
33593    for (var t = [], n = 0, r = e; n < r.length; n++) {
33594      null != (o = r[n]) && null !== o[0] && t.push(o[0]);
33595    }
33596
33597    if ((t = unique(t)).length > 1) throw new ValueError("Can not merge tensors with different batch sizes. Got tensors with shapes: " + JSON.stringify(e) + ".");
33598
33599    for (var i = null == e[0] ? null : e[0].slice(1), a = 1; a < e.length; ++a) {
33600      var o = null == e[a] ? null : e[a].slice(1);
33601      i = this.computeElementwiseOpOutputShape(i, o);
33602    }
33603
33604    var s = e.map(function (e) {
33605      return e.length;
33606    });
33607    -1 === e.indexOf(null) && 1 === unique(s).length ? this.reshapeRequired = !1 : this.reshapeRequired = !0;
33608  }, t.prototype.call = function (e, t) {
33609    var n = this;
33610    return (0, _tfjsCore.tidy)(function () {
33611      if (e = e, n.reshapeRequired) {
33612        var t = [],
33613            r = e.map(function (e) {
33614          return e.rank;
33615        });
33616
33617        if (-1 === r.indexOf(null)) {
33618          for (var i = max$1(r), a = 0, o = e; a < o.length; a++) {
33619            for (var s = (h = o[a]).rank, l = 0; l < i - s;
33619 ++l) h = expandDims$1(h, 1);
33620
33621            t.push(h);
33622          }
33623
33624          return n.mergeFunction(t);
33625        }
33626
33627        for (var u = !1, c = 0, p = e; c < p.length; c++) {
33628          var h;
33629
33630          if (null == (s = (h = p[c]).rank)) {
33631            var d = h.shape,
33632                f = d[0],
33633                g = d.slice(1).concat([f]),
33634                m = h.reshape([f].concat(arrayProd(d.slice(1))));
33635            m = (m = (0, _tfjsCore.transpose)(m, [1, 0])).reshape(g), t.push(m), u = !0;
33636          } else if (s > 1) {
33637            var y = range(1, s).concat([0]);
33638            t.push((0, _tfjsCore.transpose)(h, y)), u = !0;
33639          } else t.push(h);
33640        }
33641
33642        var v = n.mergeFunction(t),
33643            b = v.rank;
33644        if (u) if (null == b) {
33645          var w = v.shape;
33646          g = [f = w[w.length - 1]].concat(w.slice(0, w.length - 1));
33647          v = (0, _tfjsCore.transpose)(v.reshape([-1, f]), [1, 0]).reshape(g);
33648        } else if (b > 1) {
33649          y = [b - 1].concat(range(0, b - 1));
33650          v = (0, _tfjsCore.transpose)(v, y);
33651        }
33652        return v;
33653      }
33654
33655      return n.mergeFunction(e);
33656    });
33657  }, t.prototype.computeOutputShape = function (e) {
33658    var t;
33659    t = null == (e = e)[0] ? null : e[0].slice(1);
33660
33661    for (var n = 1; n < e.length; ++n) {
33662      var r = null == e[n] ? null : e[n].slice(1);
33663      t = this.computeElementwiseOpOutputShape(t, r);
33664    }
33665
33666    for (var i = [], a = 0, o = e; a < o.length; a++) {
33667      null != (r = o[a]) && null !== r[0] && i.push(r[0]);
33668    }
33669
33670    return t = 1 === (i = unique(i)).length ? i.concat(t) : [null].concat(t);
33671  }, t.prototype.computeMask = function (e, t) {
33672    return (0, _tfjsCore.tidy)(function () {
33673      if (null == t) return null;
33674      if (!Array.isArray(t)) throw new ValueError("`mask` should be an Array");
33675      if (!Array.isArray(e)) throw new ValueError("`inputs` should be an Array");
33676      if (t.length !== e.length) throw new ValueError("The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (" + e.length + " vs " + t.length + ")");
33677      if (t.every(function (e) {
33678        return null == e;
33679      })) return null;
33680
33681      for (var n = (t = t.map(function (e) {
33682        return null == e ? e : (0, _tfjsCore.expandDims)(e, 0);
33683      }))[0], r = 1; r < t.length - 1; ++r) n = (0, _tfjsCore.logicalAnd)(n, t[r]);
33684
33685      return n;
33686    });
33687  }, t;
33688}(Layer),
33689    Add = function (e) {
33690  function t(t) {
33691    return e.call(this, t) || this;
33692  }
33693
33694  return __extends(t, e), t.prototype.mergeFunction = function (e) {
33695    return (0, _tfjsCore.tidy)(function () {
33696      for (var t = e[0].clone(), n = 1; n < e.length; ++n) t = (0, _tfjsCore.add)(t, e[n]);
33697
33698      return t;
33699    });
33700  }, t.className = "Add", t;
33701}(Merge);
33702
33703_tfjsCore.serialization.registerClass(Add);
33704
33705var Multiply = function (e) {
33706  function t(t) {
33707    return e.call(this, t) || this;
33708  }
33709
33710  return __extends(t, e), t.prototype.mergeFunction = function (e) {
33711    return (0, _tfjsCore.tidy)(function () {
33712      for (var t = e[0].clone(), n = 1; n < e.length; ++n) t = (0, _tfjsCore.mul)(t, e[n]);
33713
33714      return t;
33715    });
33716  }, t.className = "Multiply", t;
33717}(Merge);
33718
33719_tfjsCore.serialization.registerClass(Multiply);
33720
33721var Average = function (e) {
33722  function t(t) {
33723    return e.call(this, t) || this;
33724  }
33725
33726  return __extends(t, e), t.prototype.mergeFunction = function (e) {
33727    return (0, _tfjsCore.tidy)(function () {
33728      for (var t = e[0].clone(), n = 1; n < e.length; ++n) t = (0, _tfjsCore.add)(t, e[n]);
33729
33730      return (0, _tfjsCore.mul)(1 / e.length, t);
33731    });
33732  }, t.className = "Average", t;
33733}(Merge);
33734
33735_tfjsCore.serialization.registerClass(Average);
33736
33737var Maximum = function (e) {
33738  function t(t) {
33739    return e.call(this, t) || this;
33740  }
33741
33742  return __extends(t, e), t.prototype.mergeFunction = function (e) {
33743    return (0, _tfjsCore.tidy)(function () {
33744      for (var t = e[0], n = 1; n < e.length; ++n) t = (0, _tfjsCore.maximum)(t, e[n]);
33745
33746      return t;
33747    });
33748  }, t.className = "Maximum", t;
33749}(Merge);
33750
33751_tfjsCore.serialization.registerClass(Maximum);
33752
33753var Minimum = function (e) {
33754  function t(t) {
33755    return e.call(this, t) || this;
33756  }
33757
33758  return __extends(t, e), t.prototype.mergeFunction = function (e) {
33759    return (0, _tfjsCore.tidy)(function () {
33760      for (var t = e[0], n = 1; n < e.length; ++n) t = (0, _tfjsCore.minimum)(t, e[n]);
33761
33762      return t;
33763    });
33764  }, t.className = "Minimum", t;
33765}(Merge);
33766
33767_tfjsCore.serialization.registerClass(Minimum);
33768
33769var Concatenate = function (e) {
33770  function t(t) {
33771    var n = e.call(this, t) || this;
33772    return n.DEFAULT_AXIS = -1, null == t && (t = {}), n.axis = null == t.axis ? n.DEFAULT_AXIS : t.axis, n.supportsMasking = !0, n.reshapeRequired = !1, n;
33773  }
33774
33775  return __extends(t, e), t.prototype.build = function (e) {
33776    if (!Array.isArray(e) || !Array.isArray(e[0]) || 1 === e.length) throw new ValueError("A `Concatenate` layer should be called on a list of at least 2 inputs");
33777
33778    for (var t = !0, n = 0, r = e = e; n < r.length; n++) {
33779      if (null != (c = r[n])) {
33780        t = !1;
33781        break;
33782      }
33783    }
33784
33785    if (!t) {
33786      for (var i = [], a = 0; a < e.length; ++a) {
33787        var o = e[a].slice();
33788        o.splice(this.axis, 1);
33789
33790        for (var s = !1, l = 0, u = i; l < u.length; l++) {
33791          var c = u[l];
33792
33793          if (_tfjsCore.util.arraysEqual(c, o)) {
33794            s = !0;
33795            break;
33796          }
33797        }
33798
33799        s || i.push(o);
33800      }
33801
33802      if (i.length > 1) throw new ValueError("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: " + JSON.stringify(e));
33803    }
33804  }, t.prototype.mergeFunction = function (e) {
33805    var t = this;
33806    return (0, _tfjsCore.tidy)(function () {
33807      return concatenate(e, t.axis);
33808    });
33809  }, t.prototype.computeOutputShape = function (e) {
33810    if (!Array.isArray(e) || !Array.isArray(e[0])) throw new ValueError("A `Concatenate` layer should be called on a list of inputs.");
33811
33812    for (var t = e, n = t[0].slice(), r = this.axis < 0 ? n.length + this.axis : this.axis, i = 0, a = t.slice(1); i < a.length; i++) {
33813      var o = a[i];
33814
33815      if (null == n[r] || null == o[r]) {
33816        n[r] = null;
33817        break;
33818      }
33819
33820      n[r] += o[r];
33821    }
33822
33823    return n;
33824  }, t.prototype.computeMask = function (e, t) {
33825    var n = this;
33826    if (null == t) return null;
33827    if (!Array.isArray(t)) throw new ValueError("`mask` should be an array for Concatenate");
33828    if (!Array.isArray(e)) throw new ValueError("`inputs` should be an array for Concatenate");
33829    if (t.length !== e.length) throw new ValueError("Mismatch in the length of mask (" + t.length + ") and the legnth of inputs (" + e.length + ")");
33830    return (0, _tfjsCore.tidy)(function () {
33831      var r = !0;
33832      if (t.forEach(function (e) {
33833        null == e || (r = !1);
33834      }), r) return null;
33835
33836      for (var i = [], a = 0; a < e.length; ++a) null == t[a] ? i.push((0, _tfjsCore.onesLike)(e[a]).asType("bool")) : t[a].rank < e[a].rank ? i.push((0, _tfjsCore.expandDims)(t[a], -1)) : i.push(t[a]);
33837
33838      var o = (0, _tfjsCore.concat)(i, n.axis);
33839      return (0, _tfjsCore.all)(o, -1, !1);
33840    });
33841  }, t.prototype.getConfig = function () {
33842    var t = {
33843      axis: this.axis
33844    },
33845        n = e.prototype.getConfig.call(this);
33846    return Object.assign(t, n), t;
33847  }, t.className = "Concatenate", t;
33848}(Merge);
33849
33850function interpretAxis(e, t) {
33851  for (; e < 0;) e += t;
33852
33853  return e;
33854}
33855
33856function batchDot(e, t, n) {
33857  if (e.shape.length > 3 || t.shape.length > 3) throw new NotImplementedError("batchDot is not implemented for tensors of 4D or higher rank yet");
33858  if (_tfjsCore.util.assert(e.shape.length >= 2, function () {
33859    return "batchDot requires the rank of x to be >= 2, but got " + e.shape.length;
33860  }), _tfjsCore.util.assert(e.shape.length >= 2, function () {
33861    return "batchDot requires the rank of y to be >= 2, but got " + t.shape.length;
33862  }), "number" == typeof n && (n = [n, n]), "complex64" === e.dtype || "complex64" === t.dtype) throw new NotImplementedError("batchDot is not implemented for complex64-type Tensors yet.");
33863  var r = e.shape.length,
33864      i = t.shape.length;
33865  null == n && (n = [r - 1, i - 2]);
33866  var a = n;
33867  return (0, _tfjsCore.tidy)(function () {
33868    var n, o;
33869
33870    if (r > i) {
33871      n = r - i;
33872
33873      for (var s = [], l = 0; l < n; ++l) s.push(1);
33874
33875      t = t.reshape(t.shape.concat(s));
33876    } else if (i > r) {
33877      n = i - r;
33878
33879      for (s = [], l = 0; l < n; ++l) s.push(1);
33880
33881      e = e.reshape(e.shape.concat(s));
33882    } else n = 0;
33883
33884    if (2 === e.shape.length && 2 === t.shape.length) o = a[0] === a[1] ? e.mulStrict(t).sum(a[0]) : e.transpose([1, 0]).mulStrict(t).sum(a[1]);else {
33885      var u = a[0] !== e.shape.length - 1,
33886          c = a[1] === t.shape.length - 1;
33887      o = e.matMul(t, u, c);
33888    }
33889
33890    if (n > 0) {
33891      var p = void 0,
33892          h = [];
33893
33894      for (l = p = r > i ? r + i - 3 : r - 1; l < p + n; ++l) h.push(l);
33895
33896      o = o.squeeze(h);
33897    }
33898
33899    return 1 === o.shape.length && (o = o.expandDims(1)), o;
33900  });
33901}
33902
33903_tfjsCore.serialization.registerClass(Concatenate);
33904
33905var Dot = function (e) {
33906  function t(t) {
33907    var n = e.call(this, t) || this;
33908    return n.axes = t.axes, n.normalize = null != t.normalize && t.normalize, n.supportsMasking = !0, n.reshapeRequired = !1, n;
33909  }
33910
33911  return __extends(t, e), t.prototype.build = function (e) {
33912    _tfjsCore.util.assert(Array.isArray(e) && 2 === e.length && Array.isArray(e[0]) && Array.isArray(e[1]), function () {
33913      return "A `Dot` layer should be called on a list of exactly 2 inputs.";
33914    });
33915
33916    var t = e[0],
33917        n = e[1];
33918    if (t.length > 3 || n.length > 3) throw new NotImplementedError("Dot layer does not support tensors of 4D or higher rank yet.");
33919    var r = this.interpretAxes(t, n);
33920    if (t[r[0]] !== n[r[1]]) throw new ValueError("Dimension incompatibility: " + t[r[0]] + " !== " + n[r[1]]);
33921  }, t.prototype.mergeFunction = function (e) {
33922    if (2 !== e.length) throw new ValueError("A `Dot` layer must be called on exactly 2 inputs, but received " + e.length + " input(s).");
33923    var t,
33924        n = e[0],
33925        r = e[1];
33926    return t = Array.isArray(this.axes) ? this.axes.map(function (t, n) {
33927      return interpretAxis(t, e[n].shape.length);
33928    }) : [interpretAxis(this.axes, n.shape.length), interpretAxis(this.axes, r.shape.length)], this.normalize && (n = l2Normalize(n, t[0]), r = l2Normalize(r, t[1])), batchDot(n, r, t);
33929  }, t.prototype.interpretAxes = function (e, t) {
33930    return Array.isArray(this.axes) ? this.axes : [interpretAxis(this.axes, e.length), interpretAxis(this.axes, t.length)];
33931  }, t.prototype.computeOutputShape = function (e) {
33932    _tfjsCore.util.assert(Array.isArray(e) && 2 === e.length && Array.isArray(e[0]) && Array.isArray(e[1]), function () {
33933      return "A `Dot` layer should be called on a list of exactly 2 inputs.";
33934    });
33935
33936    var t = e[0].slice(),
33937        n = e[1].slice();
33938    if (t.length > 3 || n.length > 3) throw new NotImplementedError("Dot layer does not support tensors of 4D or higher rank yet.");
33939    var r = this.interpretAxes(t, n);
33940    t.splice(r[0], 1), n.splice(r[1], 1), n.splice(0, 1);
33941    var i = t.concat(n);
33942    return 1 === i.length && i.push(1), i;
33943  }, t.prototype.computeMask = function (e, t) {
33944    return null;
33945  }, t.prototype.getConfig = function () {
33946    var t = {
33947      axes: this.axes,
33948      normalize: this.normalize
33949    },
33950        n = e.prototype.getConfig.call(this);
33951    return Object.assign(t, n), t;
33952  }, t.className = "Dot", t;
33953}(Merge);
33954
33955_tfjsCore.serialization.registerClass(Dot);
33956
33957var GaussianNoise = function (e) {
33958  function t(t) {
33959    var n = e.call(this, t) || this;
33960    return n.supportsMasking = !0, n.stddev = t.stddev, n;
33961  }
33962
33963  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
33964    return e;
33965  }, t.prototype.getConfig = function () {
33966    var t = e.prototype.getConfig.call(this),
33967        n = {
33968      stddev: this.stddev
33969    };
33970    return Object.assign(n, t), n;
33971  }, t.prototype.call = function (e, t) {
33972    var n = this;
33973    return (0, _tfjsCore.tidy)(function () {
33974      n.invokeCallHook(e, t);
33975      var r = getExactlyOneTensor(e);
33976      return inTrainPhase(function () {
33977        return randomNormal$1(r.shape, 0, n.stddev).add(r);
33978      }, function () {
33979        return r;
33980      }, t.training || !1);
33981    });
33982  }, t.className = "GaussianNoise", t;
33983}(Layer);
33984
33985_tfjsCore.serialization.registerClass(GaussianNoise);
33986
33987var GaussianDropout = function (e) {
33988  function t(t) {
33989    var n = e.call(this, t) || this;
33990    return n.supportsMasking = !0, n.rate = t.rate, n;
33991  }
33992
33993  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
33994    return e;
33995  }, t.prototype.getConfig = function () {
33996    var t = e.prototype.getConfig.call(this),
33997        n = {
33998      rate: this.rate
33999    };
34000    return Object.assign(n, t), n;
34001  }, t.prototype.call = function (e, t) {
34002    var n = this;
34003    return (0, _tfjsCore.tidy)(function () {
34004      n.invokeCallHook(e, t);
34005      var r = getExactlyOneTensor(e);
34006
34007      if (n.rate > 0 && n.rate < 1) {
34008        return inTrainPhase(function () {
34009          var e = Math.sqrt(n.rate / (1 - n.rate));
34010          return r.mul(randomNormal$1(r.shape, 1, e));
34011        }, function () {
34012          return r;
34013        }, t.training || !1);
34014      }
34015
34016      return r;
34017    });
34018  }, t.className = "GaussianDropout", t;
34019}(Layer);
34020
34021_tfjsCore.serialization.registerClass(GaussianDropout);
34022
34023var AlphaDropout = function (e) {
34024  function t(t) {
34025    var n = e.call(this, t) || this;
34026    return n.supportsMasking = !0, n.rate = t.rate, n.noiseShape = t.noiseShape, n;
34027  }
34028
34029  return __extends(t, e), t.prototype._getNoiseShape = function (e) {
34030    return this.noiseShape || getExactlyOneTensor(e).shape;
34031  }, t.prototype.computeOutputShape = function (e) {
34032    return e;
34033  }, t.prototype.getConfig = function () {
34034    var t = e.prototype.getConfig.call(this),
34035        n = {
34036      rate: this.rate
34037    };
34038    return Object.assign(n, t), n;
34039  }, t.prototype.call = function (e, t) {
34040    var n = this;
34041    return (0, _tfjsCore.tidy)(function () {
34042      if (n.rate < 1 && n.rate > 0) {
34043        var r = n._getNoiseShape(e);
34044
34045        return inTrainPhase(function () {
34046          var t = getExactlyOneTensor(e),
34047              i = -1.7580993408473766,
34048              a = (0, _tfjsCore.greaterEqual)((0, _tfjsCore.randomUniform)(r), n.rate);
34049          a = cast$1(a, "float32");
34050          var o = Math.pow((1 - n.rate) * (1 + n.rate * Math.pow(i, 2)), -.5),
34051              s = -o * i * n.rate;
34052          return t.mul(a).add(a.add(-1).mul(i)).mul(o).add(s);
34053        }, function () {
34054          return getExactlyOneTensor(e);
34055        }, t.training || !1);
34056      }
34057
34058      return e;
34059    });
34060  }, t.className = "AlphaDropout", t;
34061}(Layer);
34062
34063function batchNormalization(e, t, n, r, i, a) {
34064  var o;
34065  if (void 0 === a && (a = .001), 2 === e.rank) o = (0, _tfjsCore.batchNorm2d)(e, t, n, r, i, a);else if (3 === e.rank) o = (0, _tfjsCore.batchNorm3d)(e, t, n, r, i, a);else {
34066    if (4 !== e.rank) throw new NotImplementedError("batchNormalization is not implemented for array of rank " + e.rank + " yet");
34067    o = (0, _tfjsCore.batchNorm4d)(e, t, n, r, i, a);
34068  }
34069  return o;
34070}
34071
34072function regularNormalizeBatchInTraining(e, t, n, r, i) {
34073  return void 0 === i && (i = .001), (0, _tfjsCore.tidy)(function () {
34074    var a = (0, _tfjsCore.moments)(e, r),
34075        o = a.mean,
34076        s = a.variance;
34077    return [batchNormalization(e, o, s, n, t, i), o, s];
34078  });
34079}
34080
34081function broadcastNormalizeBatchInTraining(e, t, n, r, i) {
34082  return void 0 === i && (i = .001), (0, _tfjsCore.tidy)(function () {
34083    for (var a = (0, _tfjsCore.moments)(e, r), o = a.mean, s = a.variance, l = [], u = 0, c = range(0, e.rank); u < c.length; u++) {
34084      var p = c[u];
34085      -1 !== r.indexOf(p) ? l.push(1) : l.push(e.shape[p]);
34086    }
34087
34088    var h = o.reshape(l),
34089        d = s.reshape(l),
34090        f = null == t ? null : t.reshape(l),
34091        g = null == n ? null : n.reshape(l);
34092    return [batchNormalization(e, h, d, g, f, i), o, s];
34093  });
34094}
34095
34096function normalizeBatchInTraining(e, t, n, r, i) {
34097  return void 0 === i && (i = .001), _tfjsCore.util.arraysEqual(r.slice().sort(), range(0, e.rank - 1)) ? regularNormalizeBatchInTraining(e, t, n, r, i) : broadcastNormalizeBatchInTraining(e, t, n, r, i);
34098}
34099
34100_tfjsCore.serialization.registerClass(AlphaDropout);
34101
34102var BatchNormalization = function (e) {
34103  function t(t) {
34104    var n = this;
34105    return null == t && (t = {}), (n = e.call(this, t) || this).supportsMasking = !0, n.axis = null == t.axis ? -1 : t.axis, n.momentum = null == t.momentum ? .99 : t.momentum, n.epsilon = null == t.epsilon ? .001 : t.epsilon, n.center = null == t.center || t.center, n.scale = null == t.scale || t.scale, n.betaInitializer = getInitializer(t.betaInitializer || "zeros"), n.gammaInitializer = getInitializer(t.gammaInitializer || "ones"), n.movingMeanInitializer = getInitializer(t.movingMeanInitializer || "zeros"), n.movingVarianceInitializer = getInitializer(t.movingVarianceInitializer || "ones"), n.betaConstraint = getConstraint(t.betaConstraint), n.gammaConstraint = getConstraint(t.gammaConstraint), n.betaRegularizer = getRegularizer(t.betaRegularizer), n.gammaRegularizer = getRegularizer(t.gammaRegularizer), n;
34106  }
34107
34108  return __extends(t, e), t.prototype.build = function (e) {
34109    var t;
34110    e = getExactlyOneShape(e);
34111    var n = this.axis >= 0 ? this.axis : this.axis + e.length,
34112        r = e[n];
34113    if (null == r) throw new ValueError("Axis " + n + " of input tensor should have a defined dimension but the layer received an input with shape " + JSON.stringify(e) + ".");
34114    this.inputSpec = [new InputSpec({
34115      ndim: e.length,
34116      axes: (t = {}, t[n] = r, t)
34117    })];
34118    var i = [r];
34119    this.scale && (this.gamma = this.addWeight("gamma", i, null, this.gammaInitializer, this.gammaRegularizer, !0, this.gammaConstraint)), this.center && (this.beta = this.addWeight("beta", i, null, this.betaInitializer, this.betaRegularizer, !0, this.betaConstraint)), this.movingMean = this.addWeight("moving_mean", i, null, this.movingMeanInitializer, null, !1), this.movingVariance = this.addWeight("moving_variance", i, null, this.movingVarianceInitializer, null, !1), this.built = !0;
34120  }, t.prototype.call = function (e, t) {
34121    var n = this;
34122    return (0, _tfjsCore.tidy)(function () {
34123      var r = null != t.training && t.training,
34124          i = getExactlyOneTensor(e),
34125          a = i.shape,
34126          o = a.length,
34127          s = range(0, o),
34128          l = n.axis >= 0 ? n.axis : n.axis + o;
34129      s.splice(l, 1);
34130      var u = pyListRepeat(1, o);
34131      u[l] = a[l];
34132      var c = s.slice();
34133      c.sort();
34134      var p = !_tfjsCore.util.arraysEqual(c, range(0, o).slice(0, o - 1));
34135      if (!r) return function () {
34136        if (p) {
34137          var e = n.movingMean.read().reshape(u),
34138              t = n.movingVariance.read().reshape(u),
34139              r = n.center ? n.beta.read().reshape(u) : null,
34140              a = n.scale ? n.gamma.read().reshape(u) : null;
34141          return batchNormalization(i, e, t, r, a, n.epsilon);
34142        }
34143
34144        return batchNormalization(i, n.movingMean.read(), n.movingVariance.read(), null == n.beta ? null : n.beta.read(), null == n.gamma ? null : n.gamma.read(), n.epsilon);
34145      }();
34146
34147      var h = normalizeBatchInTraining(i, n.gamma.read(), n.beta.read(), s, n.epsilon),
34148          d = h[0],
34149          f = h[1],
34150          g = h[2],
34151          m = function (e, t, n) {
34152        (0, _tfjsCore.tidy)(function () {
34153          var r = 1 - n,
34154              i = e.read(),
34155              a = i.sub(t).mul(r);
34156          e.write(i.sub(a));
34157        });
34158      };
34159
34160      return m(n.movingMean, f, n.momentum), m(n.movingVariance, g, n.momentum), d;
34161    });
34162  }, t.prototype.getConfig = function () {
34163    var t = {
34164      axis: this.axis,
34165      momentum: this.momentum,
34166      epsilon: this.epsilon,
34167      center: this.center,
34168      scale: this.scale,
34169      betaInitializer: serializeInitializer(this.betaInitializer),
34170      gammaInitializer: serializeInitializer(this.gammaInitializer),
34171      movingMeanInitializer: serializeInitializer(this.movingMeanInitializer),
34172      movingVarianceInitializer: serializeInitializer(this.movingVarianceInitializer),
34173      betaRegularizer: serializeRegularizer(this.betaRegularizer),
34174      gammaRegularizer: serializeRegularizer(this.gammaRegularizer),
34175      betaConstraint: serializeConstraint(this.betaConstraint),
34176      gammaConstraint: serializeConstraint(this.gammaConstraint)
34177    },
34178        n = e.prototype.getConfig.call(this);
34179    return Object.assign(t, n), t;
34180  }, t.className = "BatchNormalization", t;
34181}(Layer);
34182
34183_tfjsCore.serialization.registerClass(BatchNormalization);
34184
34185var LayerNormalization = function (e) {
34186  function t(t) {
34187    var n = this;
34188
34189    if (null == t && (t = {}), (n = e.call(this, t) || this).axis = null == t.axis ? -1 : t.axis, "number" == typeof n.axis) {
34190      if (!Number.isInteger(n.axis)) throw new Error("Expected axis to be an integer, but received " + n.axis);
34191    } else {
34192      if (!Array.isArray(n.axis)) throw new Error("Expected axis to be an integer or an array of integers, but received " + JSON.stringify(n.axis));
34193
34194      for (var r = 0, i = n.axis; r < i.length; r++) {
34195        var a = i[r];
34196        if (!Number.isInteger(a)) throw new Error("Expected axis to be an array of integers, but received " + JSON.stringify(n.axis));
34197      }
34198    }
34199
34200    return n.epsilon = null == t.epsilon ? .001 : t.epsilon, n.center = null == t.center || t.center, n.scale = null == t.scale || t.scale, n.betaInitializer = getInitializer(t.betaInitializer || "zeros"), n.gammaInitializer = getInitializer(t.gammaInitializer || "ones"), n.betaRegularizer = getRegularizer(t.betaRegularizer), n.gammaRegularizer = getRegularizer(t.gammaRegularizer), n.supportsMasking = !0, n;
34201  }
34202
34203  return __extends(t, e), t.prototype.build = function (e) {
34204    var t = (e = getExactlyOneShape(e)).length;
34205    "number" == typeof this.axis && (this.axis = [this.axis]);
34206
34207    for (var n = 0; n < this.axis.length; ++n) this.axis[n] < 0 && (this.axis[n] += t);
34208
34209    for (var r = 0, i = this.axis; r < i.length; r++) {
34210      var a = i[r];
34211      if (a < 0 || a >= t) throw new Error("Invalid axis: " + a);
34212    }
34213
34214    if (this.axis.length !== unique(this.axis).length) throw new Error("Found duplicate axes in: " + this.axis);
34215    var o = this.axis.map(function (t) {
34216      return e[t];
34217    });
34218    this.scale ? this.gamma = this.addWeight("gamma", o, "float32", this.gammaInitializer, this.gammaRegularizer, !0) : this.gamma = null, this.center ? this.beta = this.addWeight("beta", o, "float32", this.betaInitializer, this.betaRegularizer, !0) : this.beta = null, this.built = !0;
34219  }, t.prototype.call = function (e, t) {
34220    var n = this,
34221        r = getExactlyOneTensor(e),
34222        i = r.shape,
34223        a = i.length;
34224    return (0, _tfjsCore.tidy)(function () {
34225      for (var e = (0, _tfjsCore.moments)(r, n.axis, !0), t = e.mean, o = e.variance, s = pyListRepeat(1, a), l = 0, u = n.axis; l < u.length; l++) {
34226        var c = u[l];
34227        s[c] = i[c];
34228      }
34229
34230      for (var p = function (e) {
34231        return null != e && e.shape.length !== a && n.axis !== [a - 1] ? e.reshape(s) : e;
34232      }, h = p(n.gamma.read()), d = p(n.beta.read()), f = [], g = [], m = 0; m < a; ++m) -1 !== n.axis.indexOf(m) ? (f.push(i[m]), g.push(1)) : (f.push(1), g.push(i[m]));
34233
34234      return t = t.tile(f), o = o.tile(f), h = h.tile(g), d = d.tile(g), batchNormalization(r, t, o, d, h, n.epsilon);
34235    });
34236  }, t.prototype.getConfig = function () {
34237    var t = {
34238      axis: this.axis,
34239      epsilon: this.epsilon,
34240      center: this.center,
34241      scale: this.scale,
34242      betaInitializer: serializeInitializer(this.betaInitializer),
34243      gammaInitializer: serializeInitializer(this.gammaInitializer),
34244      betaRegularizer: serializeRegularizer(this.betaRegularizer),
34245      gammaRegularizer: serializeRegularizer(this.gammaRegularizer)
34246    },
34247        n = e.prototype.getConfig.call(this);
34248    return Object.assign(t, n), t;
34249  }, t.className = "LayerNormalization", t;
34250}(Layer);
34251
34252function spatial2dPadding(e, t, n) {
34253  return (0, _tfjsCore.tidy)(function () {
34254    if (4 !== e.rank) throw new ValueError("temporalPadding expects input tensor to be 4-D, but received a " + e.rank + "-D tensor.");
34255    if (null == t && (t = [[1, 1], [1, 1]]), 2 !== t.length || 2 !== t[0].length || 2 !== t[1].length) throw new ValueError("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers.");
34256    if (null == n && (n = imageDataFormat()), "channelsLast" !== n && "channelsFirst" !== n) throw new ValueError("Unknown data format: " + n + ". Supported data formats are 'channelsLast' and 'channelsFirst.");
34257    var r;
34258    return r = "channelsFirst" === n ? [[0, 0], [0, 0], t[0], t[1]] : [[0, 0], t[0], t[1], [0, 0]], (0, _tfjsCore.pad)(e, r);
34259  });
34260}
34261
34262_tfjsCore.serialization.registerClass(LayerNormalization);
34263
34264var ZeroPadding2D = function (e) {
34265  function t(t) {
34266    var n = this;
34267    if (null == t && (t = {}), (n = e.call(this, t) || this).dataFormat = null == t.dataFormat ? imageDataFormat() : t.dataFormat, null == t.padding) n.padding = [[1, 1], [1, 1]];else if ("number" == typeof t.padding) n.padding = [[t.padding, t.padding], [t.padding, t.padding]];else {
34268      if (t.padding = t.padding, 2 !== t.padding.length) throw new ValueError("ZeroPadding2D expects padding to be a length-2 array, but received a length-" 
34268+ t.padding.length + " array.");
34269      var r = void 0,
34270          i = void 0;
34271      if ("number" == typeof t.padding[0]) r = [t.padding[0], t.padding[0]], i = [t.padding[1], t.padding[1]];else {
34272        if (t.padding = t.padding, 2 !== t.padding[0].length) throw new ValueError("ZeroPadding2D expects height padding to be a length-2 array, but received a length-" + t.padding[0].length + " array.");
34273        if (r = t.padding[0], 2 !== t.padding[1].length) throw new ValueError("ZeroPadding2D expects width padding to be a length-2 array, but received a length-" + t.padding[1].length + " array.");
34274        i = t.padding[1];
34275      }
34276      n.padding = [r, i];
34277    }
34278    return n.inputSpec = [new InputSpec({
34279      ndim: 4
34280    })], n;
34281  }
34282
34283  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
34284    var t, n;
34285    return e = getExactlyOneShape(e), "channelsFirst" === this.dataFormat ? (t = null != e[2] && e[2] >= 0 ? e[2] + this.padding[0][0] + this.padding[0][1] : null, n = null != e[3] && e[3] >= 0 ? e[3] + this.padding[1][0] + this.padding[1][1] : null, [e[0], e[1], t, n]) : (t = null != e[1] && e[1] >= 0 ? e[1] + this.padding[0][0] + this.padding[0][1] : null, n = null != e[2] && e[2] >= 0 ? e[2] + this.padding[1][0] + this.padding[1][1] : null, [e[0], t, n, e[3]]);
34286  }, t.prototype.call = function (e, t) {
34287    var n = this;
34288    return (0, _tfjsCore.tidy)(function () {
34289      return spatial2dPadding(getExactlyOneTensor(e), n.padding, n.dataFormat);
34290    });
34291  }, t.prototype.getConfig = function () {
34292    var t = {
34293      padding: this.padding,
34294      dataFormat: this.dataFormat
34295    },
34296        n = e.prototype.getConfig.call(this);
34297    return Object.assign(t, n), t;
34298  }, t.className = "ZeroPadding2D", t;
34299}(Layer);
34300
34301function pool2d(e, t, n, r, i, a) {
34302  return (0, _tfjsCore.tidy)(function () {
34303    var o;
34304    checkDataFormat(i), checkPoolMode(a), checkPaddingMode(r), null == n && (n = [1, 1]), null == r && (r = "valid"), null == i && (i = imageDataFormat()), null == a && (a = "max"), e = preprocessConv2DInput(e, i);
34305    var s = "same" === r ? "same" : "valid";
34306    return o = "max" === a ? (0, _tfjsCore.maxPool)(e, t, n, s) : (0, _tfjsCore.avgPool)(e, t, n, s), "channelsFirst" === i && (o = (0, _tfjsCore.transpose)(o, [0, 3, 1, 2])), o;
34307  });
34308}
34309
34310function pool3d(e, t, n, r, i, a) {
34311  return (0, _tfjsCore.tidy)(function () {
34312    var o;
34313    checkDataFormat(i), checkPoolMode(a), checkPaddingMode(r), null == n && (n = [1, 1, 1]), null == r && (r = "valid"), null == i && (i = imageDataFormat()), null == a && (a = "max"), e = preprocessConv3DInput(e, i);
34314    var s = "same" === r ? "same" : "valid";
34315    return o = "max" === a ? (0, _tfjsCore.maxPool3d)(e, t, n, s) : (0, _tfjsCore.avgPool3d)(e, t, n, s), "channelsFirst" === i && (o = (0, _tfjsCore.transpose)(o, [0, 4, 1, 2, 3])), o;
34316  });
34317}
34318
34319_tfjsCore.serialization.registerClass(ZeroPadding2D);
34320
34321var Pooling1D = function (e) {
34322  function t(t) {
34323    var n = this;
34324    if (null == t.poolSize && (t.poolSize = 2), n = e.call(this, t) || this, "number" == typeof t.poolSize) n.poolSize = [t.poolSize];else {
34325      if (!Array.isArray(t.poolSize) || 1 !== t.poolSize.length || "number" != typeof t.poolSize[0]) throw new ValueError("poolSize for 1D convolutional layer must be a number or an Array of a single number, but received " + JSON.stringify(t.poolSize));
34326      n.poolSize = t.poolSize;
34327    }
34328    if (assertPositiveInteger(n.poolSize, "poolSize"), null == t.strides) n.strides = n.poolSize;else if ("number" == typeof t.strides) n.strides = [t.strides];else {
34329      if (!Array.isArray(t.strides) || 1 !== t.strides.length || "number" != typeof t.strides[0]) throw new ValueError("strides for 1D convolutional layer must be a number or an Array of a single number, but received " + JSON.stringify(t.strides));
34330      n.strides = t.strides;
34331    }
34332    return assertPositiveInteger(n.strides, "strides"), n.padding = null == t.padding ? "valid" : t.padding, checkPaddingMode(n.padding), n.inputSpec = [new InputSpec({
34333      ndim: 3
34334    })], n;
34335  }
34336
34337  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
34338    var t = convOutputLength((e = getExactlyOneShape(e))[1], this.poolSize[0], this.padding, this.strides[0]);
34339    return [e[0], t, e[2]];
34340  }, t.prototype.call = function (e, t) {
34341    var n = this;
34342    return (0, _tfjsCore.tidy)(function () {
34343      n.invokeCallHook(e, t), e = expandDims$1(getExactlyOneTensor(e), 2);
34344      var r = n.poolingFunction(getExactlyOneTensor(e), [n.poolSize[0], 1], [n.strides[0], 1], n.padding, "channelsLast");
34345      return (0, _tfjsCore.squeeze)(r, [2]);
34346    });
34347  }, t.prototype.getConfig = function () {
34348    var t = {
34349      poolSize: this.poolSize,
34350      padding: this.padding,
34351      strides: this.strides
34352    },
34353        n = e.prototype.getConfig.call(this);
34354    return Object.assign(t, n), t;
34355  }, t;
34356}(Layer),
34357    MaxPooling1D = function (e) {
34358  function t(t) {
34359    return e.call(this, t) || this;
34360  }
34361
34362  return __extends(t, e), t.prototype.poolingFunction = function (e, t, n, r, i) {
34363    return checkDataFormat(i), checkPaddingMode(r), pool2d(e, t, n, r, i, "max");
34364  }, t.className = "MaxPooling1D", t;
34365}(Pooling1D);
34366
34367_tfjsCore.serialization.registerClass(MaxPooling1D);
34368
34369var AveragePooling1D = function (e) {
34370  function t(t) {
34371    return e.call(this, t) || this;
34372  }
34373
34374  return __extends(t, e), t.prototype.poolingFunction = function (e, t, n, r, i) {
34375    return checkDataFormat(i), checkPaddingMode(r), pool2d(e, t, n, r, i, "avg");
34376  }, t.className = "AveragePooling1D", t;
34377}(Pooling1D);
34378
34379_tfjsCore.serialization.registerClass(AveragePooling1D);
34380
34381var Pooling2D = function (e) {
34382  function t(t) {
34383    var n = this;
34384    if (null == t.poolSize && (t.poolSize = [2, 2]), (n = e.call(this, t) || this).poolSize = Array.isArray(t.poolSize) ? t.poolSize : [t.poolSize, t.poolSize], null == t.strides) n.strides = n.poolSize;else if (Array.isArray(t.strides)) {
34385      if (2 !== t.strides.length) throw new ValueError("If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length " + t.strides.length + ".");
34386      n.strides = t.strides;
34387    } else n.strides = [t.strides, t.strides];
34388    return assertPositiveInteger(n.poolSize, "poolSize"), assertPositiveInteger(n.strides, "strides"), n.padding = null == t.padding ? "valid" : t.padding, n.dataFormat = null == t.dataFormat ? "channelsLast" : t.dataFormat, checkDataFormat(n.dataFormat), checkPaddingMode(n.padding), n.inputSpec = [new InputSpec({
34389      ndim: 4
34390    })], n;
34391  }
34392
34393  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
34394    e = getExactlyOneShape(e);
34395    var t = "channelsFirst" === this.dataFormat ? e[2] : e[1],
34396        n = "channelsFirst" === this.dataFormat ? e[3] : e[2];
34397    return t = convOutputLength(t, this.poolSize[0], this.padding, this.strides[0]), n = convOutputLength(n, this.poolSize[1], this.padding, this.strides[1]), "channelsFirst" === this.dataFormat ? [e[0], e[1], t, n] : [e[0], t, n, e[3]];
34398  }, t.prototype.call = function (e, t) {
34399    var n = this;
34400    return (0, _tfjsCore.tidy)(function () {
34401      return n.invokeCallHook(e, t), n.poolingFunction(getExactlyOneTensor(e), n.poolSize, n.strides, n.padding, n.dataFormat);
34402    });
34403  }, t.prototype.getConfig = function () {
34404    var t = {
34405      poolSize: this.poolSize,
34406      padding: this.padding,
34407      strides: this.strides,
34408      dataFormat: this.dataFormat
34409    },
34410        n = e.prototype.getConfig.call(this);
34411    return Object.assign(t, n), t;
34412  }, t;
34413}(Layer),
34414    MaxPooling2D = function (e) {
34415  function t(t) {
34416    return e.call(this, t) || this;
34417  }
34418
34419  return __extends(t, e), t.prototype.poolingFunction = function (e, t, n, r, i) {
34420    return checkDataFormat(i), checkPaddingMode(r), pool2d(e, t, n, r, i, "max");
34421  }, t.className = "MaxPooling2D", t;
34422}(Pooling2D);
34423
34424_tfjsCore.serialization.registerClass(MaxPooling2D);
34425
34426var AveragePooling2D = function (e) {
34427  function t(t) {
34428    return e.call(this, t) || this;
34429  }
34430
34431  return __extends(t, e), t.prototype.poolingFunction = function (e, t, n, r, i) {
34432    return checkDataFormat(i), checkPaddingMode(r), pool2d(e, t, n, r, i, "avg");
34433  }, t.className = "AveragePooling2D", t;
34434}(Pooling2D);
34435
34436_tfjsCore.serialization.registerClass(AveragePooling2D);
34437
34438var Pooling3D = function (e) {
34439  function t(t) {
34440    var n = this;
34441    if (null == t.poolSize && (t.poolSize = [2, 2, 2]), (n = e.call(this, t) || this).poolSize = Array.isArray(t.poolSize) ? t.poolSize : [t.poolSize, t.poolSize, t.poolSize], null == t.strides) n.strides = n.poolSize;else if (Array.isArray(t.strides)) {
34442      if (3 !== t.strides.length) throw new ValueError("If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length " + t.strides.length + ".");
34443      n.strides = t.strides;
34444    } else n.strides = [t.strides, t.strides, t.strides];
34445    return assertPositiveInteger(n.poolSize, "poolSize"), assertPositiveInteger(n.strides, "strides"), n.padding = null == t.padding ? "valid" : t.padding, n.dataFormat = null == t.dataFormat ? "channelsLast" : t.dataFormat, checkDataFormat(n.dataFormat), checkPaddingMode(n.padding), n.inputSpec = [new InputSpec({
34446      ndim: 5
34447    })], n;
34448  }
34449
34450  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
34451    e = getExactlyOneShape(e);
34452    var t = "channelsFirst" === this.dataFormat ? e[2] : e[1],
34453        n = "channelsFirst" === this.dataFormat ? e[3] : e[2],
34454        r = "channelsFirst" === this.dataFormat ? e[4] : e[3];
34455    return t = convOutputLength(t, this.poolSize[0], this.padding, this.strides[0]), n = convOutputLength(n, this.poolSize[1], this.padding, this.strides[1]), r = convOutputLength(r, this.poolSize[2], this.padding, this.strides[2]), "channelsFirst" === this.dataFormat ? [e[0], e[1], t, n, r] : [e[0], t, n, r, e[4]];
34456  }, t.prototype.call = function (e, t) {
34457    var n = this;
34458    return (0, _tfjsCore.tidy)(function () {
34459      return n.invokeCallHook(e, t), n.poolingFunction(getExactlyOneTensor(e), n.poolSize, n.strides, n.padding, n.dataFormat);
34460    });
34461  }, t.prototype.getConfig = function () {
34462    var t = {
34463      poolSize: this.poolSize,
34464      padding: this.padding,
34465      strides: this.strides,
34466      dataFormat: this.dataFormat
34467    },
34468        n = e.prototype.getConfig.call(this);
34469    return Object.assign(t, n), t;
34470  }, t;
34471}(Layer),
34472    MaxPooling3D = function (e) {
34473  function t(t) {
34474    return e.call(this, t) || this;
34475  }
34476
34477  return __extends(t, e), t.prototype.poolingFunction = function (e, t, n, r, i) {
34478    return checkDataFormat(i), checkPaddingMode(r), pool3d(e, t, n, r, i, "max");
34479  }, t.className = "MaxPooling3D", t;
34480}(Pooling3D);
34481
34482_tfjsCore.serialization.registerClass(MaxPooling3D);
34483
34484var AveragePooling3D = function (e) {
34485  function t(t) {
34486    return e.call(this, t) || this;
34487  }
34488
34489  return __extends(t, e), t.prototype.poolingFunction = function (e, t, n, r, i) {
34490    return checkDataFormat(i), checkPaddingMode(r), pool3d(e, t, n, r, i, "avg");
34491  }, t.className = "AveragePooling3D", t;
34492}(Pooling3D);
34493
34494_tfjsCore.serialization.registerClass(AveragePooling3D);
34495
34496var GlobalPooling1D = function (e) {
34497  function t(t) {
34498    var n = e.call(this, t) || this;
34499    return n.inputSpec = [new InputSpec({
34500      ndim: 3
34501    })], n;
34502  }
34503
34504  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
34505    return [e[0], e[2]];
34506  }, t.prototype.call = function (e, t) {
34507    throw new NotImplementedError();
34508  }, t;
34509}(Layer),
34510    GlobalAveragePooling1D = function (e) {
34511  function t(t) {
34512    return e.call(this, t || {}) || this;
34513  }
34514
34515  return __extends(t, e), t.prototype.call = function (e, t) {
34516    return (0, _tfjsCore.tidy)(function () {
34517      var t = getExactlyOneTensor(e);
34518      return (0, _tfjsCore.mean)(t, 1);
34519    });
34520  }, t.className = "GlobalAveragePooling1D", t;
34521}(GlobalPooling1D);
34522
34523_tfjsCore.serialization.registerClass(GlobalAveragePooling1D);
34524
34525var GlobalMaxPooling1D = function (e) {
34526  function t(t) {
34527    return e.call(this, t || {}) || this;
34528  }
34529
34530  return __extends(t, e), t.prototype.call = function (e, t) {
34531    return (0, _tfjsCore.tidy)(function () {
34532      var t = getExactlyOneTensor(e);
34533      return (0, _tfjsCore.max)(t, 1);
34534    });
34535  }, t.className = "GlobalMaxPooling1D", t;
34536}(GlobalPooling1D);
34537
34538_tfjsCore.serialization.registerClass(GlobalMaxPooling1D);
34539
34540var GlobalPooling2D = function (e) {
34541  function t(t) {
34542    var n = e.call(this, t) || this;
34543    return n.dataFormat = null == t.dataFormat ? "channelsLast" : t.dataFormat, checkDataFormat(n.dataFormat), n.inputSpec = [new InputSpec({
34544      ndim: 4
34545    })], n;
34546  }
34547
34548  return __extends(t, e), t.prototype.computeOutputShape = function (e) {
34549    return e = e, "channelsLast" === this.dataFormat ? [e[0], e[3]] : [e[0], e[1]];
34550  }, t.prototype.call = function (e, t) {
34551    throw new NotImplementedError();
34552  }, t.prototype.getConfig = function () {
34553    var t = {
34554      dataFormat: this.dataFormat
34555    },
34556        n = e.prototype.getConfig.call(this);
34557    return Object.assign(t, n), t;
34558  }, t;
34559}(Layer),
34560    GlobalAveragePooling2D = function (e) {
34561  function t() {
34562    return null !== e && e.apply(this, arguments) || this;
34563  }
34564
34565  return __extends(t, e), t.prototype.call = function (e, t) {
34566    var n = this;
34567    return (0, _tfjsCore.tidy)(function () {
34568      var t = getExactlyOneTensor(e);
34569      return "channelsLast" === n.dataFormat ? (0, _tfjsCore.mean)(t, [1, 2]) : (0, _tfjsCore.mean)(t, [2, 3]);
34570    });
34571  }, t.className = "GlobalAveragePooling2D", t;
34572}(GlobalPooling2D);
34573
34574_tfjsCore.serialization.registerClass(GlobalAveragePooling2D);
34575
34576var GlobalMaxPooling2D = function (e) {
34577  function t() {
34578    return null !== e && e.apply(this, arguments) || this;
34579  }
34580
34581  return __extends(t, e), t.prototype.call = function (e, t) {
34582    var n = this;
34583    return (0, _tfjsCore.tidy)(function () {
34584      var t = getExactlyOneTensor(e);
34585      return "channelsLast" === n.dataFormat ? (0, _tfjsCore.max)(t, [1, 2]) : (0, _tfjsCore.max)(t, [2, 3]);
34586    });
34587  }, t.className = "GlobalMaxPooling2D", t;
34588}(GlobalPooling2D);
34589
34590function standardizeArgs(e, t, n, r) {
34591  if (Array.isArray(e)) {
34592    if (null != t || null != n) throw new ValueError("When inputs is an array, neither initialState or constants should be provided");
34593    null != r && (n = e.slice(e.length - r, e.length), e = e.slice(0, e.length - r)), e.length > 1 && (t = e.slice(1, e.length)), e = e[0];
34594  }
34595
34596  function i(e) {
34597    return null == e || Array.isArray(e) ? e : [e];
34598  }
34599
34600  return {
34601    inputs: e,
34602    initialState: t = i(t),
34603    constants: n = i(n)
34604  };
34605}
34606
34607function rnn(e, t, n, r, i, a, o, s) {
34608  return void 0 === r && (r = !1), void 0 === o && (o = !1), void 0 === s && (s = !1), (0, _tfjsCore.tidy)(function () {
34609    var l = t.shape.length;
34610    if (l < 3) throw new ValueError("Input should be at least 3D, but is " + l + "D.");
34611    var u = [1, 0].concat(range(2, l));
34612    if (t = (0, _tfjsCore.transpose)(t, u), null != a) throw new NotImplementedError("The rnn() functoin of the deeplearn.js backend does not support constants yet.");
34613    o && console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."), null != i && ((i = i.asType("bool").asType("float32")).rank === l - 1 && (i = (0, _tfjsCore.expandDims)(i, -1)), i = (0, _tfjsCore.transpose)(i, u)), r && (t = (0, _tfjsCore.reverse)(t, 0), null != i && (i = (0, _tfjsCore.reverse)(i, 0)));
34614    var c,
34615        p,
34616        h = [],
34617        d = n,
34618        f = t.shape[0],
34619        g = (0, _tfjsCore.unstack)(t);
34620    null != i && (p = (0, _tfjsCore.unstack)(i));
34621
34622    for (var m, y = function (t) {
34623      var n = g[t],
34624          r = (0, _tfjsCore.tidy)(function () {
34625        return e(n, d);
34626      });
34627      if (null == i) c = r[0], d = r[1];else {
34628        var a = (0, _tfjsCore.tidy)(function () {
34629          var e = p[t],
34630              n = (0, _tfjsCore.onesLike)(e).sub(e);
34631          return {
34632            output: r[0].mul(e).addStrict(d[0].mul(n)),
34633            newStates: d.map(function (t, i) {
34634              return r[1][i].mul(e).addStrict(t.mul(n));
34635            })
34636          };
34637        });
34638        c = a.output, d = a.newStates;
34639      }
34640      s && h.push(c);
34641    }, v = 0; v < f; ++v) y(v);
34642
34643    if (s) {
34644      m = (0, _tfjsCore.stack)(h, 1);
34645    }
34646
34647    return [c, m, d];
34648  });
34649}
34650
34651_tfjsCore.serialization.registerClass(GlobalMaxPooling2D);
34652
34653var RNN = function (e) {
34654  function t(t) {
34655    var n,
34656        r = e.call(this, t) || this;
34657    if (null == t.cell) throw new ValueError("cell property is missing for the constructor of RNN.");
34658    if (null == (n = Array.isArray(t.cell) ? new StackedRNNCells({
34659      cells: t.cell
34660    }) : t.cell).stateSize) throw new ValueError("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state).");
34661    return r.cell = n, r.returnSequences = null != t.returnSequences && t.returnSequences, r.returnState = null != t.returnState && t.returnState, r.goBackwards = null != t.goBackwards && t.goBackwards, r._stateful = null != t.stateful && t.stateful, r.unroll = null != t.unroll && t.unroll, r.supportsMasking = !0, r.inputSpec = [new InputSpec({
34662      ndim: 3
34663    })], r.stateSpec = null, r.states_ = null, r.numConstants = null, r.keptStates = [], r;
34664  }
34665
34666  return __extends(t, e), t.prototype.getStates = function () {
34667    return null == this.states_ ? range(0, Array.isArray(this.cell.stateSize) ? this.cell.stateSize.length : 1).map(function (e) {
34668      return null;
34669    }) : this.states_;
34670  }, t.prototype.setStates = function (e) {
34671    this.states_ = e;
34672  }, t.prototype.computeOutputShape = function (e) {
34673    isArrayOfShapes(e) && (e = e[0]), e = e;
34674    var t = this.cell.stateSize;
34675    Array.isArray(t) || (t = [t]);
34676    var n,
34677        r = t[0];
34678
34679    if (n = this.returnSequences ? [e[0], e[1], r] : [e[0], r], this.returnState) {
34680      for (var i = [], a = 0, o = t; a < o.length; a++) {
34681        var s = o[a];
34682        i.push([e[0], s]);
34683      }
34684
34685      return [n].concat(i);
34686    }
34687
34688    return n;
34689  }, t.prototype.computeMask = function (e, t) {
34690    var n = this;
34691    return (0, _tfjsCore.tidy)(function () {
34692      Array.isArray(t) && (t = t[0]);
34693      var e = n.returnSequences ? t : null;
34694
34695      if (n.returnState) {
34696        var r = n.states.map(function (e) {
34697          return null;
34698        });
34699        return [e].concat(r);
34700      }
34701
34702      return e;
34703    });
34704  }, Object.defineProperty(t.prototype, "states", {
34705    get: function () {
34706      if (null == this.states_) {
34707        for (var e = Array.isArray(this.cell.stateSize) ? this.cell.stateSize.length : 1, t = [], n = 0; n < e; ++n) t.push(null);
34708
34709        return t;
34710      }
34711
34712      return this.states_;
34713    },
34714    set: function (e) {
34715      this.states_ = e;
34716    },
34717    enumerable: !0,
34718    configurable: !0
34719  }), t.prototype.build = function (e) {
34720    if (null != this.numConstants) throw new NotImplementedError("Constants support is not implemented in RNN yet.");
34721    isArrayOfShapes(e) && (e = e[0]), e = e;
34722    var t = this.stateful ? e[0] : null,
34723        n = e[e.length - 1];
34724    this.inputSpec[0] = new InputSpec({
34725      shape: [t, null, n]
34726    });
34727    var r,
34728        i = [e[0]].concat(e.slice(2));
34729
34730    if (this.cell.build(i), r = Array.isArray(this.cell.stateSize) ? this.cell.stateSize : [this.cell.stateSize], null != this.stateSpec) {
34731      if (!_tfjsCore.util.arraysEqual(this.stateSpec.map(function (e) {
34732        return e.shape[e.shape.length - 1];
34733      }), r)) throw new ValueError("An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=" + this.stateSpec + "; However cell.stateSize is " + this.cell.stateSize);
34734    } else this.stateSpec = r.map(function (e) {
34735      return new InputSpec({
34736        shape: [null, e]
34737      });
34738    });
34739
34740    this.stateful && this.resetStates();
34741  }, t.prototype.resetStates = function (e, t) {
34742    var n = this;
34743    void 0 === t && (t = !1), (0, _tfjsCore.tidy)(function () {
34744      if (!n.stateful) throw new AttributeError("Cannot call resetStates() on an RNN Layer that is not stateful.");
34745      var r = n.inputSpec[0].shape[0];
34746      if (null == r) throw new ValueError("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer.");
34747      if (null == n.states_) Array.isArray(n.cell.stateSize) ? n.states_ = n.cell.stateSize.map(function (e) {
34748        return (0, _tfjsCore.zeros)([r, e]);
34749      }) : n.states_ = [(0, _tfjsCore.zeros)([r, n.cell.stateSize])];else if (null == e) (0, _tfjsCore.dispose)(n.states_), null != n.keptStates && ((0, _tfjsCore.dispose)(n.keptStates), n.keptStates = []), Array.isArray(n.cell.stateSize) ? n.states_ = n.cell.stateSize.map(function (e) {
34750        return (0, _tfjsCore.zeros)([r, e]);
34751      }) : n.states_[0] = (0, _tfjsCore.zeros)([r, n.cell.stateSize]);else {
34752        if (Array.isArray(e) || (e = [e]), e.length !== n.states_.length) throw new ValueError("Layer " + n.name + " expects " + n.states_.length + " state(s), but it received " + e.length + " state value(s). Input received: " + e);
34753        !0 === t ? n.keptStates.push(n.states_.slice()) : (0, _tfjsCore.dispose)(n.states_);
34754
34755        for (var i = 0; i < n.states_.length; ++i) {
34756          var a = e[i],
34757              o = Array.isArray(n.cell.stateSize) ? n.cell.stateSize[i] : n.cell.stateSize,
34758              s = [r, o];
34759          if (!_tfjsCore.util.arraysEqual(a.shape, s)) throw new ValueError("State " + i + " is incompatible with layer " + n.name + ": expected shape=" + s + ", received shape=" + a.shape);
34760          n.states_[i] = a;
34761        }
34762      }
34763      n.states_ = n.states_.map(function (e) {
34764        return (0, _tfjsCore.keep)(e.clone());
34765      });
34766    });
34767  }, t.prototype.apply = function (t, n) {
34768    var r = null == n ? null : n.initialState,
34769        i = null == n ? null : n.constants;
34770    null == n && (n = {});
34771    var a = standardizeArgs(t, r, i, this.numConstants);
34772    t = a.inputs, r = a.initialState, i = a.constants;
34773    var o = [],
34774        s = [];
34775
34776    if (null != r) {
34777      n.initialState = r, o = o.concat(r), this.stateSpec = [];
34778
34779      for (var l = 0, u = r; l < u.length; l++) {
34780        var c = u[l];
34781        this.stateSpec.push(new InputSpec({
34782          shape: c.shape
34783        }));
34784      }
34785
34786      s = s.concat(this.stateSpec);
34787    }
34788
34789    if (null != i && (n.constants = i, o = o.concat(i), this.numConstants = i.length), o[0] instanceof SymbolicTensor) {
34790      var p = [t].concat(o),
34791          h = this.inputSpec.concat(s),
34792          d = this.inputSpec;
34793      this.inputSpec = h;
34794      var f = e.prototype.apply.call(this, p, n);
34795      return this.inputSpec = d, f;
34796    }
34797
34798    return e.prototype.apply.call(this, t, n);
34799  }, t.prototype.call = function (e, t) {
34800    var n = this;
34801    return (0, _tfjsCore.tidy)(function () {
34802      var r = null == t ? null : t.mask,
34803          i = null == t ? null : t.training,
34804          a = null == t ? null : t.initialState;
34805      e = getExactlyOneTensor(e), null == a && (a = n.stateful ? n.states_ : n.getInitialState(e));
34806      var o = Array.isArray(n.cell.stateSize) ? n.cell.stateSize.length : 1;
34807      if (a.length !== o) throw new ValueError("RNN Layer has " + o + " state(s) but was passed " + a.length + " initial state(s).");
34808      n.unroll && console.warn("Ignoring unroll = true for RNN layer, due to imperative backend.");
34809      var s = {
34810        training: i
34811      },
34812          l = rnn(function (e, t) {
34813        var r = n.cell.call([e].concat(t), s);
34814        return [r[0], r.slice(1)];
34815      }, e, a, n.goBackwards, r, null, n.unroll, n.returnSequences),
34816          u = l[0],
34817          c = l[1],
34818          p = l[2];
34819      n.stateful && n.resetStates(p, i);
34820      var h = n.returnSequences ? c : u;
34821      return n.returnState ? [h].concat(p) : h;
34822    });
34823  }, t.prototype.getInitialState = function (e) {
34824    var t = this;
34825    return (0, _tfjsCore.tidy)(function () {
34826      var n = (0, _tfjsCore.zeros)(e.shape);
34827      return n = expandDims$1(n = (0, _tfjsCore.sum)(n, [1, 2])), Array.isArray(t.cell.stateSize) ? t.cell.stateSize.map(function (e) {
34828        return e > 1 ? tile$1(n, [1, e]) : n;
34829      }) : t.cell.stateSize > 1 ? [tile$1(n, [1, t.cell.stateSize])] : [n];
34830    });
34831  }, Object.defineProperty(t.prototype, "trainableWeights", {
34832    get: function () {
34833      return this.trainable ? this.cell.trainableWeights : [];
34834    },
34835    enumerable: !0,
34836    configurable: !0
34837  }), Object.defineProperty(t.prototype, "nonTrainableWeights", {
34838    get: function () {
34839      return this.trainable ? this.cell.nonTrainableWeights : this.cell.weights;
34840    },
34841    enumerable: !0,
34842    configurable: !0
34843  }), t.prototype.setFastWeightInitDuringBuild = function (t) {
34844    e.prototype.setFastWeightInitDuringBuild.call(this, t), null != this.cell && this.cell.setFastWeightInitDuringBuild(t);
34845  }, t.prototype.getConfig = function () {
34846    var t = {
34847      returnSequences: this.returnSequences,
34848      returnState: this.returnState,
34849      goBackwards: this.goBackwards,
34850      stateful: this.stateful,
34851      unroll: this.unroll
34852    };
34853    null != this.numConstants && (t.numConstants = this.numConstants);
34854    var n = this.cell.getConfig();
34855    t.cell = {
34856      className: this.cell.getClassName(),
34857      config: n
34858    };
34859    var r = e.prototype.getConfig.call(this);
34860    return Object.assign(t, r), t;
34861  }, t.fromConfig = function (e, t, n) {
34862    void 0 === n && (n = {});
34863    var r = deserialize(t.cell, n);
34864    return new e(Object.assign(t, {
34865      cell: r
34866    }));
34867  }, t.className = "RNN", t;
34868}(Layer);
34869
34870exports.RNN = RNN;
34871
34872_tfjsCore.serialization.registerClass(RNN);
34873
34874var RNNCell = function (e) {
34875  function t() {
34876    return null !== e && e.apply(this, arguments) || this;
34877  }
34878
34879  return __extends(t, e), t;
34880}(Layer),
34881    SimpleRNNCell = function (e) {
34882  function t(t) {
34883    var n = e.call(this, t) || this;
34884    return n.DEFAULT_ACTIVATION = "tanh", n.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", n.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", n.DEFAULT_BIAS_INITIALIZER = "zeros", n.units = t.units, assertPositiveInteger(n.units, "units"), n.activation = getActivation(null == t.activation ? n.DEFAULT_ACTIVATION : t.activation), n.useBias = null == t.useBias || t.useBias, n.kernelInitializer = getInitializer(t.kernelInitializer || n.DEFAULT_KERNEL_INITIALIZER), n.recurrentInitializer = getInitializer(t.recurrentInitializer || n.DEFAULT_RECURRENT_INITIALIZER), n.biasInitializer = getInitializer(t.biasInitializer || n.DEFAULT_BIAS_INITIALIZER), n.kernelRegularizer = getRegularizer(t.kernelRegularizer), n.recurrentRegularizer = getRegularizer(t.recurrentRegularizer), n.biasRegularizer = getRegularizer(t.biasRegularizer), n.kernelConstraint = getConstraint(t.kernelConstraint), n.recurrentConstraint = getConstraint(t.recurrentConstraint), n.biasConstraint = getConstraint(t.biasConstraint), n.dropout = min$1([1, max$1([0, null == t.dropout ? 0 : t.dropout])]), n.recurrentDropout = min$1([1, max$1([0, null == t.recurrentDropout ? 0 : t.recurrentDropout])]), n.stateSize = n.units, n.dropoutMask = null, n.recurrentDropoutMask = null, n;
34885  }
34886
34887  return __extends(t, e), t.prototype.build = function (e) {
34888    e = getExactlyOneShape(e), this.kernel = this.addWeight("kernel", [e[e.length - 1], this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, this.units], null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias ? this.bias = this.addWeight("bias", [this.units], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.built = !0;
34889  }, t.prototype.call = function (e, t) {
34890    var n = this;
34891    return (0, _tfjsCore.tidy)(function () {
34892      if (2 !== (e = e).length) throw new ValueError("SimpleRNNCell expects 2 input Tensors, got " + e.length + ".");
34893      var r = e[1];
34894      e = e[0];
34895      var i,
34896          a = null != t.training && t.training;
34897      0 < n.dropout && n.dropout < 1 && null == n.dropoutMask && (n.dropoutMask = generateDropoutMask(function () {
34898        return (0, _tfjsCore.onesLike)(e);
34899      }, n.dropout, a)), 0 < n.recurrentDropout && n.recurrentDropout < 1 && null == n.recurrentDropoutMask && (n.recurrentDropoutMask = generateDropoutMask(function () {
34900        return (0, _tfjsCore.onesLike)(r);
34901      }, n.recurrentDropout, a));
34902      var o = n.dropoutMask,
34903          s = n.recurrentDropoutMask;
34904      i = dot(null != o ? (0, _tfjsCore.mul)(e, o) : e, n.kernel.read()), null != n.bias && (i = biasAdd(i, n.bias.read())), null != s && (r = (0, _tfjsCore.mul)(r, s));
34905      var l = (0, _tfjsCore.add)(i, dot(r, n.recurrentKernel.read()));
34906      return null != n.activation && (l = n.activation.apply(l)), [l, l];
34907    });
34908  }, t.prototype.getConfig = function () {
34909    var t = {
34910      units: this.units,
34911      activation: serializeActivation(this.activation),
34912      useBias: this.useBias,
34913      kernelInitializer: serializeInitializer(this.kernelInitializer),
34914      recurrentInitializer: serializeInitializer(this.recurrentInitializer),
34915      biasInitializer: serializeInitializer(this.biasInitializer),
34916      kernelRegularizer: serializeRegularizer(this.kernelRegularizer),
34917      recurrentRegularizer: serializeRegularizer(this.recurrentRegularizer),
34918      biasRegularizer: serializeRegularizer(this.biasRegularizer),
34919      activityRegularizer: serializeRegularizer(this.activityRegularizer),
34920      kernelConstraint: serializeConstraint(this.kernelConstraint),
34921      recurrentConstraint: serializeConstraint(this.recurrentConstraint),
34922      biasConstraint: serializeConstraint(this.biasConstraint),
34923      dropout: this.dropout,
34924      recurrentDropout: this.recurrentDropout
34925    },
34926        n = e.prototype.getConfig.call(this);
34927    return Object.assign(t, n), t;
34928  }, t.className = "SimpleRNNCell", t;
34929}(RNNCell);
34930
34931_tfjsCore.serialization.registerClass(SimpleRNNCell);
34932
34933var SimpleRNN = function (e) {
34934  function t(t) {
34935    return t.cell = new SimpleRNNCell(t), e.call(this, t) || this;
34936  }
34937
34938  return __extends(t, e), t.prototype.call = function (t, n) {
34939    var r = this;
34940    return (0, _tfjsCore.tidy)(function () {
34941      null != r.cell.dropoutMask && ((0, _tfjsCore.dispose)(r.cell.dropoutMask), r.cell.dropoutMask = null), null != r.cell.recurrentDropoutMask && ((0, _tfjsCore.dispose)(r.cell.recurrentDropoutMask), r.cell.recurrentDropoutMask = null);
34942      var i = null == n ? null : n.mask,
34943          a = null == n ? null : n.training,
34944          o = null == n ? null : n.initialState;
34945      return e.prototype.call.call(r, t, {
34946        mask: i,
34947        training: a,
34948        initialState: o
34949      });
34950    });
34951  }, Object.defineProperty(t.prototype, "units", {
34952    get: function () {
34953      return this.cell.units;
34954    },
34955    enumerable: !0,
34956    configurable: !0
34957  }), Object.defineProperty(t.prototype, "activation", {
34958    get: function () {
34959      return this.cell.activation;
34960    },
34961    enumerable: !0,
34962    configurable: !0
34963  }), Object.defineProperty(t.prototype, "useBias", {
34964    get: function () {
34965      return this.cell.useBias;
34966    },
34967    enumerable: !0,
34968    configurable: !0
34969  }), Object.defineProperty(t.prototype, "kernelInitializer", {
34970    get: function () {
34971      return this.cell.kernelInitializer;
34972    },
34973    enumerable: !0,
34974    configurable: !0
34975  }), Object.defineProperty(t.prototype, "recurrentInitializer", {
34976    get: function () {
34977      return this.cell.recurrentInitializer;
34978    },
34979    enumerable: !0,
34980    configurable: !0
34981  }), Object.defineProperty(t.prototype, "biasInitializer", {
34982    get: function () {
34983      return this.cell.biasInitializer;
34984    },
34985    enumerable: !0,
34986    configurable: !0
34987  }), Object.defineProperty(t.prototype, "kernelRegularizer", {
34988    get: function () {
34989      return this.cell.kernelRegularizer;
34990    },
34991    enumerable: !0,
34992    configurable: !0
34993  }), Object.defineProperty(t.prototype, "recurrentRegularizer", {
34994    get: function () {
34995      return this.cell.recurrentRegularizer;
34996    },
34997    enumerable: !0,
34998    configurable: !0
34999  }), Object.defineProperty(t.prototype, "biasRegularizer", {
35000    get: function () {
35001      return this.cell.biasRegularizer;
35002    },
35003    enumerable: !0,
35004    configurable: !0
35005  }), Object.defineProperty(t.prototype, "kernelConstraint", {
35006    get: function () {
35007      return this.cell.kernelConstraint;
35008    },
35009    enumerable: !0,
35010    configurable: !0
35011  }), Object.defineProperty(t.prototype, "recurrentConstraint", {
35012    get: function () {
35013      return this.cell.recurrentConstraint;
35014    },
35015    enumerable: !0,
35016    configurable: !0
35017  }), Object.defineProperty(t.prototype, "biasConstraint", {
35018    get: function () {
35019      return this.cell.biasConstraint;
35020    },
35021    enumerable: !0,
35022    configurable: !0
35023  }), Object.defineProperty(t.prototype, "dropout", {
35024    get: function () {
35025      return this.cell.dropout;
35026    },
35027    enumerable: !0,
35028    configurable: !0
35029  }), Object.defineProperty(t.prototype, "recurrentDropout", {
35030    get: function () {
35031      return this.cell.recurrentDropout;
35032    },
35033    enumerable: !0,
35034    configurable: !0
35035  }), t.prototype.getConfig = function () {
35036    var t = {
35037      units: this.units,
35038      activation: serializeActivation(this.activation),
35039      useBias: this.useBias,
35040      kernelInitializer: serializeInitializer(this.kernelInitializer),
35041      recurrentInitializer: serializeInitializer(this.recurrentInitializer),
35042      biasInitializer: serializeInitializer(this.biasInitializer),
35043      kernelRegularizer: serializeRegularizer(this.kernelRegularizer),
35044      recurrentRegularizer: serializeRegularizer(this.recurrentRegularizer),
35045      biasRegularizer: serializeRegularizer(this.biasRegularizer),
35046      activityRegularizer: serializeRegularizer(this.activityRegularizer),
35047      kernelConstraint: serializeConstraint(this.kernelConstraint),
35048      recurrentConstraint: serializeConstraint(this.recurrentConstraint),
35049      biasConstraint: serializeConstraint(this.biasConstraint),
35050      dropout: this.dropout,
35051      recurrentDropout: this.recurrentDropout
35052    },
35053        n = e.prototype.getConfig.call(this);
35054    return delete n.cell, Object.assign(t, n), t;
35055  }, t.fromConfig = function (e, t) {
35056    return new e(t);
35057  }, t.className = "SimpleRNN", t;
35058}(RNN);
35059
35060_tfjsCore.serialization.registerClass(SimpleRNN);
35061
35062var GRUCell = function (e) {
35063  function t(t) {
35064    var n = e.call(this, t) || this;
35065    return n.DEFAULT_ACTIVATION = "tanh", n.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", n.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", n.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", n.DEFAULT_BIAS_INITIALIZER = "zeros", n.units = t.units, assertPositiveInteger(n.units, "units"), n.activation = getActivation(void 0 === t.activation ? n.DEFAULT_ACTIVATION : t.activation), n.recurrentActivation = getActivation(void 0 === t.recurrentActivation ? n.DEFAULT_RECURRENT_ACTIVATION : t.recurrentActivation), n.useBias = null == t.useBias || t.useBias, n.kernelInitializer = getInitializer(t.kernelInitializer || n.DEFAULT_KERNEL_INITIALIZER), n.recurrentInitializer = getInitializer(t.recurrentInitializer || n.DEFAULT_RECURRENT_INITIALIZER), n.bi
35065asInitializer = getInitializer(t.biasInitializer || n.DEFAULT_BIAS_INITIALIZER), n.kernelRegularizer = getRegularizer(t.kernelRegularizer), n.recurrentRegularizer = getRegularizer(t.recurrentRegularizer), n.biasRegularizer = getRegularizer(t.biasRegularizer), n.kernelConstraint = getConstraint(t.kernelConstraint), n.recurrentConstraint = getConstraint(t.recurrentConstraint), n.biasConstraint = getConstraint(t.biasConstraint), n.dropout = min$1([1, max$1([0, null == t.dropout ? 0 : t.dropout])]), n.recurrentDropout = min$1([1, max$1([0, null == t.recurrentDropout ? 0 : t.recurrentDropout])]), n.implementation = t.implementation, n.stateSize = n.units, n.dropoutMask = null, n.recurrentDropoutMask = null, n;
35066  }
35067
35068  return __extends(t, e), t.prototype.build = function (e) {
35069    var t = (e = getExactlyOneShape(e))[e.length - 1];
35070    this.kernel = this.addWeight("kernel", [t, 3 * this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, 3 * this.units], null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias ? this.bias = this.addWeight("bias", [3 * this.units], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.built = !0;
35071  }, t.prototype.call = function (e, t) {
35072    var n = this;
35073    return (0, _tfjsCore.tidy)(function () {
35074      if (2 !== (e = e).length) throw new ValueError("GRUCell expects 2 input Tensors (inputs, h, c), got " + e.length + ".");
35075      var r = null != t.training && t.training,
35076          i = e[1];
35077      e = e[0], 0 < n.dropout && n.dropout < 1 && null == n.dropoutMask && (n.dropoutMask = generateDropoutMask(function () {
35078        return (0, _tfjsCore.onesLike)(e);
35079      }, n.dropout, r, 3)), 0 < n.recurrentDropout && n.recurrentDropout < 1 && null == n.recurrentDropoutMask && (n.recurrentDropoutMask = generateDropoutMask(function () {
35080        return (0, _tfjsCore.onesLike)(i);
35081      }, n.recurrentDropout, r, 3));
35082      var a,
35083          o,
35084          s,
35085          l = n.dropoutMask,
35086          u = n.recurrentDropoutMask;
35087      0 < n.dropout && n.dropout < 1 && (e = (0, _tfjsCore.mul)(e, l[0]));
35088      var c = dot(e, n.kernel.read());
35089      n.useBias && (c = biasAdd(c, n.bias.read())), 0 < n.recurrentDropout && n.recurrentDropout < 1 && (i = (0, _tfjsCore.mul)(i, u[0]));
35090      var p = n.recurrentKernel.read(),
35091          h = (0, _tfjsCore.split)(p, [2 * n.units, n.units], p.rank - 1),
35092          d = h[0],
35093          f = h[1],
35094          g = dot(i, d),
35095          m = (0, _tfjsCore.split)(c, 3, c.rank - 1),
35096          y = m[0],
35097          v = m[1],
35098          b = m[2],
35099          w = (0, _tfjsCore.split)(g, 2, g.rank - 1),
35100          z = w[0],
35101          S = w[1];
35102      a = n.recurrentActivation.apply((0, _tfjsCore.add)(y, z)), o = n.recurrentActivation.apply((0, _tfjsCore.add)(v, S));
35103      var A = dot((0, _tfjsCore.mul)(o, i), f);
35104      s = n.activation.apply((0, _tfjsCore.add)(b, A));
35105
35106      var _ = (0, _tfjsCore.add)((0, _tfjsCore.mul)(a, i), (0, _tfjsCore.mul)((0, _tfjsCore.add)(1, (0, _tfjsCore.neg)(a)), s));
35107
35108      return [_, _];
35109    });
35110  }, t.prototype.getConfig = function () {
35111    var t = {
35112      units: this.units,
35113      activation: serializeActivation(this.activation),
35114      recurrentActivation: serializeActivation(this.recurrentActivation),
35115      useBias: this.useBias,
35116      kernelInitializer: serializeInitializer(this.kernelInitializer),
35117      recurrentInitializer: serializeInitializer(this.recurrentInitializer),
35118      biasInitializer: serializeInitializer(this.biasInitializer),
35119      kernelRegularizer: serializeRegularizer(this.kernelRegularizer),
35120      recurrentRegularizer: serializeRegularizer(this.recurrentRegularizer),
35121      biasRegularizer: serializeRegularizer(this.biasRegularizer),
35122      activityRegularizer: serializeRegularizer(this.activityRegularizer),
35123      kernelConstraint: serializeConstraint(this.kernelConstraint),
35124      recurrentConstraint: serializeConstraint(this.recurrentConstraint),
35125      biasConstraint: serializeConstraint(this.biasConstraint),
35126      dropout: this.dropout,
35127      recurrentDropout: this.recurrentDropout,
35128      implementation: this.implementation
35129    },
35130        n = e.prototype.getConfig.call(this);
35131    return Object.assign(t, n), t;
35132  }, t.className = "GRUCell", t;
35133}(RNNCell);
35134
35135_tfjsCore.serialization.registerClass(GRUCell);
35136
35137var GRU = function (e) {
35138  function t(t) {
35139    return 0 === t.implementation && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), t.cell = new GRUCell(t), e.call(this, t) || this;
35140  }
35141
35142  return __extends(t, e), t.prototype.call = function (t, n) {
35143    var r = this;
35144    return (0, _tfjsCore.tidy)(function () {
35145      null != r.cell.dropoutMask && ((0, _tfjsCore.dispose)(r.cell.dropoutMask), r.cell.dropoutMask = null), null != r.cell.recurrentDropoutMask && ((0, _tfjsCore.dispose)(r.cell.recurrentDropoutMask), r.cell.recurrentDropoutMask = null);
35146      var i = null == n ? null : n.mask,
35147          a = null == n ? null : n.training,
35148          o = null == n ? null : n.initialState;
35149      return e.prototype.call.call(r, t, {
35150        mask: i,
35151        training: a,
35152        initialState: o
35153      });
35154    });
35155  }, Object.defineProperty(t.prototype, "units", {
35156    get: function () {
35157      return this.cell.units;
35158    },
35159    enumerable: !0,
35160    configurable: !0
35161  }), Object.defineProperty(t.prototype, "activation", {
35162    get: function () {
35163      return this.cell.activation;
35164    },
35165    enumerable: !0,
35166    configurable: !0
35167  }), Object.defineProperty(t.prototype, "recurrentActivation", {
35168    get: function () {
35169      return this.cell.recurrentActivation;
35170    },
35171    enumerable: !0,
35172    configurable: !0
35173  }), Object.defineProperty(t.prototype, "useBias", {
35174    get: function () {
35175      return this.cell.useBias;
35176    },
35177    enumerable: !0,
35178    configurable: !0
35179  }), Object.defineProperty(t.prototype, "kernelInitializer", {
35180    get: function () {
35181      return this.cell.kernelInitializer;
35182    },
35183    enumerable: !0,
35184    configurable: !0
35185  }), Object.defineProperty(t.prototype, "recurrentInitializer", {
35186    get: function () {
35187      return this.cell.recurrentInitializer;
35188    },
35189    enumerable: !0,
35190    configurable: !0
35191  }), Object.defineProperty(t.prototype, "biasInitializer", {
35192    get: function () {
35193      return this.cell.biasInitializer;
35194    },
35195    enumerable: !0,
35196    configurable: !0
35197  }), Object.defineProperty(t.prototype, "kernelRegularizer", {
35198    get: function () {
35199      return this.cell.kernelRegularizer;
35200    },
35201    enumerable: !0,
35202    configurable: !0
35203  }), Object.defineProperty(t.prototype, "recurrentRegularizer", {
35204    get: function () {
35205      return this.cell.recurrentRegularizer;
35206    },
35207    enumerable: !0,
35208    configurable: !0
35209  }), Object.defineProperty(t.prototype, "biasRegularizer", {
35210    get: function () {
35211      return this.cell.biasRegularizer;
35212    },
35213    enumerable: !0,
35214    configurable: !0
35215  }), Object.defineProperty(t.prototype, "kernelConstraint", {
35216    get: function () {
35217      return this.cell.kernelConstraint;
35218    },
35219    enumerable: !0,
35220    configurable: !0
35221  }), Object.defineProperty(t.prototype, "recurrentConstraint", {
35222    get: function () {
35223      return this.cell.recurrentConstraint;
35224    },
35225    enumerable: !0,
35226    configurable: !0
35227  }), Object.defineProperty(t.prototype, "biasConstraint", {
35228    get: function () {
35229      return this.cell.biasConstraint;
35230    },
35231    enumerable: !0,
35232    configurable: !0
35233  }), Object.defineProperty(t.prototype, "dropout", {
35234    get: function () {
35235      return this.cell.dropout;
35236    },
35237    enumerable: !0,
35238    configurable: !0
35239  }), Object.defineProperty(t.prototype, "recurrentDropout", {
35240    get: function () {
35241      return this.cell.recurrentDropout;
35242    },
35243    enumerable: !0,
35244    configurable: !0
35245  }), Object.defineProperty(t.prototype, "implementation", {
35246    get: function () {
35247      return this.cell.implementation;
35248    },
35249    enumerable: !0,
35250    configurable: !0
35251  }), t.prototype.getConfig = function () {
35252    var t = {
35253      units: this.units,
35254      activation: serializeActivation(this.activation),
35255      recurrentActivation: serializeActivation(this.recurrentActivation),
35256      useBias: this.useBias,
35257      kernelInitializer: serializeInitializer(this.kernelInitializer),
35258      recurrentInitializer: serializeInitializer(this.recurrentInitializer),
35259      biasInitializer: serializeInitializer(this.biasInitializer),
35260      kernelRegularizer: serializeRegularizer(this.kernelRegularizer),
35261      recurrentRegularizer: serializeRegularizer(this.recurrentRegularizer),
35262      biasRegularizer: serializeRegularizer(this.biasRegularizer),
35263      activityRegularizer: serializeRegularizer(this.activityRegularizer),
35264      kernelConstraint: serializeConstraint(this.kernelConstraint),
35265      recurrentConstraint: serializeConstraint(this.recurrentConstraint),
35266      biasConstraint: serializeConstraint(this.biasConstraint),
35267      dropout: this.dropout,
35268      recurrentDropout: this.recurrentDropout,
35269      implementation: this.implementation
35270    },
35271        n = e.prototype.getConfig.call(this);
35272    return delete n.cell, Object.assign(t, n), t;
35273  }, t.fromConfig = function (e, t) {
35274    return 0 === t.implmentation && (t.implementation = 1), new e(t);
35275  }, t.className = "GRU", t;
35276}(RNN);
35277
35278_tfjsCore.serialization.registerClass(GRU);
35279
35280var LSTMCell = function (e) {
35281  function t(t) {
35282    var n = e.call(this, t) || this;
35283    return n.DEFAULT_ACTIVATION = "tanh", n.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", n.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", n.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", n.DEFAULT_BIAS_INITIALIZER = "zeros", n.units = t.units, assertPositiveInteger(n.units, "units"), n.activation = getActivation(void 0 === t.activation ? n.DEFAULT_ACTIVATION : t.activation), n.recurrentActivation = getActivation(void 0 === t.recurrentActivation ? n.DEFAULT_RECURRENT_ACTIVATION : t.recurrentActivation), n.useBias = null == t.useBias || t.useBias, n.kernelInitializer = getInitializer(t.kernelInitializer || n.DEFAULT_KERNEL_INITIALIZER), n.recurrentInitializer = getInitializer(t.recurrentInitializer || n.DEFAULT_RECURRENT_INITIALIZER), n.bi
35283asInitializer = getInitializer(t.biasInitializer || n.DEFAULT_BIAS_INITIALIZER), n.unitForgetBias = t.unitForgetBias, n.kernelRegularizer = getRegularizer(t.kernelRegularizer), n.recurrentRegularizer = getRegularizer(t.recurrentRegularizer), n.biasRegularizer = getRegularizer(t.biasRegularizer), n.kernelConstraint = getConstraint(t.kernelConstraint), n.recurrentConstraint = getConstraint(t.recurrentConstraint), n.biasConstraint = getConstraint(t.biasConstraint), n.dropout = min$1([1, max$1([0, null == t.dropout ? 0 : t.dropout])]), n.recurrentDropout = min$1([1, max$1([0, null == t.recurrentDropout ? 0 : t.recurrentDropout])]), n.implementation = t.implementation, n.stateSize = [n.units, n.units], n.dropoutMask = null, n.recurrentDropoutMask = null, n;
35284  }
35285
35286  return __extends(t, e), t.prototype.build = function (e) {
35287    var t,
35288        n,
35289        r = (e = getExactlyOneShape(e))[e.length - 1];
35290
35291    if (this.kernel = this.addWeight("kernel", [r, 4 * this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, 4 * this.units], null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias) {
35292      if (this.unitForgetBias) {
35293        var i = this.biasInitializer,
35294            a = this.units;
35295        n = new ((t = function (e) {
35296          function t() {
35297            return null !== e && e.apply(this, arguments) || this;
35298          }
35299
35300          return __extends(t, e), t.prototype.apply = function (e, t) {
35301            var n = i.apply([a]),
35302                r = new Ones().apply([a]),
35303                o = i.apply([2 * a]);
35304            return concatAlongFirstAxis(concatAlongFirstAxis(n, r), o);
35305          }, t;
35306        }(Initializer)).className = "CustomInit", t)();
35307      } else n = this.biasInitializer;
35308
35309      this.bias = this.addWeight("bias", [4 * this.units], null, n, this.biasRegularizer, !0, this.biasConstraint);
35310    } else this.bias = null;
35311
35312    this.built = !0;
35313  }, t.prototype.call = function (e, t) {
35314    var n = this;
35315    return (0, _tfjsCore.tidy)(function () {
35316      var r = null != t.training && t.training;
35317      if (3 !== (e = e).length) throw new ValueError("LSTMCell expects 3 input Tensors (inputs, h, c), got " + e.length + ".");
35318      var i = e[1],
35319          a = e[2];
35320      e = e[0], 0 < n.dropout && n.dropout < 1 && null == n.dropoutMask && (n.dropoutMask = generateDropoutMask(function () {
35321        return (0, _tfjsCore.onesLike)(e);
35322      }, n.dropout, r, 4)), 0 < n.recurrentDropout && n.recurrentDropout < 1 && null == n.recurrentDropoutMask && (n.recurrentDropoutMask = generateDropoutMask(function () {
35323        return (0, _tfjsCore.onesLike)(i);
35324      }, n.recurrentDropout, r, 4));
35325      var o,
35326          s,
35327          l,
35328          u,
35329          c = n.dropoutMask,
35330          p = n.recurrentDropoutMask;
35331      0 < n.dropout && n.dropout < 1 && (e = (0, _tfjsCore.mul)(e, c[0]));
35332      var h = dot(e, n.kernel.read());
35333      0 < n.recurrentDropout && n.recurrentDropout < 1 && (i = (0, _tfjsCore.mul)(i, p[0])), h = (0, _tfjsCore.add)(h, dot(i, n.recurrentKernel.read())), n.useBias && (h = biasAdd(h, n.bias.read()));
35334      var d = (0, _tfjsCore.split)(h, 4, h.rank - 1),
35335          f = d[0],
35336          g = d[1],
35337          m = d[2],
35338          y = d[3];
35339      o = n.recurrentActivation.apply(f), s = n.recurrentActivation.apply(g), l = (0, _tfjsCore.add)((0, _tfjsCore.mul)(s, a), (0, _tfjsCore.mul)(o, n.activation.apply(m))), u = n.recurrentActivation.apply(y);
35340      var v = (0, _tfjsCore.mul)(u, n.activation.apply(l));
35341      return [v, v, l];
35342    });
35343  }, t.prototype.getConfig = function () {
35344    var t = {
35345      units: this.units,
35346      activation: serializeActivation(this.activation),
35347      recurrentActivation: serializeActivation(this.recurrentActivation),
35348      useBias: this.useBias,
35349      kernelInitializer: serializeInitializer(this.kernelInitializer),
35350      recurrentInitializer: serializeInitializer(this.recurrentInitializer),
35351      biasInitializer: serializeInitializer(this.biasInitializer),
35352      unitForgetBias: this.unitForgetBias,
35353      kernelRegularizer: serializeRegularizer(this.kernelRegularizer),
35354      recurrentRegularizer: serializeRegularizer(this.recurrentRegularizer),
35355      biasRegularizer: serializeRegularizer(this.biasRegularizer),
35356      activityRegularizer: serializeRegularizer(this.activityRegularizer),
35357      kernelConstraint: serializeConstraint(this.kernelConstraint),
35358      recurrentConstraint: serializeConstraint(this.recurrentConstraint),
35359      biasConstraint: serializeConstraint(this.biasConstraint),
35360      dropout: this.dropout,
35361      recurrentDropout: this.recurrentDropout,
35362      implementation: this.implementation
35363    },
35364        n = e.prototype.getConfig.call(this);
35365    return Object.assign(t, n), t;
35366  }, t.className = "LSTMCell", t;
35367}(RNNCell);
35368
35369_tfjsCore.serialization.registerClass(LSTMCell);
35370
35371var LSTM = function (e) {
35372  function t(t) {
35373    return 0 === t.implementation && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), t.cell = new LSTMCell(t), e.call(this, t) || this;
35374  }
35375
35376  return __extends(t, e), t.prototype.call = function (t, n) {
35377    var r = this;
35378    return (0, _tfjsCore.tidy)(function () {
35379      null != r.cell.dropoutMask && ((0, _tfjsCore.dispose)(r.cell.dropoutMask), r.cell.dropoutMask = null), null != r.cell.recurrentDropoutMask && ((0, _tfjsCore.dispose)(r.cell.recurrentDropoutMask), r.cell.recurrentDropoutMask = null);
35380      var i = null == n ? null : n.mask,
35381          a = null == n ? null : n.training,
35382          o = null == n ? null : n.initialState;
35383      return e.prototype.call.call(r, t, {
35384        mask: i,
35385        training: a,
35386        initialState: o
35387      });
35388    });
35389  }, Object.defineProperty(t.prototype, "units", {
35390    get: function () {
35391      return this.cell.units;
35392    },
35393    enumerable: !0,
35394    configurable: !0
35395  }), Object.defineProperty(t.prototype, "activation", {
35396    get: function () {
35397      return this.cell.activation;
35398    },
35399    enumerable: !0,
35400    configurable: !0
35401  }), Object.defineProperty(t.prototype, "recurrentActivation", {
35402    get: function () {
35403      return this.cell.recurrentActivation;
35404    },
35405    enumerable: !0,
35406    configurable: !0
35407  }), Object.defineProperty(t.prototype, "useBias", {
35408    get: function () {
35409      return this.cell.useBias;
35410    },
35411    enumerable: !0,
35412    configurable: !0
35413  }), Object.defineProperty(t.prototype, "kernelInitializer", {
35414    get: function () {
35415      return this.cell.kernelInitializer;
35416    },
35417    enumerable: !0,
35418    configurable: !0
35419  }), Object.defineProperty(t.prototype, "recurrentInitializer", {
35420    get: function () {
35421      return this.cell.recurrentInitializer;
35422    },
35423    enumerable: !0,
35424    configurable: !0
35425  }), Object.defineProperty(t.prototype, "biasInitializer", {
35426    get: function () {
35427      return this.cell.biasInitializer;
35428    },
35429    enumerable: !0,
35430    configurable: !0
35431  }), Object.defineProperty(t.prototype, "unitForgetBias", {
35432    get: function () {
35433      return this.cell.unitForgetBias;
35434    },
35435    enumerable: !0,
35436    configurable: !0
35437  }), Object.defineProperty(t.prototype, "kernelRegularizer", {
35438    get: function () {
35439      return this.cell.kernelRegularizer;
35440    },
35441    enumerable: !0,
35442    configurable: !0
35443  }), Object.defineProperty(t.prototype, "recurrentRegularizer", {
35444    get: function () {
35445      return this.cell.recurrentRegularizer;
35446    },
35447    enumerable: !0,
35448    configurable: !0
35449  }), Object.defineProperty(t.prototype, "biasRegularizer", {
35450    get: function () {
35451      return this.cell.biasRegularizer;
35452    },
35453    enumerable: !0,
35454    configurable: !0
35455  }), Object.defineProperty(t.prototype, "kernelConstraint", {
35456    get: function () {
35457      return this.cell.kernelConstraint;
35458    },
35459    enumerable: !0,
35460    configurable: !0
35461  }), Object.defineProperty(t.prototype, "recurrentConstraint", {
35462    get: function () {
35463      return this.cell.recurrentConstraint;
35464    },
35465    enumerable: !0,
35466    configurable: !0
35467  }), Object.defineProperty(t.prototype, "biasConstraint", {
35468    get: function () {
35469      return this.cell.biasConstraint;
35470    },
35471    enumerable: !0,
35472    configurable: !0
35473  }), Object.defineProperty(t.prototype, "dropout", {
35474    get: function () {
35475      return this.cell.dropout;
35476    },
35477    enumerable: !0,
35478    configurable: !0
35479  }), Object.defineProperty(t.prototype, "recurrentDropout", {
35480    get: function () {
35481      return this.cell.recurrentDropout;
35482    },
35483    enumerable: !0,
35484    configurable: !0
35485  }), Object.defineProperty(t.prototype, "implementation", {
35486    get: function () {
35487      return this.cell.implementation;
35488    },
35489    enumerable: !0,
35490    configurable: !0
35491  }), t.prototype.getConfig = function () {
35492    var t = {
35493      units: this.units,
35494      activation: serializeActivation(this.activation),
35495      recurrentActivation: serializeActivation(this.recurrentActivation),
35496      useBias: this.useBias,
35497      kernelInitializer: serializeInitializer(this.kernelInitializer),
35498      recurrentInitializer: serializeInitializer(this.recurrentInitializer),
35499      biasInitializer: serializeInitializer(this.biasInitializer),
35500      unitForgetBias: this.unitForgetBias,
35501      kernelRegularizer: serializeRegularizer(this.kernelRegularizer),
35502      recurrentRegularizer: serializeRegularizer(this.recurrentRegularizer),
35503      biasRegularizer: serializeRegularizer(this.biasRegularizer),
35504      activityRegularizer: serializeRegularizer(this.activityRegularizer),
35505      kernelConstraint: serializeConstraint(this.kernelConstraint),
35506      recurrentConstraint: serializeConstraint(this.recurrentConstraint),
35507      biasConstraint: serializeConstraint(this.biasConstraint),
35508      dropout: this.dropout,
35509      recurrentDropout: this.recurrentDropout,
35510      implementation: this.implementation
35511    },
35512        n = e.prototype.getConfig.call(this);
35513    return delete n.cell, Object.assign(t, n), t;
35514  }, t.fromConfig = function (e, t) {
35515    return 0 === t.implmentation && (t.implementation = 1), new e(t);
35516  }, t.className = "LSTM", t;
35517}(RNN);
35518
35519_tfjsCore.serialization.registerClass(LSTM);
35520
35521var StackedRNNCells = function (e) {
35522  function t(t) {
35523    var n = e.call(this, t) || this;
35524    return n.cells = t.cells, n;
35525  }
35526
35527  return __extends(t, e), Object.defineProperty(t.prototype, "stateSize", {
35528    get: function () {
35529      for (var e = [], t = 0, n = this.cells.slice().reverse(); t < n.length; t++) {
35530        var r = n[t];
35531        Array.isArray(r.stateSize) ? e.push.apply(e, r.stateSize) : e.push(r.stateSize);
35532      }
35533
35534      return e;
35535    },
35536    enumerable: !0,
35537    configurable: !0
35538  }), t.prototype.call = function (e, t) {
35539    var n = this;
35540    return (0, _tfjsCore.tidy)(function () {
35541      for (var r = (e = e).slice(1), i = [], a = 0, o = n.cells.slice().reverse(); a < o.length; a++) {
35542        var s = o[a];
35543        Array.isArray(s.stateSize) ? i.push(r.splice(0, s.stateSize.length)) : i.push(r.splice(0, 1));
35544      }
35545
35546      i.reverse();
35547
35548      for (var l, u = [], c = 0; c < n.cells.length; ++c) {
35549        s = n.cells[c];
35550        r = i[c], l = 0 === c ? [e[0]].concat(r) : [l[0]].concat(r), l = s.call(l, t), u.push(l.slice(1));
35551      }
35552
35553      r = [];
35554
35555      for (var p = 0, h = u.slice().reverse(); p < h.length; p++) {
35556        var d = h[p];
35557        r.push.apply(r, d);
35558      }
35559
35560      return [l[0]].concat(r);
35561    });
35562  }, t.prototype.build = function (e) {
35563    var t;
35564    isArrayOfShapes(e) && (e = e[0]), e = e, this.cells.forEach(function (n, r) {
35565      nameScope("RNNCell_" + r, function () {
35566        n.build(e), t = Array.isArray(n.stateSize) ? n.stateSize[0] : n.stateSize, e = [e[0], t];
35567      });
35568    }), this.built = !0;
35569  }, t.prototype.getConfig = function () {
35570    for (var t = [], n = 0, r = this.cells; n < r.length; n++) {
35571      var i = r[n];
35572      t.push({
35573        className: i.getClassName(),
35574        config: i.getConfig()
35575      });
35576    }
35577
35578    var a = {
35579      cells: t
35580    },
35581        o = e.prototype.getConfig.call(this);
35582    return Object.assign(a, o), a;
35583  }, t.fromConfig = function (e, t, n) {
35584    void 0 === n && (n = {});
35585
35586    for (var r = [], i = 0, a = t.cells; i < a.length; i++) {
35587      var o = a[i];
35588      r.push(deserialize(o, n));
35589    }
35590
35591    return new e({
35592      cells: r
35593    });
35594  }, Object.defineProperty(t.prototype, "trainableWeights", {
35595    get: function () {
35596      if (!this.trainable) return [];
35597
35598      for (var e = [], t = 0, n = this.cells; t < n.length; t++) {
35599        var r = n[t];
35600        e.push.apply(e, r.trainableWeights);
35601      }
35602
35603      return e;
35604    },
35605    enumerable: !0,
35606    configurable: !0
35607  }), Object.defineProperty(t.prototype, "nonTrainableWeights", {
35608    get: function () {
35609      for (var e = [], t = 0, n = this.cells; t < n.length; t++) {
35610        var r = n[t];
35611        e.push.apply(e, r.nonTrainableWeights);
35612      }
35613
35614      if (!this.trainable) {
35615        for (var i = [], a = 0, o = this.cells; a < o.length; a++) {
35616          r = o[a];
35617          i.push.apply(i, r.trainableWeights);
35618        }
35619
35620        return i.concat(e);
35621      }
35622
35623      return e;
35624    },
35625    enumerable: !0,
35626    configurable: !0
35627  }), t.prototype.getWeights = function () {
35628    for (var e = [], t = 0, n = this.cells; t < n.length; t++) {
35629      var r = n[t];
35630      e.push.apply(e, r.weights);
35631    }
35632
35633    return batchGetValue(e);
35634  }, t.prototype.setWeights = function (e) {
35635    for (var t = [], n = 0, r = this.cells; n < r.length; n++) for (var i = r[n], a = i.weights.length, o = e.splice(a), s = 0; s < i.weights.length; ++s) t.push([i.weights[s], o[s]]);
35636
35637    batchSetValue(t);
35638  }, t.className = "StackedRNNCells", t;
35639}(RNNCell);
35640
35641function generateDropoutMask(e, t, n, r) {
35642  function i() {
35643    return dropout$1(e(), t);
35644  }
35645
35646  if (void 0 === n && (n = null), void 0 === r && (r = 1), r > 1) {
35647    for (var a = [], o = 0; o < r; o++) a.push(inTrainPhase(i, e, n));
35648
35649    return a.map(function (e) {
35650      return (0, _tfjsCore.keep)(e.clone());
35651    });
35652  }
35653
35654  return (0, _tfjsCore.keep)(inTrainPhase(i, e, n).clone());
35655}
35656
35657_tfjsCore.serialization.registerClass(StackedRNNCells);
35658
35659var Wrapper = function (e) {
35660  function t(t) {
35661    var n = e.call(this, t) || this;
35662    return n.layer = t.layer, n;
35663  }
35664
35665  return __extends(t, e), t.prototype.build = function (e) {
35666    this.built = !0;
35667  }, Object.defineProperty(t.prototype, "trainable", {
35668    get: function () {
35669      return null != this.layer && this.layer.trainable;
35670    },
35671    set: function (e) {
35672      null != this.layer && (this.layer.trainable = e);
35673    },
35674    enumerable: !0,
35675    configurable: !0
35676  }), Object.defineProperty(t.prototype, "trainableWeights", {
35677    get: function () {
35678      return this.layer.trainableWeights;
35679    },
35680    enumerable: !0,
35681    configurable: !0
35682  }), Object.defineProperty(t.prototype, "nonTrainableWeights", {
35683    get: function () {
35684      return this.layer.nonTrainableWeights;
35685    },
35686    enumerable: !0,
35687    configurable: !0
35688  }), Object.defineProperty(t.prototype, "updates", {
35689    get: function () {
35690      return this.layer._updates;
35691    },
35692    enumerable: !0,
35693    configurable: !0
35694  }), Object.defineProperty(t.prototype, "losses", {
35695    get: function () {
35696      return this.layer.losses;
35697    },
35698    enumerable: !0,
35699    configurable: !0
35700  }), t.prototype.getWeights = function () {
35701    return this.layer.getWeights();
35702  }, t.prototype.setWeights = function (e) {
35703    this.layer.setWeights(e);
35704  }, t.prototype.getConfig = function () {
35705    var t = {
35706      layer: {
35707        className: this.layer.getClassName(),
35708        config: this.layer.getConfig()
35709      }
35710    },
35711        n = e.prototype.getConfig.call(this);
35712    return Object.assign(t, n), t;
35713  }, t.prototype.setFastWeightInitDuringBuild = function (t) {
35714    e.prototype.setFastWeightInitDuringBuild.call(this, t), null != this.layer && this.layer.setFastWeightInitDuringBuild(t);
35715  }, t.fromConfig = function (e, t, n) {
35716    void 0 === n && (n = {});
35717    var r = deserialize(t.layer, n);
35718    delete t.layer;
35719    var i = {
35720      layer: r
35721    };
35722    return Object.assign(i, t), new e(i);
35723  }, t;
35724}(Layer),
35725    TimeDistributed = function (e) {
35726  function t(t) {
35727    var n = e.call(this, t) || this;
35728    return n.supportsMasking = !0, n;
35729  }
35730
35731  return __extends(t, e), t.prototype.build = function (t) {
35732    if ((t = getExactlyOneShape(t)).length < 3) throw new ValueError("TimeDistributed layer expects an input shape >= 3D, but received input shape " + JSON.stringify(t));
35733    this.inputSpec = [{
35734      shape: t
35735    }];
35736    var n = [t[0]].concat(t.slice(2));
35737    this.layer.built || (this.layer.build(n), this.layer.built = !0), e.prototype.build.call(this, t);
35738  }, t.prototype.computeOutputShape = function (e) {
35739    var t = [(e = getExactlyOneShape(e))[0]].concat(e.slice(2)),
35740        n = this.layer.computeOutputShape(t),
35741        r = e[1];
35742    return [n[0], r].concat(n.slice(1));
35743  }, t.prototype.call = function (e, t) {
35744    var n = this;
35745    return (0, _tfjsCore.tidy)(function () {
35746      return rnn(function (e, r) {
35747        return [getExactlyOneTensor(n.layer.call(e, t)), []];
35748      }, e = getExactlyOneTensor(e), [], !1, null, null, !1, !0)[1];
35749    });
35750  }, t.className = "TimeDistributed", t;
35751}(Wrapper);
35752
35753function checkBidirectionalMergeMode(e) {
35754  checkStringTypeUnionValue(VALID_BIDIRECTIONAL_MERGE_MODES, "BidirectionalMergeMode", e);
35755}
35756
35757_tfjsCore.serialization.registerClass(TimeDistributed);
35758
35759var DEFAULT_BIDIRECTIONAL_MERGE_MODE = "concat",
35760    Bidirectional = function (e) {
35761  function t(t) {
35762    var n = e.call(this, t) || this,
35763        r = t.layer.getConfig(),
35764        i = {};
35765    i.className = t.layer.getClassName(), i.config = r, n.forwardLayer = deserialize(i), r.goBackwards = !0 !== r.goBackwards;
35766    var a = {};
35767    if (a.className = t.layer.getClassName(), a.config = r, n.backwardLayer = deserialize(a), n.forwardLayer.name = "forward_" + n.forwardLayer.name, n.backwardLayer.name = "backward_" + n.backwardLayer.name, n.mergeMode = void 0 === t.mergeMode ? DEFAULT_BIDIRECTIONAL_MERGE_MODE : t.mergeMode, checkBidirectionalMergeMode(n.mergeMode), t.weights) throw new NotImplementedError("weights support is not implemented for Bidirectional layer yet.");
35768    return n._stateful = t.layer.stateful, n.returnSequences = t.layer.returnSequences, n.returnState = t.layer.returnState, n.supportsMasking = !0, n._trainable = !0, n.inputSpec = t.layer.inputSpec, n.numConstants = null, n;
35769  }
35770
35771  return __extends(t, e), Object.defineProperty(t.prototype, "trainable", {
35772    get: function () {
35773      return this._trainable;
35774    },
35775    set: function (e) {
35776      this._trainable = e, null != this.forwardLayer && (this.forwardLayer.trainable = e), null != this.backwardLayer && (this.backwardLayer.trainable = e);
35777    },
35778    enumerable: !0,
35779    configurable: !0
35780  }), t.prototype.getWeights = function () {
35781    return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights());
35782  }, t.prototype.setWeights = function (e) {
35783    var t = e.length,
35784        n = Math.floor(t / 2);
35785    this.forwardLayer.setWeights(e.slice(0, n)), this.backwardLayer.setWeights(e.slice(n));
35786  }, t.prototype.computeOutputShape = function (e) {
35787    var t,
35788        n,
35789        r,
35790        i = this.forwardLayer.computeOutputShape(e);
35791    return Array.isArray(i) && Array.isArray(i[0]) || (i = [i]), i = i, this.returnState ? (r = i.slice(1), t = i[0]) : t = i[0], t = t, "concat" === this.mergeMode ? (t[t.length - 1] *= 2, n = [t]) : n = null == this.mergeMode ? [t, t.slice()] : [t], this.returnState ? null == this.mergeMode ? n.concat(r).concat(r.slice()) : [t].concat(r).concat(r.slice()) : singletonOrArray(n);
35792  }, t.prototype.apply = function (t, n) {
35793    var r = null == n ? null : n.initialState,
35794        i = null == n ? null : n.constants;
35795    null == n && (n = {});
35796    var a = standardizeArgs(t, r, i, this.numConstants);
35797    if (t = a.inputs, r = a.initialState, i = a.constants, Array.isArray(t) && (r = t.slice(1), t = t[0]), (null == r || 0 === r.length) && null == i) return e.prototype.apply.call(this, t, n);
35798    var o = [],
35799        s = [];
35800
35801    if (null != r) {
35802      var l = r.length;
35803      if (l % 2 > 0) throw new ValueError("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs.");
35804      n.initialState = r, o.push.apply(o, r);
35805      var u = r.map(function (e) {
35806        return new InputSpec({
35807          shape: e.shape
35808        });
35809      });
35810      this.forwardLayer.stateSpec = u.slice(0, l / 2), this.backwardLayer.stateSpec = u.slice(l / 2), s.push.apply(s, u);
35811    }
35812
35813    if (null != i) throw new NotImplementedError("Support for constants in Bidirectional layers is not implemented yet.");
35814
35815    for (var c = o[0] instanceof SymbolicTensor, p = 0, h = o; p < h.length; p++) {
35816      if (h[p] instanceof SymbolicTensor !== c) throw new ValueError("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors");
35817    }
35818
35819    if (c) {
35820      var d = [t].concat(o),
35821          f = this.inputSpec.concat(s),
35822          g = this.inputSpec;
35823      this.inputSpec = f;
35824      var m = e.prototype.apply.call(this, d, n);
35825      return this.inputSpec = g, m;
35826    }
35827
35828    return e.prototype.apply.call(this, t, n);
35829  }, t.prototype.call = function (e, t) {
35830    var n = this;
35831    return (0, _tfjsCore.tidy)(function () {
35832      var r,
35833          i,
35834          a,
35835          o,
35836          s = t.initialState;
35837      if (null == s) r = n.forwardLayer.call(e, t), i = n.backwardLayer.call(e, t);else {
35838        var l = s.slice(0, s.length / 2),
35839            u = s.slice(s.length / 2);
35840        r = n.forwardLayer.call(e, Object.assign(t, {
35841          initialState: l
35842        })), i = n.backwardLayer.call(e, Object.assign(t, {
35843          initialState: u
35844        }));
35845      }
35846      return n.returnState && (Array.isArray(r) && (a = r.slice(1).concat(i.slice(1))), r = r[0], i = i[0]), n.returnSequences && (i = (0, _tfjsCore.reverse)(i, 1)), "concat" === n.mergeMode ? o = concatenate([r, i]) : "sum" === n.mergeMode ? o = (0, _tfjsCore.add)(r, i) : "ave" === n.mergeMode ? o = (0, _tfjsCore.mul)(.5, (0, _tfjsCore.add)(r, i)) : "mul" === n.mergeMode ? o = (0, _tfjsCore.mul)(r, i) : null == n.mergeMode && (o = [r, i]), n.returnState ? null == n.mergeMode ? o.concat(a) : [o].concat(a) : o;
35847    });
35848  }, t.prototype.resetStates = function (e) {
35849    this.forwardLayer.resetStates(), this.backwardLayer.resetStates();
35850  }, t.prototype.build = function (e) {
35851    var t = this;
35852    nameScope(this.forwardLayer.name, function () {
35853      t.forwardLayer.build(e);
35854    }), nameScope(this.backwardLayer.name, function () {
35855      t.backwardLayer.build(e);
35856    }), this.built = !0;
35857  }, t.prototype.computeMask = function (e, t) {
35858    var n;
35859
35860    if (Array.isArray(t) && (t = t[0]), n = this.returnSequences ? null == this.mergeMode ? [t, t] : t : null == this.mergeMode ? [null, null] : null, this.returnState) {
35861      var r = this.forwardLayer.states.map(function (e) {
35862        return null;
35863      });
35864      return Array.isArray(n) ? n.concat(r).concat(r) : [n].concat(r).concat(r);
35865    }
35866
35867    return n;
35868  }, Object.defineProperty(t.prototype, "trainableWeights", {
35869    get: function () {
35870      return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights);
35871    },
35872    enumerable: !0,
35873    configurable: !0
35874  }), Object.defineProperty(t.prototype, "nonTrainableWeights", {
35875    get: function () {
35876      return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights);
35877    },
35878    enumerable: !0,
35879    configurable: !0
35880  }), t.prototype.setFastWeightInitDuringBuild = function (t) {
35881    e.prototype.setFastWeightInitDuringBuild.call(this, t), null != this.forwardLayer && this.forwardLayer.setFastWeightInitDuringBuild(t), null != this.backwardLayer && this.backwardLayer.setFastWeightInitDuringBuild(t);
35882  }, t.prototype.getConfig = function () {
35883    var t = {
35884      mergeMode: this.mergeMode
35885    },
35886        n = e.prototype.getConfig.call(this);
35887    return Object.assign(t, n), t;
35888  }, t.fromConfig = function (e, t) {
35889    var n = deserialize(t.layer);
35890    if (delete t.layer, null != t.numConstants) throw new NotImplementedError("Deserialization of a Bidirectional layer with numConstants present is not supported yet.");
35891    var r = t;
35892    return r.layer = n, new e(r);
35893  }, t.className = "Bidirectional", t;
35894}(Wrapper);
35895
35896function inputLayer(e) {
35897  return new InputLayer(e);
35898}
35899
35900function elu$2(e) {
35901  return new ELU(e);
35902}
35903
35904function reLU(e) {
35905  return new ReLU(e);
35906}
35907
35908function leakyReLU(e) {
35909  return new LeakyReLU(e);
35910}
35911
35912function prelu$1(e) {
35913  return new PReLU(e);
35914}
35915
35916function softmax$1(e) {
35917  return new Softmax$1(e);
35918}
35919
35920function thresholdedReLU(e) {
35921  return new ThresholdedReLU(e);
35922}
35923
35924function conv1d$2(e) {
35925  return new Conv1D(e);
35926}
35927
35928function conv2d$1(e) {
35929  return new Conv2D(e);
35930}
35931
35932function conv2dTranspose$1(e) {
35933  return new Conv2DTranspose(e);
35934}
35935
35936function conv3d$2(e) {
35937  return new Conv3D(e);
35938}
35939
35940function separableConv2d$1(e) {
35941  return new SeparableConv2D(e);
35942}
35943
35944function cropping2D(e) {
35945  return new Cropping2D(e);
35946}
35947
35948function upSampling2d(e) {
35949  return new UpSampling2D(e);
35950}
35951
35952function depthwiseConv2d$2(e) {
35953  return new DepthwiseConv2D(e);
35954}
35955
35956function activation(e) {
35957  return new Activation$1(e);
35958}
35959
35960function dense(e) {
35961  return new Dense(e);
35962}
35963
35964function dropout$2(e) {
35965  return new Dropout(e);
35966}
35967
35968function spatialDropout1d(e) {
35969  return new SpatialDropout1D(e);
35970}
35971
35972function flatten$1(e) {
35973  return new Flatten(e);
35974}
35975
35976function repeatVector(e) {
35977  return new RepeatVector(e);
35978}
35979
35980function reshape(e) {
35981  return new Reshape(e);
35982}
35983
35984function permute(e) {
35985  return new Permute(e);
35986}
35987
35988function embedding(e) {
35989  return new Embedding(e);
35990}
35991
35992function add$2(e) {
35993  return new Add(e);
35994}
35995
35996function average$1(e) {
35997  return new Average(e);
35998}
35999
36000function concatenate$2(e) {
36001  return new Concatenate(e);
36002}
36003
36004function maximum$2(e) {
36005  return new Maximum(e);
36006}
36007
36008function minimum$2(e) {
36009  return new Minimum(e);
36010}
36011
36012function multiply$1(e) {
36013  return new Multiply(e);
36014}
36015
36016function dot$1(e) {
36017  return new Dot(e);
36018}
36019
36020function batchNormalization$1(e) {
36021  return new BatchNormalization(e);
36022}
36023
36024function layerNormalization(e) {
36025  return new LayerNormalization(e);
36026}
36027
36028function zeroPadding2d(e) {
36029  return new ZeroPadding2D(e);
36030}
36031
36032function averagePooling1d(e) {
36033  return new AveragePooling1D(e);
36034}
36035
36036function avgPool1d(e) {
36037  return averagePooling1d(e);
36038}
36039
36040function avgPooling1d(e) {
36041  return averagePooling1d(e);
36042}
36043
36044function averagePooling2d(e) {
36045  return new AveragePooling2D(e);
36046}
36047
36048function avgPool2d(e) {
36049  return averagePooling2d(e);
36050}
36051
36052function avgPooling2d(e) {
36053  return averagePooling2d(e);
36054}
36055
36056function averagePooling3d(e) {
36057  return new AveragePooling3D(e);
36058}
36059
36060function avgPool3d$1(e) {
36061  return averagePooling3d(e);
36062}
36063
36064function avgPooling3d(e) {
36065  return averagePooling3d(e);
36066}
36067
36068function globalAveragePooling1d(e) {
36069  return new GlobalAveragePooling1D(e);
36070}
36071
36072function globalAveragePooling2d(e) {
36073  return new GlobalAveragePooling2D(e);
36074}
36075
36076function globalMaxPooling1d(e) {
36077  return new GlobalMaxPooling1D(e);
36078}
36079
36080function globalMaxPooling2d(e) {
36081  return new GlobalMaxPooling2D(e);
36082}
36083
36084function maxPooling1d(e) {
36085  return new MaxPooling1D(e);
36086}
36087
36088function maxPooling2d(e) {
36089  return new MaxPooling2D(e);
36090}
36091
36092function maxPooling3d(e) {
36093  return new MaxPooling3D(e);
36094}
36095
36096function gru(e) {
36097  return new GRU(e);
36098}
36099
36100function gruCell(e) {
36101  return new GRUCell(e);
36102}
36103
36104function lstm(e) {
36105  return new LSTM(e);
36106}
36107
36108function lstmCell(e) {
36109  return new LSTMCell(e);
36110}
36111
36112function simpleRNN(e) {
36113  return new SimpleRNN(e);
36114}
36115
36116function simpleRNNCell(e) {
36117  return new SimpleRNNCell(e);
36118}
36119
36120function rnn$1(e) {
36121  return new RNN(e);
36122}
36123
36124function stackedRNNCells(e) {
36125  return new StackedRNNCells(e);
36126}
36127
36128function bidirectional(e) {
36129  return new Bidirectional(e);
36130}
36131
36132function timeDistributed(e) {
36133  return new TimeDistributed(e);
36134}
36135
36136_tfjsCore.serialization.registerClass(Bidirectional);
36137
36138var globalMaxPool1d = globalMaxPooling1d,
36139    globalMaxPool2d = globalMaxPooling2d,
36140    maxPool1d = maxPooling1d,
36141    maxPool2d = maxPooling2d;
36142
36143function gaussianNoise(e) {
36144  return new GaussianNoise(e);
36145}
36146
36147function gaussianDropout(e) {
36148  return new GaussianDropout(e);
36149}
36150
36151function alphaDropout(e) {
36152  return new AlphaDropout(e);
36153}
36154
36155function masking(e) {
36156  return new Masking(e);
36157}
36158
36159var exports_layers = Object.freeze({
36160  inputLayer: inputLayer,
36161  elu: elu$2,
36162  reLU: reLU,
36163  leakyReLU: leakyReLU,
36164  prelu: prelu$1,
36165  softmax: softmax$1,
36166  thresholdedReLU: thresholdedReLU,
36167  conv1d: conv1d$2,
36168  conv2d: conv2d$1,
36169  conv2dTranspose: conv2dTranspose$1,
36170  conv3d: conv3d$2,
36171  separableConv2d: separableConv2d$1,
36172  cropping2D: cropping2D,
36173  upSampling2d: upSampling2d,
36174  depthwiseConv2d: depthwiseConv2d$2,
36175  activation: activation,
36176  dense: dense,
36177  dropout: dropout$2,
36178  spatialDropout1d: spatialDropout1d,
36179  flatten: flatten$1,
36180  repeatVector: repeatVector,
36181  reshape: reshape,
36182  permute: permute,
36183  embedding: embedding,
36184  add: add$2,
36185  average: average$1,
36186  concatenate: concatenate$2,
36187  maximum: maximum$2,
36188  minimum: minimum$2,
36189  multiply: multiply$1,
36190  dot: dot$1,
36191  batchNormalization: batchNormalization$1,
36192  layerNormalization: layerNormalization,
36193  zeroPadding2d: zeroPadding2d,
36194  averagePooling1d: averagePooling1d,
36195  avgPool1d: avgPool1d,
36196  avgPooling1d: avgPooling1d,
36197  averagePooling2d: averagePooling2d,
36198  avgPool2d: avgPool2d,
36199  avgPooling2d: avgPooling2d,
36200  averagePooling3d: averagePooling3d,
36201  avgPool3d: avgPool3d$1,
36202  avgPooling3d: avgPooling3d,
36203  globalAveragePooling1d: globalAveragePooling1d,
36204  globalAveragePooling2d: globalAveragePooling2d,
36205  globalMaxPooling1d: globalMaxPooling1d,
36206  globalMaxPooling2d: globalMaxPooling2d,
36207  maxPooling1d: maxPooling1d,
36208  maxPooling2d: maxPooling2d,
36209  maxPooling3d: maxPooling3d,
36210  gru: gru,
36211  gruCell: gruCell,
36212  lstm: lstm,
36213  lstmCell: lstmCell,
36214  simpleRNN: simpleRNN,
36215  simpleRNNCell: simpleRNNCell,
36216  rnn: rnn$1,
36217  stackedRNNCells: stackedRNNCells,
36218  bidirectional: bidirectional,
36219  timeDistributed: timeDistributed,
36220  globalMaxPool1d: globalMaxPool1d,
36221  globalMaxPool2d: globalMaxPool2d,
36222  maxPool1d: maxPool1d,
36223  maxPool2d: maxPool2d,
36224  Layer: Layer,
36225  RNN: RNN,
36226  RNNCell: RNNCell,
36227  input: input,
36228  gaussianNoise: gaussianNoise,
36229  gaussianDropout: gaussianDropout,
36230  alphaDropout: alphaDropout,
36231  masking: masking
36232});
36233exports.layers = exports_layers;
36234
36235function binaryAccuracy$1(e, t) {
36236  return binaryAccuracy(e, t);
36237}
36238
36239function binaryCrossentropy$2(e, t) {
36240  return binaryCrossentropy$1(e, t);
36241}
36242
36243function sparseCategoricalAccuracy$1(e, t) {
36244  return sparseCategoricalAccuracy(e, t);
36245}
36246
36247function categoricalAccuracy$1(e, t) {
36248  return categoricalAccuracy(e, t);
36249}
36250
36251function categoricalCrossentropy$2(e, t) {
36252  return categoricalCrossentropy$1(e, t);
36253}
36254
36255function precision$1(e, t) {
36256  return precision(e, t);
36257}
36258
36259function recall$1(e, t) {
36260  return recall(e, t);
36261}
36262
36263function cosineProximity$1(e, t) {
36264  return cosineProximity(e, t);
36265}
36266
36267function meanAbsoluteError$1(e, t) {
36268  return meanAbsoluteError(e, t);
36269}
36270
36271function meanAbsolutePercentageError$1(e, t) {
36272  return meanAbsolutePercentageError(e, t);
36273}
36274
36275function MAPE$2(e, t) {
36276  return meanAbsolutePercentageError(e, t);
36277}
36278
36279function mape$2(e, t) {
36280  return meanAbsolutePercentageError(e, t);
36281}
36282
36283function meanSquaredError$1(e, t) {
36284  return meanSquaredError(e, t);
36285}
36286
36287function MSE$2(e, t) {
36288  return meanSquaredError(e, t);
36289}
36290
36291function mse$2(e, t) {
36292  return meanSquaredError(e, t);
36293}
36294
36295var exports_metrics = Object.freeze({
36296  binaryAccuracy: binaryAccuracy$1,
36297  binaryCrossentropy: binaryCrossentropy$2,
36298  sparseCategoricalAccuracy: sparseCategoricalAccuracy$1,
36299  categoricalAccuracy: categoricalAccuracy$1,
36300  categoricalCrossentropy: categoricalCrossentropy$2,
36301  precision: precision$1,
36302  recall: recall$1,
36303  cosineProximity: cosineProximity$1,
36304  meanAbsoluteError: meanAbsoluteError$1,
36305  meanAbsolutePercentageError: meanAbsolutePercentageError$1,
36306  MAPE: MAPE$2,
36307  mape: mape$2,
36308  meanSquaredError: meanSquaredError$1,
36309  MSE: MSE$2,
36310  mse: mse$2
36311}),
36312    exports_models = Object.freeze({
36313  modelFromJSON: modelFromJSON
36314});
36315exports.models = exports_models;
36316exports.metrics = exports_metrics;
36317
36318function l1l2(e) {
36319  return new L1L2(e);
36320}
36321
36322function l1$1(e) {
36323  return l1(e);
36324}
36325
36326function l2$1(e) {
36327  return l2(e);
36328}
36329
36330var exports_regularizers = Object.freeze({
36331  l1l2: l1l2,
36332  l1: l1$1,
36333  l2: l2$1
36334}),
36335    Callback = function (e) {
36336  function t() {
36337    var t = null !== e && e.apply(this, arguments) || this;
36338    return t.model = null, t;
36339  }
36340
36341  return __extends(t, e), t.prototype.setModel = function (e) {
36342    if (!(e instanceof LayersModel)) throw new Error("model must be a LayersModel, not some other Container");
36343    this.model = e;
36344  }, t;
36345}(BaseCallback);
36346
36347exports.Callback = Callback;
36348exports.regularizers = exports_regularizers;
36349
36350function less(e, t) {
36351  return e < t;
36352}
36353
36354function greater$1(e, t) {
36355  return e > t;
36356}
36357
36358var EarlyStopping = function (e) {
36359  function t(t) {
36360    var n = e.call(this) || this;
36361    if (null == t && (t = {}), t.restoreBestWeights) throw new NotImplementedError("restoreBestWeights = True is not implemented in EarlyStopping yet.");
36362    return n.monitor = t.monitor || "val_loss", n.minDelta = Math.abs(t.minDelta || 0), n.patience = t.patience || 0, n.verbose = t.verbose || 0, n.mode = t.mode || "auto", n.baseline = t.baseline, -1 === ["auto", "min", "max"].indexOf(n.mode) && (console.warn("EarlyStopping mode '" + n.mode + "' is invalid. Falling back to mode 'auto'."), n.mode = "auto"), "min" === n.mode ? n.monitorFunc = less : "max" === n.mode ? n.monitorFunc = greater$1 : -1 !== n.monitor.indexOf("acc") ? n.monitorFunc = greater$1 : n.monitorFunc = less, n.monitorFunc === less && (n.minDelta *= -1), n;
36363  }
36364
36365  return __extends(t, e), t.prototype.onTrainBegin = function (e) {
36366    return __awaiter(this, void 0, void 0, function () {
36367      return __generator(this, function (e) {
36368        return this.wait = 0, this.stoppedEpoch = 0, null != this.baseline ? this.best = this.baseline : this.best = this.monitorFunc === less ? 1 / 0 : -1 / 0, [2];
36369      });
36370    });
36371  }, t.prototype.onEpochEnd = function (e, t) {
36372    return __awaiter(this, void 0, void 0, function () {
36373      var n;
36374      return __generator(this, function (r) {
36375        switch (r.label) {
36376          case 0:
36377            return [4, resolveScalarsInLogs(t)];
36378
36379          case 1:
36380            return r.sent(), null == (n = this.getMonitorValue(t)) ? [2] : (this.monitorFunc(n - this.minDelta, this.best) ? (this.best = n, this.wait = 0) : (this.wait++, this.wait >= this.patience && (this.stoppedEpoch = e, this.model.stopTraining = !0)), [2]);
36381        }
36382      });
36383    });
36384  }, t.prototype.onTrainEnd = function (e) {
36385    return __awaiter(this, void 0, void 0, function () {
36386      return __generator(this, function (e) {
36387        return this.stoppedEpoch > 0 && this.verbose && console.log("Epoch " + this.stoppedEpoch + ": early stopping."), [2];
36388      });
36389    });
36390  }, t.prototype.getMonitorValue = function (e) {
36391    null == e && (e = {});
36392    var t = e[this.monitor];
36393    return null == t && console.warn("Metric for EarlyStopping " + this.monitor + " is not available. Available metrics are: " + Object.keys(e)), t;
36394  }, t;
36395}(Callback);
36396
36397exports.EarlyStopping = EarlyStopping;
36398
36399function earlyStopping(e) {
36400  return new EarlyStopping(e);
36401}
36402
36403var callbacks = {
36404  earlyStopping: earlyStopping
36405};
36406exports.callbacks = callbacks;
36407},{"@tensorflow/tfjs-core":"node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js"}],"node_modules/@tensorflow/tfjs-data/dist/tf-data.esm.js":[function(require,module,exports) {
36408var global = arguments[3];
36409var Buffer = require("buffer").Buffer;
36410"use strict";
36411
36412Object.defineProperty(exports, "__esModule", {
36413  value: true
36414});
36415exports.array = array;
36416exports.zip = zip;
36417exports.csv = csv;
36418exports.func = func;
36419exports.generator = generator;
36420exports.microphone = microphone;
36421exports.webcam = webcam;
36422exports.version_data = exports.URLDataSource = exports.FileDataSource = exports.TextLineDataset = exports.CSVDataset = exports.Dataset = void 0;
36423
36424var _tfjsCore = require("@tensorflow/tfjs-core");
36425
36426/**
36427 * @license
36428 * Copyright 2020 Google LLC. All Rights Reserved.
36429 * Licensed under the Apache License, Version 2.0 (the "License");
36430 * you may not use this file except in compliance with the License.
36431 * You may obtain a copy of the License at
36432 *
36433 * http://www.apache.org/licenses/LICENSE-2.0
36434 *
36435 * Unless required by applicable law or agreed to in writing, software
36436 * distributed under the License is distributed on an "AS IS" BASIS,
36437 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36438 * See the License for the specific language governing permissions and
36439 * limitations under the License.
36440 * =============================================================================
36441 */
36442var extendStatics = function (t, e) {
36443  return (extendStatics = Object.setPrototypeOf || {
36444    __proto__: []
36445  } instanceof Array && function (t, e) {
36446    t.__proto__ = e;
36447  } || function (t, e) {
36448    for (var r in e) e.hasOwnProperty(r) && (t[r] = e[r]);
36449  })(t, e);
36450};
36451
36452function __extends(t, e) {
36453  function r() {
36454    this.constructor = t;
36455  }
36456
36457  extendStatics(t, e), t.prototype = null === e ? Object.create(e) : (r.prototype = e.prototype, new r());
36458}
36459
36460function __awaiter(t, e, r, n) {
36461  return new (r || (r = Promise))(function (i, o) {
36462    function a(t) {
36463      try {
36464        u(n.next(t));
36465      } catch (t) {
36466        o(t);
36467      }
36468    }
36469
36470    function s(t) {
36471      try {
36472        u(n.throw(t));
36473      } catch (t) {
36474        o(t);
36475      }
36476    }
36477
36478    function u(t) {
36479      t.done ? i(t.value) : new r(function (e) {
36480        e(t.value);
36481      }).then(a, s);
36482    }
36483
36484    u((n = n.apply(t, e || [])).next());
36485  });
36486}
36487
36488function __generator(t, e) {
36489  var r,
36490      n,
36491      i,
36492      o,
36493      a = {
36494    label: 0,
36495    sent: function () {
36496      if (1 & i[0]) throw i[1];
36497      return i[1];
36498    },
36499    trys: [],
36500    ops: []
36501  };
36502  return o = {
36503    next: s(0),
36504    throw: s(1),
36505    return: s(2)
36506  }, "function" == typeof Symbol && (o[Symbol.iterator] = function () {
36507    return this;
36508  }), o;
36509
36510  function s(o) {
36511    return function (s) {
36512      return function (o) {
36513        if (r) throw new TypeError("Generator is already executing.");
36514
36515        for (; a;) try {
36516          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;
36517
36518          switch (n = 0, i && (o = [2 & o[0], i.value]), o[0]) {
36519            case 0:
36520            case 1:
36521              i = o;
36522              break;
36523
36524            case 4:
36525              return a.label++, {
36526                value: o[1],
36527                done: !1
36528              };
36529
36530            case 5:
36531              a.label++, n = o[1], o = [0];
36532              continue;
36533
36534            case 7:
36535              o = a.ops.pop(), a.trys.pop();
36536              continue;
36537
36538            default:
36539              if (!(i = (i = a.trys).length > 0 && i[i.length - 1]) && (6 === o[0] || 2 === o[0])) {
36540                a = 0;
36541                continue;
36542              }
36543
36544              if (3 === o[0] && (!i || o[1] > i[0] && o[1] < i[3])) {
36545                a.label = o[1];
36546                break;
36547              }
36548
36549              if (6 === o[0] && a.label < i[1]) {
36550                a.label = i[1], i = o;
36551                break;
36552              }
36553
36554              if (i && a.label < i[2]) {
36555                a.label = i[2], a.ops.push(o);
36556                break;
36557              }
36558
36559              i[2] && a.ops.pop(), a.trys.pop();
36560              continue;
36561          }
36562
36563          o = e.call(t, a);
36564        } catch (t) {
36565          o = [6, t], n = 0;
36566        } finally {
36567          r = i = 0;
36568        }
36569
36570        if (5 & o[0]) throw o[1];
36571        return {
36572          value: o[0] ? o[1] : void 0,
36573          done: !0
36574        };
36575      }([o, s]);
36576    };
36577  }
36578}
36579
36580var commonjsGlobal = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {};
36581
36582function createCommonjsModule(t, e) {
36583  return t(e = {
36584    exports: {}
36585  }, e.exports), e.exports;
36586}
36587
36588var alea = createCommonjsModule(function (t) {
36589  !function (t, e, r) {
36590    function n(t, e) {
36591      return e.c = t.c, e.s0 = t.s0, e.s1 = t.s1, e.s2 = t.s2, e;
36592    }
36593
36594    function i(t, e) {
36595      var r = new function (t) {
36596        var e,
36597            r = this,
36598            n = (e = 4022871197, function (t) {
36599          t = t.toString();
36600
36601          for (var r = 0; r < t.length; r++) {
36602            var n = .02519603282416938 * (e += t.charCodeAt(r));
36603            n -= e = n >>> 0, e = (n *= e) >>> 0, e += 4294967296 * (n -= e);
36604          }
36605
36606          return 2.3283064365386963e-10 * (e >>> 0);
36607        });
36608        r.next = function () {
36609          var t = 2091639 * r.s0 + 2.3283064365386963e-10 * r.c;
36610          return r.s0 = r.s1, r.s1 = r.s2, r.s2 = t - (r.c = 0 | t);
36611        }, 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;
36612      }(t),
36613          i = e && e.state,
36614          o = r.next;
36615      return o.int32 = function () {
36616        return 4294967296 * r.next() | 0;
36617      }, o.double = function () {
36618        return o() + 1.1102230246251565e-16 * (2097152 * o() | 0);
36619      }, o.quick = o, i && ("object" == typeof i && n(i, r), o.state = function () {
36620        return n(r, {});
36621      }), o;
36622    }
36623
36624    e && e.exports ? e.exports = i : r && r.amd ? r(function () {
36625      return i;
36626    }) : this.alea = i;
36627  }(0, t, !1);
36628}),
36629    xor128 = createCommonjsModule(function (t) {
36630  !function (t, e, r) {
36631    function n(t, e) {
36632      return e.x = t.x, e.y = t.y, e.z = t.z, e.w = t.w, e;
36633    }
36634
36635    function i(t, e) {
36636      var r = new function (t) {
36637        var e = this,
36638            r = "";
36639        e.x = 0, e.y = 0, e.z = 0, e.w = 0, e.next = function () {
36640          var t = e.x ^ e.x << 11;
36641          return e.x = e.y, e.y = e.z, e.z = e.w, e.w ^= e.w >>> 19 ^ t ^ t >>> 8;
36642        }, t === (0 | t) ? e.x = t : r += t;
36643
36644        for (var n = 0; n < r.length + 64; n++) e.x ^= 0 | r.charCodeAt(n), e.next();
36645      }(t),
36646          i = e && e.state,
36647          o = function () {
36648        return (r.next() >>> 0) / 4294967296;
36649      };
36650
36651      return o.double = function () {
36652        do {
36653          var t = ((r.next() >>> 11) + (r.next() >>> 0) / 4294967296) / (1 << 21);
36654        } while (0 === t);
36655
36656        return t;
36657      }, o.int32 = r.next, o.quick = o, i && ("object" == typeof i && n(i, r), o.state = function () {
36658        return n(r, {});
36659      }), o;
36660    }
36661
36662    e && e.exports ? e.exports = i : r && r.amd ? r(function () {
36663      return i;
36664    }) : this.xor128 = i;
36665  }(0, t, !1);
36666}),
36667    xorwow = createCommonjsModule(function (t) {
36668  !function (t, e, r) {
36669    function n(t, e) {
36670      return e.x = t.x, e.y = t.y, e.z = t.z, e.w = t.w, e.v = t.v, e.d 
36670= t.d, e;
36671    }
36672
36673    function i(t, e) {
36674      var r = new function (t) {
36675        var e = this,
36676            r = "";
36677        e.next = function () {
36678          var t = e.x ^ e.x >>> 2;
36679          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;
36680        }, e.x = 0, e.y = 0, e.z = 0, e.w = 0, e.v = 0, t === (0 | t) ? e.x = t : r += t;
36681
36682        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();
36683      }(t),
36684          i = e && e.state,
36685          o = function () {
36686        return (r.next() >>> 0) / 4294967296;
36687      };
36688
36689      return o.double = function () {
36690        do {
36691          var t = ((r.next() >>> 11) + (r.next() >>> 0) / 4294967296) / (1 << 21);
36692        } while (0 === t);
36693
36694        return t;
36695      }, o.int32 = r.next, o.quick = o, i && ("object" == typeof i && n(i, r), o.state = function () {
36696        return n(r, {});
36697      }), o;
36698    }
36699
36700    e && e.exports ? e.exports = i : r && r.amd ? r(function () {
36701      return i;
36702    }) : this.xorwow = i;
36703  }(0, t, !1);
36704}),
36705    xorshift7 = createCommonjsModule(function (t) {
36706  !function (t, e, r) {
36707    function n(t, e) {
36708      return e.x = t.x.slice(), e.i = t.i, e;
36709    }
36710
36711    function i(t, e) {
36712      null == t && (t = +new Date());
36713
36714      var r = new function (t) {
36715        var e = this;
36716        e.next = function () {
36717          var t,
36718              r,
36719              n = e.x,
36720              i = e.i;
36721          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;
36722        }, function (t, e) {
36723          var r,
36724              n = [];
36725          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;
36726
36727          for (; n.length < 8;) n.push(0);
36728
36729          for (r = 0; r < 8 && 0 === n[r]; ++r);
36730
36731          for (8 == r ? n[7] = -1 : n[r], t.x = n, t.i = 0, r = 256; r > 0; --r) t.next();
36732        }(e, t);
36733      }(t),
36734          i = e && e.state,
36735          o = function () {
36736        return (r.next() >>> 0) / 4294967296;
36737      };
36738
36739      return o.double = function () {
36740        do {
36741          var t = ((r.next() >>> 11) + (r.next() >>> 0) / 4294967296) / (1 << 21);
36742        } while (0 === t);
36743
36744        return t;
36745      }, o.int32 = r.next, o.quick = o, i && (i.x && n(i, r), o.state = function () {
36746        return n(r, {});
36747      }), o;
36748    }
36749
36750    e && e.exports ? e.exports = i : r && r.amd ? r(function () {
36751      return i;
36752    }) : this.xorshift7 = i;
36753  }(0, t, !1);
36754}),
36755    xor4096 = createCommonjsModule(function (t) {
36756  !function (t, e, r) {
36757    function n(t, e) {
36758      return e.i = t.i, e.w = t.w, e.X = t.X.slice(), e;
36759    }
36760
36761    function i(t, e) {
36762      null == t && (t = +new Date());
36763
36764      var r = new function (t) {
36765        var e = this;
36766        e.next = function () {
36767          var t,
36768              r,
36769              n = e.w,
36770              i = e.X,
36771              o = e.i;
36772          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;
36773        }, function (t, e) {
36774          var r,
36775              n,
36776              i,
36777              o,
36778              a,
36779              s = [],
36780              u = 128;
36781
36782          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);
36783
36784          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;
36785
36786          t.w = a, t.X = s, t.i = i;
36787        }(e, t);
36788      }(t),
36789          i = e && e.state,
36790          o = function () {
36791        return (r.next() >>> 0) / 4294967296;
36792      };
36793
36794      return o.double = function () {
36795        do {
36796          var t = ((r.next() >>> 11) + (r.next() >>> 0) / 4294967296) / (1 << 21);
36797        } while (0 === t);
36798
36799        return t;
36800      }, o.int32 = r.next, o.quick = o, i && (i.X && n(i, r), o.state = function () {
36801        return n(r, {});
36802      }), o;
36803    }
36804
36805    e && e.exports ? e.exports = i : r && r.amd ? r(function () {
36806      return i;
36807    }) : this.xor4096 = i;
36808  }(0, t, !1);
36809}),
36810    tychei = createCommonjsModule(function (t) {
36811  !function (t, e, r) {
36812    function n(t, e) {
36813      return e.a = t.a, e.b = t.b, e.c = t.c, e.d = t.d, e;
36814    }
36815
36816    function i(t, e) {
36817      var r = new function (t) {
36818        var e = this,
36819            r = "";
36820        e.next = function () {
36821          var t = e.b,
36822              r = e.c,
36823              n = e.d,
36824              i = e.a;
36825          return t = t << 25 ^ t >>> 7 ^ r, r = r - n | 0, n = n << 24 ^ n >>>
36825 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;
36826        }, 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;
36827
36828        for (var n = 0; n < r.length + 20; n++) e.b ^= 0 | r.charCodeAt(n), e.next();
36829      }(t),
36830          i = e && e.state,
36831          o = function () {
36832        return (r.next() >>> 0) / 4294967296;
36833      };
36834
36835      return o.double = function () {
36836        do {
36837          var t = ((r.next() >>> 11) + (r.next() >>> 0) / 4294967296) / (1 << 21);
36838        } while (0 === t);
36839
36840        return t;
36841      }, o.int32 = r.next, o.quick = o, i && ("object" == typeof i && n(i, r), o.state = function () {
36842        return n(r, {});
36843      }), o;
36844    }
36845
36846    e && e.exports ? e.exports = i : r && r.amd ? r(function () {
36847      return i;
36848    }) : this.tychei = i;
36849  }(0, t, !1);
36850}),
36851    seedrandom = createCommonjsModule(function (t) {
36852  !function (e, r) {
36853    var n,
36854        i = this,
36855        o = 256,
36856        a = 6,
36857        s = "random",
36858        u = r.pow(o, a),
36859        c = r.pow(2, 52),
36860        l = 2 * c,
36861        h = o - 1;
36862
36863    function f(t, f, v) {
36864      var _ = [],
36865          w = p(function t(e, r) {
36866        var n,
36867            i = [],
36868            o = typeof e;
36869        if (r && "object" == o) for (n in e) try {
36870          i.push(t(e[n], r - 1));
36871        } catch (t) {}
36872        return i.length ? i : "string" == o ? e : e + "\0";
36873      }((f = 1 == f ? {
36874        entropy: !0
36875      } : f || {}).entropy ? [t, m(e)] : null == t ? function () {
36876        try {
36877          var t;
36878          return n && (t = n.randomBytes) ? t = t(o) : (t = new Uint8Array(o), (i.crypto || i.msCrypto).getRandomValues(t)), m(t);
36879        } catch (t) {
36880          var r = i.navigator,
36881              a = r && r.plugins;
36882          return [+new Date(), i, a, i.screen, m(e)];
36883        }
36884      }() : t, 3), _),
36885          y = new function (t) {
36886        var e,
36887            r = t.length,
36888            n = this,
36889            i = 0,
36890            a = n.i = n.j = 0,
36891            s = n.S = [];
36892        r || (t = [r++]);
36893
36894        for (; i < o;) s[i] = i++;
36895
36896        for (i = 0; i < o; i++) s[i] = s[a = h & a + t[i % r] + (e = s[i])], s[a] = e;
36897
36898        (n.g = function (t) {
36899          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)];
36900
36901          return n.i = i, n.j = a, r;
36902        })(o);
36903      }(_),
36904          g = function () {
36905        for (var t = y.g(a), e = u, r = 0; t < c;) t = (t + r) * o, e *= o, r = y.g(1);
36906
36907        for (; t >= l;) t /= 2, e /= 2, r >>>= 1;
36908
36909        return (t + r) / e;
36910      };
36911
36912      return g.int32 = function () {
36913        return 0 | y.g(4);
36914      }, g.quick = function () {
36915        return y.g(4) / 4294967296;
36916      }, g.double = g, p(m(y.S), e), (f.pass || v || function (t, e, n, i) {
36917        return i && (i.S && d(i, y), t.state = function () {
36918          return d(y, {});
36919        }), n ? (r[s] = t, e) : t;
36920      })(g, w, "global" in f ? f.global : this == r, f.state);
36921    }
36922
36923    function d(t, e) {
36924      return e.i = t.i, e.j = t.j, e.S = t.S.slice(), e;
36925    }
36926
36927    function p(t, e) {
36928      for (var r, n = t + "", i = 0; i < n.length;) e[h & i] = h & (r ^= 19 * e[h & i]) + n.charCodeAt(i++);
36929
36930      return m(e);
36931    }
36932
36933    function m(t) {
36934      return String.fromCharCode.apply(0, t);
36935    }
36936
36937    if (r["seed" + s] = f, p(r.random(), e), t.exports) {
36938      t.exports = f;
36939
36940      try {
36941        n = require("crypto");
36942      } catch (t) {}
36943    } else 0;
36944  }([], Math);
36945});
36946seedrandom.alea = alea, seedrandom.xor128 = xor128, seedrandom.xorwow = xorwow, seedrandom.xorshift7 = xorshift7, seedrandom.xor4096 = xor4096, seedrandom.tychei = tychei;
36947var seedrandom$1 = seedrandom,
36948    seedrandom_1 = seedrandom$1.alea;
36949
36950function deepMap(t, e) {
36951  return deepMapInternal(t, e);
36952}
36953
36954function deepMapInternal(t, e, r, n) {
36955  if (void 0 === r && (r = new Map()), void 0 === n && (n = new Set()), null == t) return null;
36956  if (n.has(t)) throw new Error("Circular references are not supported.");
36957  if (r.has(t)) return r.get(t);
36958  var i = e(t);
36959  if (i.recurse && null !== i.value) throw new Error("A deep map function may not return both a value and recurse=true.");
36960
36961  if (i.recurse) {
36962    if (isIterable(t)) {
36963      var o = Array.isArray(t) ? [] : {};
36964
36965      for (var a in n.add(t), t) {
36966        var s = deepMapInternal(t[a], e, r, n);
36967        o[a] = s;
36968      }
36969
36970      return n.delete(t), o;
36971    }
36972
36973    throw new Error("Can't recurse into non-iterable type: " + t);
36974  }
36975
36976  return r.set(t, i.value), i.value;
36977}
36978
36979function deepZip(t, e) {
36980  return void 0 === e && (e = zipToList), deepZipInternal(t, e);
36981}
36982
36983function deepZipInternal(t, e, r) {
36984  void 0 === r && (r = new Set());
36985  var n = t[0];
36986  if (r.has(n)) throw new Error("Circular references are not supported.");
36987  var i = e(t);
36988  if (i.recurse && null !== i.value) throw new Error("A deep zip function may not return both a value and recurse=true.");
36989
36990  if (i.recurse) {
36991    if (isIterable(n)) {
36992      var o = Array.isArray(n) ? [] : {};
36993      r.add(n);
36994
36995      var a = function (n) {
36996        var i = deepZipInternal(t.map(function (t) {
36997          return t[n];
36998        }), e, r);
36999        o[n] = i;
37000      };
37001
37002      for (var s in n) a(s);
37003
37004      return r.delete(n), o;
37005    }
37006
37007    throw new Error("Can't recurse into non-iterable type: " + n);
37008  }
37009
37010  return i.value;
37011}
37012
37013function zipToList(t) {
37014  return null === t ? null : isIterable(t[0]) ? {
37015    value: null,
37016    recurse: !0
37017  } : {
37018    value: t,
37019    recurse: !1
37020  };
37021}
37022
37023function deepMapAndAwaitAll(t, e) {
37024  return __awaiter(this, void 0, void 0, function () {
37025    var r, n, i, o, a, s;
37026    return __generator(this, function (u) {
37027      switch (u.label) {
37028        case 0:
37029          r = new Map(), deepMapInternal(t, e, r), n = 0, i = Array.from(r.keys()), u.label = 1;
37030
37031        case 1:
37032          return n < i.length ? (o = i[n], (a = r.get(o)) instanceof Promise ? [4, a] : [3, 3]) : [3, 4];
37033
37034        case 2:
37035          s = u.sent(), r.set(o, s), u.label = 3;
37036
37037        case 3:
37038          return n++, [3, 1];
37039
37040        case 4:
37041          return [2, deepMapInternal(t, e, r)];
37042      }
37043    });
37044  });
37045}
37046
37047function isIterable(t) {
37048  return null != t && !ArrayBuffer.isView(t) && (Array.isArray(t) || "object" == typeof t && !(t instanceof _tfjsCore.Tensor));
37049}
37050
37051function canTensorify(t) {
37052  return null == t || isPrimitive(t) || Array.isArray(t) || "object" == typeof t && t instanceof _tfjsCore.Tensor || _tfjsCore.util.isTypedArray(t);
37053}
37054
37055function isPrimitive(t) {
37056  return null === t || "object" != typeof t && "function" != typeof t;
37057}
37058
37059function deepClone(t) {
37060  return deepMap(t, cloneIfTensor);
37061}
37062
37063function cloneIfTensor(t) {
37064  return t instanceof _tfjsCore.Tensor ? {
37065    value: t.clone(),
37066    recurse: !1
37067  } : isIterable(t) ? {
37068    value: null,
37069    recurse: !0
37070  } : {
37071    value: t,
37072    recurse: !1
37073  };
37074}
37075
37076var RingBuffer = function () {
37077  function t(t) {
37078    if (this.capacity = t, this.begin = 0, this.end = 0, null == t) throw new RangeError("Can't create a ring buffer of unknown capacity.");
37079    if (t < 1) throw new RangeError("Can't create ring buffer of capacity < 1.");
37080    this.data = new Array(t), this.doubledCapacity = 2 * t;
37081  }
37082
37083  return t.prototype.wrap = function (t) {
37084    for (; t < 0;) t += this.doubledCapacity;
37085
37086    return t % this.doubledCapacity;
37087  }, t.prototype.get = function (t) {
37088    if (t < 0) throw new RangeError("Can't get item at a negative index.");
37089    return this.data[t % this.capacity];
37090  }, t.prototype.set = function (t, e) {
37091    if (t < 0) throw new RangeError("Can't set item at a negative index.");
37092    this.data[t % this.capacity] = e;
37093  }, t.prototype.length = function () {
37094    var t = this.end - this.begin;
37095    return t < 0 && (t = this.doubledCapacity + t), t;
37096  }, t.prototype.isFull = function () {
37097    return this.length() === this.capacity;
37098  }, t.prototype.isEmpty = function () {
37099    return 0 === this.length();
37100  }, t.prototype.push = function (t) {
37101    if (this.isFull()) throw new RangeError("Ring buffer is full.");
37102    this.set(this.end, t), this.end = this.wrap(this.end + 1);
37103  }, t.prototype.pushAll = function (t) {
37104    for (var e = 0, r = t; e < r.length; e++) {
37105      var n = r[e];
37106      this.push(n);
37107    }
37108  }, t.prototype.pop = function () {
37109    if (this.isEmpty()) throw new RangeError("Ring buffer is empty.");
37110    this.end = this.wrap(this.end - 1);
37111    var t = this.get(this.end);
37112    return this.set(this.end, void 0), t;
37113  }, t.prototype.unshift = function (t) {
37114    if (this.isFull()) throw new RangeError("Ring buffer is full.");
37115    this.begin = this.wrap(this.begin - 1), this.set(this.begin, t);
37116  }, t.prototype.shift = function () {
37117    if (this.isEmpty()) throw new RangeError("Ring buffer is empty.");
37118    var t = this.get(this.begin);
37119    return this.set(this.begin, void 0), this.begin = this.wrap(this.begin + 1), t;
37120  }, t.prototype.shuffleExcise = function (t) {
37121    if (this.isEmpty()) throw new RangeError("Ring buffer is empty.");
37122    var e = this.wrap(this.begin + t),
37123        r = this.get(e);
37124    return this.set(e, this.pop()), r;
37125  }, t;
37126}(),
37127    GrowingRingBuffer = function (t) {
37128  function e() {
37129    return t.call(this, e.INITIAL_CAPACITY) || this;
37130  }
37131
37132  return __extends(e, t), e.prototype.isFull = function () {
37133    return !1;
37134  }, e.prototype.push = function (e) {
37135    t.prototype.isFull.call(this) && this.expand(), t.prototype.push.call(this, e);
37136  }, e.prototype.unshift = function (e) {
37137    t.prototype.isFull.call(this) && this.expand(), t.prototype.unshift.call(this, e);
37138  }, e.prototype.expand = function () {
37139    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));
37140
37141    this.data = e, this.capacity = t, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end = r;
37142  }, e.INITIAL_CAPACITY = 32, e;
37143}(RingBuffer);
37144
37145function iteratorFromItems(t) {
37146  return new ArrayIterator(t);
37147}
37148
37149function iteratorFromFunction(t) {
37150  return new FunctionCallIterator(t);
37151}
37152
37153function iteratorFromConcatenated(t, e) {
37154  return new ChainedIterator(t, e);
37155}
37156
37157function iteratorFromZipped(t, e) {
37158  return void 0 === e && (e = ZipMismatchMode.FAIL), new ZipIterator(t, e);
37159}
37160
37161var ZipMismatchMode,
37162    LazyIterator = function () {
37163  function t() {}
37164
37165  return t.prototype.toArray = function () {
37166    return __awaiter(this, void 0, void 0, function () {
37167      var t, e;
37168      return __generator(this, function (r) {
37169        switch (r.label) {
37170          case 0:
37171            return t = [], [4, this.next()];
37172
37173          case 1:
37174            e = r.sent(), r.label = 2;
37175
37176          case 2:
37177            return e.done ? [3, 4] : (t.push(e.value), [4, this.next()]);
37178
37179          case 3:
37180            return e = r.sent(), [3, 2];
37181
37182          case 4:
37183            return [2, t];
37184        }
37185      });
37186    });
37187  }, t.prototype.toArrayForTest = function () {
37188    return __awaiter(this, void 0, void 0, function () {
37189      var t, e, r;
37190      return __generator(this, function (n) {
37191        switch (n.label) {
37192          case 0:
37193            return t = this.prefetch(100), e = [], [4, t.next()];
37194
37195          case 1:
37196            r = n.sent(), n.label = 2;
37197
37198          case 2:
37199            return r.done ? [3, 4] : (e.push(r.value), [4, t.next()]);
37200
37201          case 3:
37202            return r = n.sent(), [3, 2];
37203
37204          case 4:
37205            return [2, e];
37206        }
37207      });
37208    });
37209  }, t.prototype.resolveFully = function () {
37210    return __awaiter(this, void 0, void 0, function () {
37211      var t;
37212      return __generator(this, function (e) {
37213        switch (e.label) {
37214          case 0:
37215            return [4, this.next()];
37216
37217          case 1:
37218            t = e.sent(), e.label = 2;
37219
37220          case 2:
37221            return t.done ? [3, 4] : [4, this.next()];
37222
37223          case 3:
37224            return t = e.sent(), [3, 2];
37225
37226          case 4:
37227            return [2];
37228        }
37229      });
37230    });
37231  }, t.prototype.resolveWhile = function (t) {
37232    return __awaiter(this, void 0, void 0, function () {
37233      var e, r;
37234      return __generator(this, function (n) {
37235        switch (n.label) {
37236          case 0:
37237            return [4, this.next()];
37238
37239          case 1:
37240            e = n.sent(), r = t(e.value), n.label = 2;
37241
37242          case 2:
37243            return e.done || !r ? [3, 4] : [4, this.next()];
37244
37245          case 3:
37246            return e = n.sent(), r = t(e.value), [3, 2];
37247
37248          case 4:
37249            return [2];
37250        }
37251      });
37252    });
37253  }, t.prototype.handleErrors = function (t) {
37254    return new ErrorHandlingLazyIterator(this, t);
37255  }, t.prototype.filter = function (t) {
37256    return new FilterIterator(this, t);
37257  }, t.prototype.map = function (t) {
37258    return new MapIterator(this, t);
37259  }, t.prototype.mapAsync = function (t) {
37260    return new AsyncMapIterator(this, t);
37261  }, t.prototype.serialMapAsync = function (t) {
37262    return new AsyncMapIterator(this, t).serial();
37263  }, t.prototype.flatmap = function (t) {
37264    return new FlatmapIterator(this, t);
37265  }, t.prototype.forEachAsync = function (t) {
37266    return __awaiter(this, void 0, void 0, function () {
37267      return __generator(this, function (e) {
37268        return [2, this.map(t).resolveFully()];
37269      });
37270    });
37271  }, t.prototype.serialForEach = function (t) {
37272    return __awaiter(this, void 0, void 0, function () {
37273      return __generator(this, function (e) {
37274        return [2, this.serialMapAsync(t).resolveWhile(function (t) {
37275          return !0 === t;
37276        })];
37277      });
37278    });
37279  }, t.prototype.rowMajorBatch = function (t, e) {
37280    return void 0 === e && (e = !0), new RowMajorBatchIterator(this, t, e);
37281  }, t.prototype.columnMajorBatch = function (t, e, r) {
37282    return void 0 === e && (e = !0), void 0 === r && (r = zipToList), this.rowMajorBatch(t, e).map(function (t) {
37283      return deepZip(t, r);
37284    });
37285  }, t.prototype.concatenate = function (t, e) {
37286    return new ChainedIterator(iteratorFromItems([this, t]), e);
37287  }, t.prototype.take = function (t) {
37288    return t < 0 || null == t ? this : new TakeIterator(this, t);
37289  }, t.prototype.skip = function (t) {
37290    return t < 0 || null == t ? this : new SkipIterator(this, t);
37291  }, t.prototype.prefetch = function (t) {
37292    return new PrefetchIterator(this, t);
37293  }, t.prototype.shuffle = function (t, e) {
37294    return new ShuffleIterator(this, t, e);
37295  }, t.prototype.serial = function () {
37296    return new SerialIterator(this);
37297  }, t;
37298}(),
37299    ArrayIterator = function (t) {
37300  function e(e) {
37301    var r = t.call(this) || this;
37302    return r.items = e, r.trav = 0, r;
37303  }
37304
37305  return __extends(e, t), e.prototype.summary = function () {
37306    return "Array of " + this.items.length + " items";
37307  }, e.prototype.next = function () {
37308    return __awaiter(this, void 0, void 0, function () {
37309      var t;
37310      return __generator(this, function (e) {
37311        return this.trav >= this.items.length ? [2, {
37312          value: null,
37313          done: !0
37314        }] : (t = this.items[this.trav], this.trav++, [2, {
37315          value: deepClone(t),
37316          done: !1
37317        }]);
37318      });
37319    });
37320  }, e;
37321}(LazyIterator),
37322    FunctionCallIterator = function (t) {
37323  function e(e) {
37324    var r = t.call(this) || this;
37325    return r.nextFn = e, r;
37326  }
37327
37328  return __extends(e, t), e.prototype.summary = function () {
37329    return "Function call";
37330  }, e.prototype.next = function () {
37331    return __awaiter(this, void 0, void 0, function () {
37332      return __generator(this, function (t) {
37333        try {
37334          return [2, this.nextFn()];
37335        } catch (t) {
37336          throw t.message = "Error thrown while iterating through a dataset: " + t.message, t;
37337        }
37338
37339        return [2];
37340      });
37341    });
37342  }, e;
37343}(LazyIterator),
37344    SerialIterator = function (t) {
37345  function e(e) {
37346    var r = t.call(this) || this;
37347    return r.upstream = e, r.lastRead = Promise.resolve({
37348      value: null,
37349      done: !1
37350    }), r;
37351  }
37352
37353  return __extends(e, t), e.prototype.summary = function () {
37354    return this.upstream.summary() + " -> Serial";
37355  }, e.prototype.next = function () {
37356    return __awaiter(this, void 0, void 0, function () {
37357      var t = this;
37358      return __generator(this, function (e) {
37359        return this.lastRead = this.lastRead.then(function () {
37360          return t.serialNext();
37361        }), [2, this.lastRead];
37362      });
37363    });
37364  }, e.prototype.serialNext = function () {
37365    return __awaiter(this, void 0, void 0, function () {
37366      return __generator(this, function (t) {
37367        return [2, this.upstream.next()];
37368      });
37369    });
37370  }, e;
37371}(LazyIterator),
37372    SkipIterator = function (t) {
37373  function e(e, r) {
37374    var n = t.call(this) || this;
37375    return n.upstream = e, n.maxCount = r, n.count = 0, n.lastRead = Promise.resolve({
37376      value: null,
37377      done: !1
37378    }), n;
37379  }
37380
37381  return __extends(e, t), e.prototype.summary = function () {
37382    return this.upstream.summary() + " -> Skip";
37383  }, e.prototype.next = function () {
37384    return __awaiter(this, void 0, void 0, function () {
37385      var t = this;
37386      return __generator(this, function (e) {
37387        return this.lastRead = this.lastRead.then(function () {
37388          return t.serialNext();
37389        }), [2, this.lastRead];
37390      });
37391    });
37392  }, e.prototype.serialNext = function () {
37393    return __awaiter(this, void 0, void 0, function () {
37394      var t;
37395      return __generator(this, function (e) {
37396        switch (e.label) {
37397          case 0:
37398            return this.count++ < this.maxCount ? [4, this.upstream.next()] : [3, 2];
37399
37400          case 1:
37401            return (t = e.sent()).done ? [2, t] : ((0, _tfjsCore.dispose)(t.value), [3, 0]);
37402
37403          case 2:
37404            return [2, this.upstream.next()];
37405        }
37406      });
37407    });
37408  }, e;
37409}(LazyIterator),
37410    TakeIterator = function (t) {
37411  function e(e, r) {
37412    var n = t.call(this) || this;
37413    return n.upstream = e, n.maxCount = r, n.count = 0, n;
37414  }
37415
37416  return __extends(e, t), e.prototype.summary = function () {
37417    return this.upstream.summary() + " -> Take";
37418  }, e.prototype.next = function () {
37419    return __awaiter(this, void 0, void 0, function () {
37420      return __generator(this, function (t) {
37421        return this.count++ >= this.maxCount ? [2, {
37422          value: null,
37423          done: !0
37424        }] : [2, this.upstream.next()];
37425      });
37426    });
37427  }, e;
37428}(LazyIterator),
37429    RowMajorBatchIterator = function (t) {
37430  function e(e, r, n) {
37431    void 0 === n && (n = !0);
37432    var i = t.call(this) || this;
37433    return i.upstream = e, i.batchSize = r, i.enableSmallLastBatch = n, i.lastRead = Promise.resolve({
37434      value: null,
37435      done: !1
37436    }), i;
37437  }
37438
37439  return __extends(e, t), e.prototype.summary = function () {
37440    return this.upstream.summary() + " -> RowMajorBatch";
37441  }, e.prototype.next = function () {
37442    return __awaiter(this, void 0, void 0, function () {
37443      var t = this;
37444      return __generator(this, function (e) {
37445        return this.lastRead = this.lastRead.then(function () {
37446          return t.serialNext();
37447        }), [2, this.lastRead];
37448      });
37449    });
37450  }, e.prototype.serialNext = function () {
37451    return __awaiter(this, void 0, void 0, function () {
37452      var t, e;
37453      return __generator(this, function (r) {
37454        switch (r.label) {
37455          case 0:
37456            t = [], r.label = 1;
37457
37458          case 1:
37459            return t.length < this.batchSize ? [4, this.upstream.next()] : [3, 3];
37460
37461          case 2:
37462            return (e = r.sent()).done ? this.enableSmallLastBatch && t.length > 0 ? [2, {
37463              value: t,
37464              done: !1
37465            }] : [2, {
37466              value: null,
37467              done: !0
37468            }] : (t.push(e.value), [3, 1]);
37469
37470          case 3:
37471            return [2, {
37472              value: t,
37473              done: !1
37474            }];
37475        }
37476      });
37477    });
37478  }, e;
37479}(LazyIterator),
37480    FilterIterator = function (t) {
37481  function e(e, r) {
37482    var n = t.call(this) || this;
37483    return n.upstream = e, n.predicate = r, n.lastRead = Promise.resolve({
37484      value: null,
37485      done: !1
37486    }), n;
37487  }
37488
37489  return __extends(e, t), e.prototype.summary = function () {
37490    return this.upstream.summary() + " -> Filter";
37491  }, e.prototype.next = function () {
37492    return __awaiter(this, void 0, void 0, function () {
37493      var t = this;
37494      return __generator(this, function (e) {
37495        return this.lastRead = this.lastRead.then(function () {
37496          return t.serialNext();
37497        }), [2, this.lastRead];
37498      });
37499    });
37500  }, e.prototype.serialNext = function () {
37501    return __awaiter(this, void 0, void 0, function () {
37502      var t;
37503      return __generator(this, function (e) {
37504        switch (e.label) {
37505          case 0:
37506            return [4, this.upstream.next()];
37507
37508          case 1:
37509            return (t = e.sent()).done || this.predicate(t.value) ? [2, t] : ((0, _tfjsCore.dispose)(t.value), [3, 0]);
37510
37511          case 2:
37512            return [2];
37513        }
37514      });
37515    });
37516  }, e;
37517}(LazyIterator),
37518    MapIterator = function (t) {
37519  function e(e, r) {
37520    var n = t.call(this) || this;
37521    return n.upstream = e, n.transform = r, n;
37522  }
37523
37524  return __extends(e, t), e.prototype.summary = function () {
37525    return this.upstream.summary() + " -> Map";
37526  }, e.prototype.next = function () {
37527    return __awaiter(this, void 0, void 0, function () {
37528      var t, e, r, n, i, o, a;
37529      return __generator(this, function (s) {
37530        switch (s.label) {
37531          case 0:
37532            return [4, this.upstream.next()];
37533
37534          case 1:
37535            if ((t = s.sent()).done) return [2, {
37536              value: null,
37537              done: !0
37538            }];
37539
37540            for (e = _tfjsCore.tensor_util.getTensorsInContainer(t.value), r = this.transform(t.value), n = _tfjsCore.tensor_util.getTensorsInContainer(r), i = 0, o = e; i < o.length; i++) a = o[i], _tfjsCore.tensor_util.isTensorInList(a, n) || a.dispose();
37541
37542            return [2, {
37543              value: r,
37544              done: !1
37545            }];
37546        }
37547      });
37548    });
37549  }, e;
37550}(LazyIterator),
37551    ErrorHandlingLazyIterator = function (t) {
37552  function e(e, r) {
37553    var n = t.call(this) || this;
37554    return n.upstream = e, n.handler = r, n.count = 0, n.lastRead = Promise.resolve({
37555      value: null,
37556      done: !1
37557    }), n;
37558  }
37559
37560  return __extends(e, t), e.prototype.summary = function () {
37561    return this.upstream.summary() + " -> handleErrors";
37562  }, e.prototype.next = function () {
37563    return __awaiter(this, void 0, void 0, function () {
37564      var t = this;
37565      return __generator(this, function (e) {
37566        return this.lastRead = this.lastRead.then(function () {
37567          return t.serialNext();
37568        }), [2, this.lastRead];
37569      });
37570    });
37571  }, e.prototype.serialNext = function () {
37572    return __awaiter(this, void 0, void 0, function () {
37573      var t;
37574      return __generator(this, function (e) {
37575        switch (e.label) {
37576          case 0:
37577            e.label = 1;
37578
37579          case 1:
37580            return e.trys.push([1, 3,, 4]), [4, this.upstream.next()];
37581
37582          case 2:
37583            return [2, e.sent()];
37584
37585          case 3:
37586            return t = e.sent(), this.handler(t) ? [3, 4] : [2, {
37587              value: null,
37588              done: !0
37589            }];
37590
37591          case 4:
37592            return [3, 0];
37593
37594          case 5:
37595            return [2];
37596        }
37597      });
37598    });
37599  }, e;
37600}(LazyIterator),
37601    AsyncMapIterator = function (t) {
37602  function e(e, r) {
37603    var n = t.call(this) || this;
37604    return n.upstream = e, n.transform = r, n;
37605  }
37606
37607  return __extends(e, t), e.prototype.summary = function () {
37608    return this.upstream.summary() + " -> AsyncMap";
37609  }, e.prototype.next = function () {
37610    return __awaiter(this, void 0, void 0, function () {
37611      var t, e, r, n, i, o, a;
37612      return __generator(this, function (s) {
37613        switch (s.label) {
37614          case 0:
37615            return [4, this.upstream.next()];
37616
37617          case 1:
37618            return (t = s.sent()).done ? [2, {
37619              value: null,
37620              done: !0
37621            }] : (e = _tfjsCore.tensor_util.getTensorsInContainer(t.value), [4, this.transform(t.value)]);
37622
37623          case 2:
37624            for (r = s.sent(), n = _tfjsCore.tensor_util.get
37624TensorsInContainer(r), i = 0, o = e; i < o.length; i++) a = o[i], _tfjsCore.tensor_util.isTensorInList(a, n) || a.dispose();
37625
37626            return [2, {
37627              value: r,
37628              done: !1
37629            }];
37630        }
37631      });
37632    });
37633  }, e;
37634}(LazyIterator),
37635    OneToManyIterator = function (t) {
37636  function e() {
37637    var e = t.call(this) || this;
37638    return e.outputQueue = new GrowingRingBuffer(), e.lastRead = Promise.resolve({
37639      value: null,
37640      done: !1
37641    }), e;
37642  }
37643
37644  return __extends(e, t), e.prototype.next = function () {
37645    return __awaiter(this, void 0, void 0, function () {
37646      var t = this;
37647      return __generator(this, function (e) {
37648        return this.lastRead = this.lastRead.then(function () {
37649          return t.serialNext();
37650        }), [2, this.lastRead];
37651      });
37652    });
37653  }, e.prototype.serialNext = function () {
37654    return __awaiter(this, void 0, void 0, function () {
37655      return __generator(this, function (t) {
37656        switch (t.label) {
37657          case 0:
37658            return 0 !== this.outputQueue.length() ? [3, 2] : [4, this.pump()];
37659
37660          case 1:
37661            return t.sent() ? [3, 0] : [2, {
37662              value: null,
37663              done: !0
37664            }];
37665
37666          case 2:
37667            return [2, {
37668              value: this.outputQueue.shift(),
37669              done: !1
37670            }];
37671        }
37672      });
37673    });
37674  }, e;
37675}(LazyIterator),
37676    FlatmapIterator = function (t) {
37677  function e(e, r) {
37678    var n = t.call(this) || this;
37679    return n.upstream = e, n.transform = r, n;
37680  }
37681
37682  return __extends(e, t), e.prototype.summary = function () {
37683    return this.upstream.summary() + " -> Flatmap";
37684  }, e.prototype.pump = function () {
37685    return __awaiter(this, void 0, void 0, function () {
37686      var t, e, r, n, i, o, a;
37687      return __generator(this, function (s) {
37688        switch (s.label) {
37689          case 0:
37690            return [4, this.upstream.next()];
37691
37692          case 1:
37693            if ((t = s.sent()).done) return [2, !1];
37694
37695            for (e = _tfjsCore.tensor_util.getTensorsInContainer(t.value), r = this.transform(t.value), n = _tfjsCore.tensor_util.getTensorsInContainer(r), this.outputQueue.pushAll(r), i = 0, o = e; i < o.length; i++) a = o[i], _tfjsCore.tensor_util.isTensorInList(a, n) || a.dispose();
37696
37697            return [2, !0];
37698        }
37699      });
37700    });
37701  }, e;
37702}(OneToManyIterator),
37703    ChainedIterator = function (t) {
37704  function e(e, r) {
37705    var n = t.call(this) || this;
37706    return n.baseErrorHandler = r, n.lastRead = null, n.iterator = null, n.moreIterators = e, n;
37707  }
37708
37709  return __extends(e, t), e.prototype.summary = function () {
37710    return "TODO: fill in upstream of chained summaries -> Chained";
37711  }, e.prototype.next = function () {
37712    return __awaiter(this, void 0, void 0, function () {
37713      return __generator(this, function (t) {
37714        return this.lastRead = this.readFromChain(this.lastRead), [2, this.lastRead];
37715      });
37716    });
37717  }, e.prototype.readFromChain = function (t) {
37718    return __awaiter(this, void 0, void 0, function () {
37719      var e, r;
37720      return __generator(this, function (n) {
37721        switch (n.label) {
37722          case 0:
37723            return [4, t];
37724
37725          case 1:
37726            return n.sent(), null != this.iterator ? [3, 3] : [4, this.moreIterators.next()];
37727
37728          case 2:
37729            if ((e = n.sent()).done) return [2, {
37730              value: null,
37731              done: !0
37732            }];
37733            this.iterator = e.value, null != this.baseErrorHandler && (this.iterator = this.iterator.handleErrors(this.baseErrorHandler)), n.label = 3;
37734
37735          case 3:
37736            return [4, this.iterator.next()];
37737
37738          case 4:
37739            return (r = n.sent()).done ? (this.iterator = null, [2, this.readFromChain(t)]) : [2, r];
37740        }
37741      });
37742    });
37743  }, e;
37744}(LazyIterator);
37745
37746!function (t) {
37747  t[t.FAIL = 0] = "FAIL", t[t.SHORTEST = 1] = "SHORTEST", t[t.LONGEST = 2] = "LONGEST";
37748}(ZipMismatchMode || (ZipMismatchMode = {}));
37749
37750var ZipIterator = function (t) {
37751  function e(e, r) {
37752    void 0 === r && (r = ZipMismatchMode.FAIL);
37753    var n = t.call(this) || this;
37754    return n.iterators = e, n.mismatchMode = r, n.count = 0, n.currentPromise = null, n;
37755  }
37756
37757  return __extends(e, t), e.prototype.summary = function () {
37758    return "{TODO: fill in upstream of zip summaries} -> Zip";
37759  }, e.prototype.nextState = function (t) {
37760    return __awaiter(this, void 0, void 0, function () {
37761      function e(t) {
37762        return t instanceof LazyIterator ? {
37763          value: t.next().then(function (t) {
37764            return r++, t.done && n++, t.value;
37765          }),
37766          recurse: !1
37767        } : {
37768          value: null,
37769          recurse: !0
37770        };
37771      }
37772
37773      var r, n, i;
37774      return __generator(this, function (o) {
37775        switch (o.label) {
37776          case 0:
37777            return [4, t];
37778
37779          case 1:
37780            return o.sent(), r = 0, n = 0, [4, deepMapAndAwaitAll(this.iterators, e)];
37781
37782          case 2:
37783            if (i = o.sent(), r === n) return [2, {
37784              value: null,
37785              done: !0
37786            }];
37787            if (n > 0) switch (this.mismatchMode) {
37788              case ZipMismatchMode.FAIL:
37789                throw new Error("Zipped streams should have the same length. Mismatched at element " + this.count + ".");
37790
37791              case ZipMismatchMode.SHORTEST:
37792                return [2, {
37793                  value: null,
37794                  done: !0
37795                }];
37796
37797              case ZipMismatchMode.LONGEST:
37798            }
37799            return this.count++, [2, {
37800              value: i,
37801              done: !1
37802            }];
37803        }
37804      });
37805    });
37806  }, e.prototype.next = function () {
37807    return __awaiter(this, void 0, void 0, function () {
37808      return __generator(this, function (t) {
37809        return this.currentPromise = this.nextState(this.currentPromise), [2, this.currentPromise];
37810      });
37811    });
37812  }, e;
37813}(LazyIterator),
37814    PrefetchIterator = function (t) {
37815  function e(e, r) {
37816    var n = t.call(this) || this;
37817    return n.upstream = e, n.bufferSize = r, n.buffer = new RingBuffer(r), n;
37818  }
37819
37820  return __extends(e, t), e.prototype.summary = function () {
37821    return this.upstream.summary() + " -> Prefetch";
37822  }, e.prototype.refill = function () {
37823    for (; !this.buffer.isFull();) {
37824      var t = this.upstream.next();
37825      this.buffer.push(t);
37826    }
37827  }, e.prototype.next = function () {
37828    return this.refill(), this.buffer.shift();
37829  }, e;
37830}(LazyIterator),
37831    ShuffleIterator = function (t) {
37832  function e(e, r, n) {
37833    var i = t.call(this, e, r) || this;
37834    return i.upstream = e, i.windowSize = r, i.upstreamExhausted = !1, i.random = seedrandom_1(n || _tfjsCore.util.now().toString()), i.lastRead = Promise.resolve({
37835      value: null,
37836      done: !1
37837    }), i;
37838  }
37839
37840  return __extends(e, t), e.prototype.next = function () {
37841    return __awaiter(this, void 0, void 0, function () {
37842      var t = this;
37843      return __generator(this, function (e) {
37844        return this.lastRead = this.lastRead.then(function () {
37845          return t.serialNext();
37846        }), [2, this.lastRead];
37847      });
37848    });
37849  }, e.prototype.randomInt = function (t) {
37850    return Math.floor(this.random() * t);
37851  }, e.prototype.chooseIndex = function () {
37852    return this.randomInt(this.buffer.length());
37853  }, e.prototype.serialNext = function () {
37854    return __awaiter(this, void 0, void 0, function () {
37855      var t, e;
37856      return __generator(this, function (r) {
37857        switch (r.label) {
37858          case 0:
37859            this.upstreamExhausted || this.refill(), r.label = 1;
37860
37861          case 1:
37862            return this.buffer.isEmpty() ? [3, 3] : (t = this.chooseIndex(), [4, this.buffer.shuffleExcise(t)]);
37863
37864          case 2:
37865            return (e = r.sent()).done ? (this.upstreamExhausted = !0, [3, 1]) : (this.refill(), [2, e]);
37866
37867          case 3:
37868            return [2, {
37869              value: null,
37870              done: !0
37871            }];
37872        }
37873      });
37874    });
37875  }, e;
37876}(PrefetchIterator),
37877    Dataset = function () {
37878  function t() {
37879    this.size = null;
37880  }
37881
37882  return t.prototype.batch = function (t, e) {
37883    var r = this;
37884    void 0 === e && (e = !0);
37885    var n = this;
37886    return _tfjsCore.util.assert(t > 0, function () {
37887      return "batchSize needs to be positive, but it is\n      " + t;
37888    }), datasetFromIteratorFn(function () {
37889      return __awaiter(r, void 0, void 0, function () {
37890        return __generator(this, function (r) {
37891          switch (r.label) {
37892            case 0:
37893              return [4, n.iterator()];
37894
37895            case 1:
37896              return [2, r.sent().columnMajorBatch(t, e, deepBatchConcat)];
37897          }
37898        });
37899      });
37900    }, this.size === 1 / 0 || null == this.size ? this.size : e ? Math.ceil(this.size / t) : Math.floor(this.size / t));
37901  }, t.prototype.concatenate = function (t) {
37902    var e = this,
37903        r = this;
37904    return datasetFromIteratorFn(function () {
37905      return __awaiter(e, void 0, void 0, function () {
37906        var e, n;
37907        return __generator(this, function (i) {
37908          switch (i.label) {
37909            case 0:
37910              return [4, r.iterator()];
37911
37912            case 1:
37913              return n = (e = i.sent()).concatenate, [4, t.iterator()];
37914
37915            case 2:
37916              return [2, n.apply(e, [i.sent()])];
37917          }
37918        });
37919      });
37920    }, this.size === 1 / 0 || t.size === 1 / 0 ? 1 / 0 : null != this.size && null != t.size ? this.size + t.size : null);
37921  }, t.prototype.filter = function (t) {
37922    var e = this,
37923        r = this;
37924    return datasetFromIteratorFn(function () {
37925      return __awaiter(e, void 0, void 0, function () {
37926        return __generator(this, function (e) {
37927          switch (e.label) {
37928            case 0:
37929              return [4, r.iterator()];
37930
37931            case 1:
37932              return [2, e.sent().filter(function (e) {
37933                return (0, _tfjsCore.tidy)(function () {
37934                  return t(e);
37935                });
37936              })];
37937          }
37938        });
37939      });
37940    }, this.size === 1 / 0 ? 1 / 0 : null);
37941  }, t.prototype.forEachAsync = function (t) {
37942    return __awaiter(this, void 0, void 0, function () {
37943      return __generator(this, function (e) {
37944        switch (e.label) {
37945          case 0:
37946            return [4, this.iterator()];
37947
37948          case 1:
37949            return [2, e.sent().forEachAsync(t)];
37950        }
37951      });
37952    });
37953  }, t.prototype.forEach = function (t) {
37954    return __awaiter(this, void 0, void 0, function () {
37955      return __generator(this, function (e) {
37956        return (0, _tfjsCore.deprecationWarn)("dataset.forEach() is deprecated and will be removed. Please use dataset.forEachAsync() instead"), [2, this.forEachAsync(t)];
37957      });
37958    });
37959  }, t.prototype.map = function (t) {
37960    var e = this,
37961        r = this;
37962    return datasetFromIteratorFn(function () {
37963      return __awaiter(e, void 0, void 0, function () {
37964        return __generator(this, function (e) {
37965          switch (e.label) {
37966            case 0:
37967              return [4, r.iterator()];
37968
37969            case 1:
37970              return [2, e.sent().map(function (e) {
37971                return (0, _tfjsCore.tidy)(function () {
37972                  return t(e);
37973                });
37974              })];
37975          }
37976        });
37977      });
37978    }, this.size);
37979  }, t.prototype.mapAsync = function (t) {
37980    var e = this,
37981        r = this;
37982    return datasetFromIteratorFn(function () {
37983      return __awaiter(e, void 0, void 0, function () {
37984        return __generator(this, function (e) {
37985          switch (e.label) {
37986            case 0:
37987              return [4, r.iterator()];
37988
37989            case 1:
37990              return [2, e.sent().mapAsync(t)];
37991          }
37992        });
37993      });
37994    }, this.size);
37995  }, t.prototype.prefetch = function (t) {
37996    var e = this;
37997    if (null == t) throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified.");
37998    var r = this;
37999    return datasetFromIteratorFn(function () {
38000      return __awaiter(e, void 0, void 0, function () {
38001        return __generator(this, function (e) {
38002          switch (e.label) {
38003            case 0:
38004              return [4, r.iterator()];
38005
38006            case 1:
38007              return [2, e.sent().prefetch(t)];
38008          }
38009        });
38010      });
38011    }, this.size);
38012  }, t.prototype.repeat = function (t) {
38013    var e = this,
38014        r = this;
38015    return datasetFromIteratorFn(function () {
38016      return __awaiter(e, void 0, void 0, function () {
38017        var e = this;
38018        return __generator(this, function (n) {
38019          return [2, iteratorFromConcatenated(iteratorFromFunction(function () {
38020            return __awaiter(e, void 0, void 0, function () {
38021              var t;
38022              return __generator(this, function (e) {
38023                switch (e.label) {
38024                  case 0:
38025                    return t = {}, [4, r.iterator()];
38026
38027                  case 1:
38028                    return [2, (t.value = e.sent(), t.done = !1, t)];
38029                }
38030              });
38031            });
38032          }).take(t))];
38033        });
38034      });
38035    }, null != this.size && t > 0 ? this.size * t : 0 === t ? 0 : null != this.size && (void 0 === t || t < 0) ? 1 / 0 : null);
38036  }, t.prototype.skip = function (t) {
38037    var e = this,
38038        r = this;
38039    return datasetFromIteratorFn(function () {
38040      return __awaiter(e, void 0, void 0, function () {
38041        return __generator(this, function (e) {
38042          switch (e.label) {
38043            case 0:
38044              return [4, r.iterator()];
38045
38046            case 1:
38047              return [2, e.sent().skip(t)];
38048          }
38049        });
38050      });
38051    }, null != this.size && t >= 0 && this.size >= t ? this.size - t : null != this.size && (this.size < t || void 0 === t || t < 0) ? 0 : null);
38052  }, t.prototype.shuffle = function (t, e, r) {
38053    var n = this;
38054    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)");
38055    var i = this,
38056        o = seedrandom_1(e || _tfjsCore.util.now().toString());
38057    return datasetFromIteratorFn(function () {
38058      return __awaiter(n, void 0, void 0, function () {
38059        var e;
38060        return __generator(this, function (n) {
38061          switch (n.label) {
38062            case 0:
38063              return e = o.int32(), r && (e += o.int32()), [4, i.iterator()];
38064
38065            case 1:
38066              return [2, n.sent().shuffle(t, e.toString())];
38067          }
38068        });
38069      });
38070    }, this.size);
38071  }, t.prototype.take = function (t) {
38072    var e = this,
38073        r = this;
38074    return datasetFromIteratorFn(function () {
38075      return __awaiter(e, void 0, void 0, function () {
38076        return __generator(this, function (e) {
38077          switch (e.label) {
38078            case 0:
38079              return [4, r.iterator()];
38080
38081            case 1:
38082              return [2, e.sent().take(t)];
38083          }
38084        });
38085      });
38086    }, null != this.size && this.size > t ? t : null != this.size && this.size <= t ? this.size : null);
38087  }, t.prototype.toArray = function () {
38088    return __awaiter(this, void 0, void 0, function () {
38089      return __generator(this, function (t) {
38090        switch (t.label) {
38091          case 0:
38092            if (this.size === 1 / 0) throw new Error("Can not convert infinite data stream to array.");
38093            return [4, this.iterator()];
38094
38095          case 1:
38096            return [2, t.sent().toArray()];
38097        }
38098      });
38099    });
38100  }, t.prototype.toArrayForTest = function () {
38101    return __awaiter(this, void 0, void 0, function () {
38102      return __generator(this, function (t) {
38103        switch (t.label) {
38104          case 0:
38105            if (this.size === 1 / 0) throw new Error("Can not convert infinite data stream to array.");
38106            return [4, this.iterator()];
38107
38108          case 1:
38109            return [2, t.sent().toArrayForTest()];
38110        }
38111      });
38112    });
38113  }, t.MAX_BUFFER_SIZE = 1e4, t;
38114}();
38115
38116exports.Dataset = Dataset;
38117
38118function datasetFromIteratorFn(t, e) {
38119  return void 0 === e && (e = null), new (function (r) {
38120    function n() {
38121      var t = null !== r && r.apply(this, arguments) || this;
38122      return t.size = e, t;
38123    }
38124
38125    return __extends(n, r), n.prototype.iterator = function () {
38126      return __awaiter(this, void 0, void 0, function () {
38127        return __generator(this, function (e) {
38128          return [2, t()];
38129        });
38130      });
38131    }, n;
38132  }(Dataset))();
38133}
38134
38135function array(t) {
38136  var e = this;
38137  return datasetFromIteratorFn(function () {
38138    return __awaiter(e, void 0, void 0, function () {
38139      return __generator(this, function (e) {
38140        return [2, iteratorFromItems(t)];
38141      });
38142    });
38143  }, t.length);
38144}
38145
38146function zip(t) {
38147  var e,
38148      r = this;
38149  if (!isIterable(t)) throw new Error("The argument to zip() must be an object or array.");
38150  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);
38151  return datasetFromIteratorFn(function () {
38152    return __awaiter(r, void 0, void 0, function () {
38153      return __generator(this, function (e) {
38154        switch (e.label) {
38155          case 0:
38156            return [4, deepMapAndAwaitAll(t, function (t) {
38157              if (t instanceof Dataset) return {
38158                value: t.iterator(),
38159                recurse: !1
38160              };
38161              if (isIterable(t)) return {
38162                value: null,
38163                recurse: !0
38164              };
38165              throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.");
38166            })];
38167
38168          case 1:
38169            return [2, iteratorFromZipped(e.sent(), ZipMismatchMode.SHORTEST)];
38170        }
38171      });
38172    });
38173  }, e);
38174}
38175
38176function deepBatchConcat(t) {
38177  return null === t ? null : canTensorify(t[0]) ? {
38178    value: batchConcat(t),
38179    recurse: !1
38180  } : {
38181    value: null,
38182    recurse: !0
38183  };
38184}
38185
38186function batchConcat(t) {
38187  if (0 === t.length) throw new Error("Can't make a batch of zero elements.");
38188  return t[0] instanceof _tfjsCore.Tensor ? (0, _tfjsCore.stack)(t) : (0, _tfjsCore.tensor)(t);
38189}
38190
38191var TextLineDataset = function (t) {
38192  function e(e) {
38193    var r = t.call(this) || this;
38194    return r.input = e, r;
38195  }
38196
38197  return __extends(e, t), e.prototype.iterator = function () {
38198    return __awaiter(this, void 0, void 0, function () {
38199      var t, e;
38200      return __generator(this, function (r) {
38201        switch (r.label) {
38202          case 0:
38203            return [4, this.input.iterator()];
38204
38205          case 1:
38206            return t = r.sent(), e = t.decodeUTF8(), [2, e.split("\n").map(function (t) {
38207              return t.endsWith("\r") && (t = t.slice(0, -1)), t;
38208            })];
38209        }
38210      });
38211    });
38212  }, e;
38213}(Dataset),
38214    CODE_QUOTE = '"',
38215    STATE_OUT = Symbol("out"),
38216    STATE_FIELD = Symbol("field"),
38217    STATE_QUOTE = Symbol("quote"),
38218    STATE_QUOTE_AFTER_QUOTE = Symbol("quoteafterquote"),
38219    STATE_WITHIN_QUOTE_IN_QUOTE = Symbol("quoteinquote"),
38220    CSVDataset = function (t) {
38221  function e(e, r) {
38222    var n = t.call(this) || this;
38223    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 ? (_tfjsCore.util.assert(null == r.delimiter, function () {
38224      return "Delimiter should not be provided when delimWhitespace is true.";
38225    }), n.delimWhitespace = !0, n.delimiter = " ") : n.delimiter = r.delimiter ? r.delimiter : ",", n;
38226  }
38227
38228  return __extends(e, t), e.prototype.columnNames = function () {
38229    return __awaiter(this, void 0, void 0, function () {
38230      return __generator(this, function (t) {
38231        switch (t.label) {
38232          case 0:
38233            return this.columnNamesValidated ? [3, 2] : [4, this.setColumnNames()];
38234
38235          case 1:
38236            t.sent(), t.label = 2;
38237
38238          case 2:
38239            return [2, this.configuredColumnsOnly ? Object.keys(this.columnConfigs) : this.fullColumnNames];
38240        }
38241      });
38242    });
38243  }, e.prototype.setColumnNames = function () {
38244    return __awaiter(this, void 0, void 0, function () {
38245      var t,
38246          e,
38247          r,
38248          n,
38249          i,
38250          o,
38251          a = this;
38252      return __generator(this, function (s) {
38253        switch (s.label) {
38254          case 0:
38255            return [4, this.maybeReadHeaderLine()];
38256
38257          case 1:
38258            if (t = s.sent(), !this.fullColumnNames && !t) throw new Error("Column names must be provided if there is no header line.");
38259            if (this.fullColumnNames && t && _tfjsCore.util.assert(t.length === this.fullColumnNames.length, function () {
38260              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() + ").";
38261            }), this.fullColumnNames || (this.fullColumnNames = t), e = this.fullColumnNames.reduce(function (t, e) {
38262              return t[e] = t[e] + 1 || 1, t;
38263            }, {}), r = Object.keys(e).filter(function (t) {
38264              return e[t] > 1;
38265            }), _tfjsCore.util.assert(0 === r.length, function () {
38266              return "Duplicate column names found: " + r.toString();
38267            }), 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() + ").");
38268            return this.columnNamesValidated = !0, [2];
38269        }
38270      });
38271    });
38272  }, e.prototype.maybeReadHeaderLine = function () {
38273    return __awaiter(this, void 0, void 0, function () {
38274      var t, e;
38275      return __generator(this, function (r) {
38276        switch (r.label) {
38277          case 0:
38278            return this.hasHeader ? [4, this.base.iterator()] : [3, 3];
38279
38280          case 1:
38281            return [4, r.sent().next()];
38282
38283          case 2:
38284            if ((t = r.sent()).done) throw new Error("No data was found for CSV parsing.");
38285            return e = t.value, [2, this.parseRow(e, !1)];
38286
38287          case 3:
38288            return [2, null];
38289        }
38290      });
38291    });
38292  }, e.prototype.iterator = function () {
38293    return __awaiter(this, void 0, void 0, function () {
38294      var t,
38295          e = this;
38296      return __generator(this, function (r) {
38297        switch (r.label) {
38298          case 0:
38299            return this.columnNamesValidated ? [3, 2] : [4, this.setColumnNames()];
38300
38301          case 1:
38302            r.sent(), r.label = 2;
38303
38304          case 2:
38305            return [4, this.base.iterator()];
38306
38307          case 3:
38308            return t = r.sent(), this.hasHeader && (t = t.skip(1)), [2, t.map(function (t) {
38309              return e.makeDataElement(t);
38310            })];
38311        }
38312      });
38313    });
38314  }, e.prototype.makeDataElement = function (t) {
38315    for (var e = this.parseRow(t), r = {}, n = {}, i = 0; i < this.fullColumnNames.length; i++) {
38316      var o = this.fullColumnNames[i],
38317          a = this.columnConfigs ? this.columnConfigs[o] : null;
38318
38319      if (!this.configuredColumnsOnly || a) {
38320        var s = e[i],
38321            u = null;
38322        if ("" === s) {
38323          if (a && void 0 !== a.default) u = a.default;else {
38324            if (a && (a.required || a.isLabel)) throw new Error("Required column " + o + " is empty in this line: " + t);
38325            u = void 0;
38326          }
38327        } else {
38328          var c = Number(s);
38329          if (isNaN(c)) u = a && "bool" === a.dtype ? this.getBoolean(s) : s;else if (a && a.dtype) switch (a.dtype) {
38330            case "float32":
38331              u = c;
38332              break;
38333
38334            case "int32":
38335              u = Math.floor(c);
38336              break;
38337
38338            case "bool":
38339              u = this.getBoolean(s);
38340              break;
38341
38342            default:
38343              u = c;
38344          } else u = c;
38345        }
38346        a && a.isLabel ? n[o] = u : r[o] = u;
38347      }
38348    }
38349
38350    return 0 === Object.keys(n).length ? r : {
38351      xs: r,
38352      ys: n
38353    };
38354  }, e.prototype.getBoolean = function (t) {
38355    return "1" === t || "true" === t.toLowerCase() ? 1 : 0;
38356  }, e.prototype.parseRow = function (t, e) {
38357    void 0 === e && (e = !0);
38358
38359    for (var r = [], n = 0, i = t.length, o = STATE_OUT, a = 0; a < i; a++) switch (o) {
38360      case STATE_OUT:
38361        switch (t.charAt(a)) {
38362          case CODE_QUOTE:
38363            n = a + 1, o = STATE_QUOTE;
38364            break;
38365
38366          case this.delimiter:
38367            if (n = a + 1, " " === this.delimiter && this.delimWhitespace) break;
38368            r.push(""), o = STATE_OUT;
38369            break;
38370
38371          default:
38372            o = STATE_FIELD, n = a;
38373        }
38374
38375        break;
38376
38377      case STATE_FIELD:
38378        switch (t.charAt(a)) {
38379          case this.delimiter:
38380            r.push(t.substring(n, a)), o = STATE_OUT, n = a + 1;
38381        }
38382
38383        break;
38384
38385      case STATE_QUOTE:
38386        switch (t.charAt(a)) {
38387          case CODE_QUOTE:
38388            o = STATE_QUOTE_AFTER_QUOTE;
38389        }
38390
38391        break;
38392
38393      case STATE_QUOTE_AFTER_QUOTE:
38394        switch (t.charAt(a)) {
38395          case this.delimiter:
38396            r.push(t.substring(n, a - 1)), o = STATE_OUT, n = a + 1;
38397            break;
38398
38399          case CODE_QUOTE:
38400            o = STATE_QUOTE;
38401            break;
38402
38403          default:
38404            o = STATE_WITHIN_QUOTE_IN_QUOTE;
38405        }
38406
38407        break;
38408
38409      case STATE_WITHIN_QUOTE_IN_QUOTE:
38410        switch (t.charAt(a)) {
38411          case CODE_QUOTE:
38412            o = STATE_QUOTE;
38413        }
38414
38415    }
38416
38417    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);
38418    return r;
38419  }, e;
38420}(Dataset),
38421    MicrophoneIterator = function (t) {
38422  function e(e) {
38423    var r = t.call(this) || this;
38424    r.microphoneConfig = e, r.isClosed = !1, r.fftSize = e.fftSize || 1024;
38425    var n = Math.log2(r.fftSize);
38426    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
38426 got " + r.fftSize);
38427    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.");
38428    return r;
38429  }
38430
38431  return __extends(e, t), e.prototype.summary = function () {
38432    return "microphone";
38433  }, e.create = function (t) {
38434    return void 0 === t && (t = {}), __awaiter(this, void 0, void 0, function () {
38435      var r;
38436      return __generator(this, function (n) {
38437        switch (n.label) {
38438          case 0:
38439            if ((0, _tfjsCore.env)().get("IS_NODE")) throw new Error("microphone API is only supported in browser environment.");
38440            return [4, (r = new e(t)).start()];
38441
38442          case 1:
38443            return n.sent(), [2, r];
38444        }
38445      });
38446    });
38447  }, e.prototype.start = function () {
38448    return __awaiter(this, void 0, void 0, function () {
38449      var t, e, r, n;
38450      return __generator(this, function (i) {
38451        switch (i.label) {
38452          case 0:
38453            return i.trys.push([0, 2,, 3]), t = this, [4, navigator.mediaDevices.getUserMedia({
38454              audio: null == this.audioTrackConstraints || this.audioTrackConstraints,
38455              video: !1
38456            })];
38457
38458          case 1:
38459            return t.stream = i.sent(), [3, 3];
38460
38461          case 2:
38462            throw e = i.sent(), new Error("Error thrown while initializing video stream: " + e.message);
38463
38464          case 3:
38465            if (!this.stream) throw new Error("Could not obtain audio from microphone.");
38466
38467            if (r = window.AudioContext || window.webkitAudioContext, this.audioContext = new r(), this.sampleRateHz) {
38468              if (this.audioContext.sampleRate !== this.sampleRateHz) throw new Error("Mismatch in sampling rate: Expected: " + this.sampleRateHz + "; Actual: " + this.audioContext.sampleRate);
38469            } else this.sampleRateHz = this.audioContext.sampleRate;
38470
38471            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];
38472        }
38473      });
38474    });
38475  }, e.prototype.next = function () {
38476    return __awaiter(this, void 0, void 0, function () {
38477      var t, e, r, n, i;
38478      return __generator(this, function (o) {
38479        switch (o.label) {
38480          case 0:
38481            return this.isClosed ? [2, {
38482              value: null,
38483              done: !0
38484            }] : [4, this.getAudioData()];
38485
38486          case 1:
38487            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, {
38488              value: {
38489                spectrogram: t,
38490                waveform: e
38491              },
38492              done: !1
38493            }];
38494        }
38495      });
38496    });
38497  }, e.prototype.capture = function () {
38498    return __awaiter(this, void 0, void 0, function () {
38499      return __generator(this, function (t) {
38500        switch (t.label) {
38501          case 0:
38502            return [4, this.next()];
38503
38504          case 1:
38505            return [2, t.sent().value];
38506        }
38507      });
38508    });
38509  }, e.prototype.getAudioData = function () {
38510    return __awaiter(this, void 0, void 0, function () {
38511      var t,
38512          e,
38513          r,
38514          n = this;
38515      return __generator(this, function (i) {
38516        return t = [], e = [], r = 0, [2, new Promise(function (i) {
38517          var o = setInterval(function () {
38518            n.includeSpectrogram && (n.analyser.getFloatFrequencyData(n.freqData), n.freqData[0] === -1 / 0 && i({
38519              freqDataQueue: t,
38520              timeDataQueue: e
38521            }), 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({
38522              freqDataQueue: t,
38523              timeDataQueue: e
38524            }));
38525          }, n.fftSize / n.sampleRateHz * 1e3);
38526        })];
38527      });
38528    });
38529  }, e.prototype.stop = function () {
38530    this.isClosed || (this.isClosed = !0, this.analyser.disconnect(), this.audioContext.close(), null != this.stream && this.stream.getTracks().length > 0 && this.stream.getTracks()[0].stop());
38531  }, e.prototype.toArray = function () {
38532    throw new Error("Can not convert infinite audio stream to array.");
38533  }, e.prototype.getSampleRate = function () {
38534    return this.sampleRateHz;
38535  }, e.prototype.flattenQueue = function (t) {
38536    var e = t[0].length,
38537        r = new Float32Array(t.length * e);
38538    return t.forEach(function (t, n) {
38539      return r.set(t, n * e);
38540    }), r;
38541  }, e.prototype.getTensorFromAudioDataArray = function (t, e) {
38542    var r = new Float32Array(_tfjsCore.util.sizeFromShape(e));
38543    return r.set(t, r.length - t.length), (0, _tfjsCore.tensor)(r, e);
38544  }, e;
38545}(LazyIterator),
38546    WebcamIterator = function (t) {
38547  function e(e, r) {
38548    var n = t.call(this) || this;
38549    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 = (0, _tfjsCore.tensor1d)([0], "int32"), n.webcamConfig.centerCrop) {
38550      var i = 1 * n.webcamConfig.resizeWidth / n.webcamVideoElement.width,
38551          o = 1 * n.webcamConfig.resizeHeight / n.webcamVideoElement.height,
38552          a = (1 - i) / 2,
38553          s = (1 - o) / 2,
38554          u = a + i,
38555          c = o + s;
38556      n.cropBox = (0, _tfjsCore.tensor2d)([s, a, c, u], [1, 4]);
38557    } else n.cropBox = (0, _tfjsCore.tensor2d)([0, 0, 1, 1], [1, 4]);
38558    return n;
38559  }
38560
38561  return __extends(e, t), e.prototype.summary = function () {
38562    return "webcam";
38563  }, e.create = function (t, r) {
38564    return void 0 === r && (r = {}), __awaiter(this, void 0, void 0, function () {
38565      var n;
38566      return __generator(this, function (i) {
38567        switch (i.label) {
38568          case 0:
38569            if ((0, _tfjsCore.env)().get("IS_NODE")) throw new Error("tf.data.webcam is only supported in browser environment.");
38570
38571            if (!t) {
38572              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.");
38573              t.width = r.resizeWidth, t.height = r.resizeHeight;
38574            }
38575
38576            return [4, (n = new e(t, r)).start()];
38577
38578          case 1:
38579            return i.sent(), [2, n];
38580        }
38581      });
38582    });
38583  }, e.prototype.start = function () {
38584    return __awaiter(this, void 0, void 0, function () {
38585      var t,
38586          e,
38587          r = this;
38588      return __generator(this, function (n) {
38589        switch (n.label) {
38590          case 0:
38591            this.webcamConfig.facingMode && _tfjsCore.util.assert("user" === this.webcamConfig.facingMode || "environment" === this.webcamConfig.facingMode, function () {
38592              return "Invalid webcam facing mode: " + r.webcamConfig.facingMode + ". Please provide 'user' or 'environment'";
38593            }), n.label = 1;
38594
38595          case 1:
38596            return n.trys.push([1, 3,, 4]), t = this, [4, navigator.mediaDevices.getUserMedia({
38597              video: {
38598                deviceId: this.webcamConfig.deviceId,
38599                facingMode: this.webcamConfig.facingMode ? this.webcamConfig.facingMode : "user",
38600                width: this.webcamVideoElement.width,
38601                height: this.webcamVideoElement.height
38602              }
38603            })];
38604
38605          case 2:
38606            return t.stream = n.sent(), [3, 4];
38607
38608          case 3:
38609            throw (e = n.sent()).message = "Error thrown while initializing video stream: " + e.message, e;
38610
38611          case 4:
38612            if (!this.stream) throw new Error("Could not obtain video from webcam.");
38613
38614            try {
38615              this.webcamVideoElement.srcObject = this.stream;
38616            } catch (t) {
38617              console.log(t), this.webcamVideoElement.src = window.URL.createObjectURL(this.stream);
38618            }
38619
38620            return this.webcamVideoElement.play(), this.isClosed = !1, [2, new Promise(function (t) {
38621              r.webcamVideoElement.onloadedmetadata = function () {
38622                t();
38623              };
38624            })];
38625        }
38626      });
38627    });
38628  }, e.prototype.next = function () {
38629    return __awaiter(this, void 0, void 0, function () {
38630      var t;
38631      return __generator(this, function (e) {
38632        if (this.isClosed) return [2, {
38633          value: null,
38634          done: !0
38635        }];
38636
38637        try {
38638          t = _tfjsCore.browser.fromPixels(this.webcamVideoElement);
38639        } catch (t) {
38640          throw new Error("Error thrown converting video to pixels: " + JSON.stringify(t));
38641        }
38642
38643        if (!this.resize) return [2, {
38644          value: t,
38645          done: !1
38646        }];
38647
38648        try {
38649          return [2, {
38650            value: this.cropAndResizeFrame(t),
38651            done: !1
38652          }];
38653        } catch (t) {
38654          throw new Error("Error thrown cropping the video: " + t.message);
38655        } finally {
38656          t.dispose();
38657        }
38658
38659        return [2];
38660      });
38661    });
38662  }, e.prototype.needToResize = function () {
38663    return !(!this.webcamConfig.resizeWidth || !this.webcamConfig.resizeHeight || this.webcamVideoElement.width === this.webcamConfig.resizeWidth && this.webcamVideoElement.height === this.webcamConfig.resizeHeight);
38664  }, e.prototype.cropAndResizeFrame = function (t) {
38665    var e = this;
38666    return (0, _tfjsCore.tidy)(function () {
38667      var r,
38668          n = t.toFloat().expandDims(0),
38669          i = (r = _tfjsCore.image.cropAndResize(n, e.cropBox, e.cropBoxInd, e.cropSize, "bilinear")).shape;
38670
38671      return r.reshape(i.slice(1));
38672    });
38673  }, e.prototype.capture = function () {
38674    return __awaiter(this, void 0, void 0, function () {
38675      return __generator(this, function (t) {
38676        switch (t.label) {
38677          case 0:
38678            return [4, this.next()];
38679
38680          case 1:
38681            return [2, t.sent().value];
38682        }
38683      });
38684    });
38685  }, e.prototype.stop = function () {
38686    this.stream.getTracks().forEach(function (t) {
38687      return t.stop();
38688    });
38689
38690    try {
38691      this.webcamVideoElement.srcObject = null;
38692    } catch (t) {
38693      console.log(t), this.webcamVideoElement.src = null;
38694    }
38695
38696    this.isClosed = !0;
38697  }, e.prototype.toArray = function () {
38698    throw new Error("Can not convert infinite video stream to array.");
38699  }, e;
38700}(LazyIterator),
38701    DataSource = function () {
38702  return function () {};
38703}(),
38704    StringIterator = function (t) {
38705  function e() {
38706    return null !== t && t.apply(this, arguments) || this;
38707  }
38708
38709  return __extends(e, t), e.prototype.split = function (t) {
38710    return new SplitIterator(this, t);
38711  }, e;
38712}(LazyIterator),
38713    SplitIterator = function (t) {
38714  function e(e, r) {
38715    var n = t.call(this) || this;
38716    return n.upstream = e, n.impl = new SplitIteratorImpl(e, r), n;
38717  }
38718
38719  return __extends(e, t), e.prototype.summary = function () {
38720    return this.impl.summary();
38721  }, e.prototype.next = function () {
38722    return __awaiter(this, void 0, void 0, function () {
38723      return __generator(this, function (t) {
38724        return [2, this.impl.next()];
38725      });
38726    });
38727  }, e;
38728}(StringIterator),
38729    SplitIteratorImpl = function (t) {
38730  function e(e, r) {
38731    var n = t.call(this) || this;
38732    return n.upstream = e, n.separator = r, n.carryover = "", n;
38733  }
38734
38735  return __extends(e, t), e.prototype.summary = function () {
38736    return this.upstream.summary() + " -> Split('" + this.separator + "')";
38737  }, e.prototype.pump = function () {
38738    return __awaiter(this, void 0, void 0, function () {
38739      var t, e, r, n, i;
38740      return __generator(this, function (o) {
38741        switch (o.label) {
38742          case 0:
38743            return [4, this.upstream.next()];
38744
38745          case 1:
38746            if ((t = o.sent()).done) return "" === this.carryover ? [2, !1] : (this.outputQueue.push(this.carryover), this.carryover = "", [2, !0]);
38747
38748            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);
38749
38750            return this.carryover = e[e.length - 1], [2, !0];
38751        }
38752      });
38753    });
38754  }, e;
38755}(OneToManyIterator),
38756    ByteChunkIterator = function (t) {
38757  function e() {
38758    return null !== t && t.apply(this, arguments) || this;
38759  }
38760
38761  return __extends(e, t), e.prototype.decodeUTF8 = function () {
38762    return new Utf8Iterator(this);
38763  }, e;
38764}(LazyIterator),
38765    Utf8Iterator = function (t) {
38766  function e(e) {
38767    var r = t.call(this) || this;
38768    return r.upstream = e, r.impl = new Utf8IteratorImpl(e), r;
38769  }
38770
38771  return __extends(e, t), e.prototype.summary = function () {
38772    return this.impl.summary();
38773  }, e.prototype.next = function () {
38774    return __awaiter(this, void 0, void 0, function () {
38775      return __generator(this, function (t) {
38776        return [2, this.impl.next()];
38777      });
38778    });
38779  }, e;
38780}(StringIterator),
38781    Utf8IteratorImpl = function (t) {
38782  function e(e) {
38783    var r = t.call(this) || this;
38784    if (r.upstream = e, (0, _tfjsCore.env)().get("IS_BROWSER")) r.decoder = new TextDecoder("utf-8");else {
38785      var n = require("string_decoder").StringDecoder;
38786
38787      r.decoder = new n("utf8");
38788    }
38789    return r;
38790  }
38791
38792  return __extends(e, t), e.prototype.summary = function () {
38793    return this.upstream.summary() + " -> Utf8";
38794  }, e.prototype.pump = function () {
38795    return __awaiter(this, void 0, void 0, function () {
38796      var t, e, r;
38797      return __generator(this, function (n) {
38798        switch (n.label) {
38799          case 0:
38800            return [4, this.upstream.next()];
38801
38802          case 1:
38803            return (t = n.sent()).done ? [2, !1] : (e = t.value, r = (0, _tfjsCore.env)().get("IS_BROWSER") ? this.decoder.decode(e, {
38804              stream: !0
38805            }) : this.decoder.write(Buffer.from(e.buffer)), this.outputQueue.push(r), [2, !0]);
38806        }
38807      });
38808    });
38809  }, e;
38810}(OneToManyIterator),
38811    FileChunkIterator = function (t) {
38812  function e(e, r) {
38813    void 0 === r && (r = {});
38814    var n = t.call(this) || this;
38815    return n.file = e, n.options = r, _tfjsCore.util.assert(e instanceof Uint8Array || !!(0, _tfjsCore.env)().get("IS_BROW
38815SER") && (e instanceof File || e instanceof Blob), function () {
38816      return "FileChunkIterator only supports File, Blob and Uint8Array right now.";
38817    }), n.offset = r.offset || 0, n.chunkSize = r.chunkSize || 1048576, n;
38818  }
38819
38820  return __extends(e, t), e.prototype.summary = function () {
38821    return "FileChunks " + this.file;
38822  }, e.prototype.next = function () {
38823    return __awaiter(this, void 0, void 0, function () {
38824      var t,
38825          e,
38826          r = this;
38827      return __generator(this, function (n) {
38828        switch (n.label) {
38829          case 0:
38830            return this.offset >= (this.file instanceof Uint8Array ? this.file.byteLength : this.file.size) ? [2, {
38831              value: null,
38832              done: !0
38833            }] : (t = new Promise(function (t, e) {
38834              var n = r.offset + r.chunkSize;
38835              if (r.file instanceof Uint8Array) t(new Uint8Array(r.file.slice(r.offset, n)));else {
38836                var i = new FileReader();
38837                i.onload = function (r) {
38838                  var n = i.result;
38839                  if (n instanceof ArrayBuffer && (n = new Uint8Array(n)), !(n instanceof Uint8Array)) return e(new TypeError("FileReader returned unknown type."));
38840                  t(n);
38841                }, i.onabort = function (t) {
38842                  return e(new Error("Aborted"));
38843                }, i.onerror = function (t) {
38844                  return e(new Error(t.type));
38845                };
38846                var o = r.file.slice(r.offset, n);
38847                i.readAsArrayBuffer(o);
38848              }
38849              r.offset = n;
38850            }), e = {}, [4, t]);
38851
38852          case 1:
38853            return [2, (e.value = n.sent(), e.done = !1, e)];
38854        }
38855      });
38856    });
38857  }, e;
38858}(ByteChunkIterator);
38859
38860exports.CSVDataset = CSVDataset;
38861exports.TextLineDataset = TextLineDataset;
38862
38863function urlChunkIterator(t, e) {
38864  return void 0 === e && (e = {}), __awaiter(this, void 0, void 0, function () {
38865    var r, n, i, o, a;
38866    return __generator(this, function (s) {
38867      switch (s.label) {
38868        case 0:
38869          return "string" == typeof t ? r = t : (r = t.url, n = getRequestInitFromRequest(t)), [4, _tfjsCore.util.fetch(r, n)];
38870
38871        case 1:
38872          return (i = s.sent()).ok ? (a = Uint8Array.bind, [4, i.arrayBuffer()]) : [3, 3];
38873
38874        case 2:
38875          return o = new (a.apply(Uint8Array, [void 0, s.sent()]))(), [2, new FileChunkIterator(o, e)];
38876
38877        case 3:
38878          throw new Error(i.statusText);
38879      }
38880    });
38881  });
38882}
38883
38884var getRequestInitFromRequest = function (t) {
38885  return {
38886    method: t.method,
38887    headers: t.headers,
38888    body: t.body,
38889    mode: t.mode,
38890    credentials: t.credentials,
38891    cache: t.cache,
38892    redirect: t.redirect,
38893    referrer: t.referrer,
38894    integrity: t.integrity
38895  };
38896};
38897
38898function isLocalPath(t) {
38899  return "string" == typeof t && "file://" === t.substr(0, 7);
38900}
38901
38902var FileDataSource = function (t) {
38903  function e(e, r) {
38904    void 0 === r && (r = {});
38905    var n = t.call(this) || this;
38906    return n.input = e, n.options = r, n;
38907  }
38908
38909  return __extends(e, t), e.prototype.iterator = function () {
38910    return __awaiter(this, void 0, void 0, function () {
38911      var t;
38912      return __generator(this, function (e) {
38913        return isLocalPath(this.input) && (0, _tfjsCore.env)().get("IS_NODE") && (t = require("fs"), this.input = t.readFileSync(this.input.substr(7))), [2, new FileChunkIterator(this.input, this.options)];
38914      });
38915    });
38916  }, e;
38917}(DataSource),
38918    URLDataSource = function (t) {
38919  function e(e, r) {
38920    void 0 === r && (r = {});
38921    var n = t.call(this) || this;
38922    return n.url = e, n.fileOptions = r, n;
38923  }
38924
38925  return __extends(e, t), e.prototype.iterator = function () {
38926    return __awaiter(this, void 0, void 0, function () {
38927      return __generator(this, function (t) {
38928        return isLocalPath(this.url) ? [2, new FileDataSource(this.url, this.fileOptions).iterator()] : [2, urlChunkIterator(this.url, this.fileOptions)];
38929      });
38930    });
38931  }, e;
38932}(DataSource);
38933
38934exports.URLDataSource = URLDataSource;
38935exports.FileDataSource = FileDataSource;
38936
38937function csv(t, e) {
38938  return void 0 === e && (e = {}), new CSVDataset(new URLDataSource(t), e);
38939}
38940
38941function func(t) {
38942  var e = this,
38943      r = iteratorFromFunction(t);
38944  return datasetFromIteratorFn(function () {
38945    return __awaiter(e, void 0, void 0, function () {
38946      return __generator(this, function (t) {
38947        return [2, r];
38948      });
38949    });
38950  });
38951}
38952
38953function generator(t) {
38954  var e = this;
38955  return datasetFromIteratorFn(function () {
38956    return __awaiter(e, void 0, void 0, function () {
38957      var e;
38958      return __generator(this, function (r) {
38959        switch (r.label) {
38960          case 0:
38961            return [4, t()];
38962
38963          case 1:
38964            return e = r.sent(), [2, iteratorFromFunction(function () {
38965              return e.next();
38966            })];
38967        }
38968      });
38969    });
38970  });
38971}
38972
38973function webcam(t, e) {
38974  return __awaiter(this, void 0, void 0, function () {
38975    return __generator(this, function (r) {
38976      return [2, WebcamIterator.create(t, e)];
38977    });
38978  });
38979}
38980
38981function microphone(t) {
38982  return __awaiter(this, void 0, void 0, function () {
38983    return __generator(this, function (e) {
38984      return [2, MicrophoneIterator.create(t)];
38985    });
38986  });
38987}
38988
38989var version = "1.7.1";
38990exports.version_data = version;
38991},{"@tensorflow/tfjs-core":"node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js","crypto":"node_modules/parcel-bundler/src/builtins/_empty.js","string_decoder":"node_modules/parcel-bundler/src/builtins/_empty.js","fs":"node_modules/parcel-bundler/src/builtins/_empty.js","buffer":"node_modules/buffer/index.js"}],"node_modules/@tensorflow/tfjs/dist/tf.esm.js":[function(require,module,exports) {
38992"use strict";
38993
38994Object.defineProperty(exports, "__esModule", {
38995  value: true
38996});
38997var _exportNames = {
38998  version: true,
38999  data: true
39000};
39001exports.data = exports.version = void 0;
39002
39003var _tfjsCore = require("@tensorflow/tfjs-core");
39004
39005Object.keys(_tfjsCore).forEach(function (key) {
39006  if (key === "default" || key === "__esModule") return;
39007  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
39008  Object.defineProperty(exports, key, {
39009    enumerable: true,
39010    get: function () {
39011      return _tfjsCore[key];
39012    }
39013  });
39014});
39015
39016var _tfjsLayers = require("@tensorflow/tfjs-layers");
39017
39018Object.keys(_tfjsLayers).forEach(function (key) {
39019  if (key === "default" || key === "__esModule") return;
39020  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
39021  Object.defineProperty(exports, key, {
39022    enumerable: true,
39023    get: function () {
39024      return _tfjsLayers[key];
39025    }
39026  });
39027});
39028
39029var _tfjsConverter = require("@tensorflow/tfjs-converter");
39030
39031Object.keys(_tfjsConverter).forEach(function (key) {
39032  if (key === "default" || key === "__esModule") return;
39033  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
39034  Object.defineProperty(exports, key, {
39035    enumerable: true,
39036    get: function () {
39037      return _tfjsConverter[key];
39038    }
39039  });
39040});
39041
39042var tfjsData = _interopRequireWildcard(require("@tensorflow/tfjs-data"));
39043
39044exports.data = tfjsData;
39045
39046function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
39047
39048function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39049
39050// @tensorflow/tfjs Copyright 2020 Google
39051var version = "1.7.1",
39052    version$1 = {
39053  "tfjs-core": _tfjsCore.version_core,
39054  "tfjs-data": tfjsData.version_data,
39055  "tfjs-layers": _tfjsLayers.version_layers,
39056  "tfjs-converter": _tfjsConverter.version_converter,
39057  tfjs: version
39058};
39059exports.version = version$1;
39060},{"@tensorflow/tfjs-core":"node_modules/@tensorflow/tfjs-core/dist/tf-core.esm.js","@tensorflow/tfjs-layers":"node_modules/@tensorflow/tfjs-layers/dist/tf-layers.esm.js","@tensorflow/tfjs-converter":"node_modules/@tensorflow/tfjs-converter/dist/tf-converter.esm.js","@tensorflow/tfjs-data":"node_modules/@tensorflow/tfjs-data/dist/tf-data.esm.js"}],"node_modules/acorn/dist/acorn.mjs":[function(require,module,exports) {
39061"use strict";
39062
39063Object.defineProperty(exports, "__esModule", {
39064  value: true
39065});
39066exports.getLineInfo = getLineInfo;
39067exports.isIdentifierChar = isIdentifierChar;
39068exports.isIdentifierStart = isIdentifierStart;
39069exports.isNewLine = isNewLine;
39070exports.parse = parse;
39071exports.parseExpressionAt = parseExpressionAt;
39072exports.tokenizer = tokenizer;
39073exports.version = exports.tokTypes = exports.tokContexts = exports.nonASCIIwhitespace = exports.lineBreakG = exports.lineBreak = exports.keywordTypes = exports.defaultOptions = exports.TokenType = exports.Token = exports.TokContext = exports.SourceLocation = exports.Position = exports.Parser = exports.Node = void 0;
39074// Reserved word lists for various dialects of the language
39075var reservedWords = {
39076  3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
39077  5: "class enum extends super const export import",
39078  6: "enum",
39079  strict: "implements interface let package private protected public static yield",
39080  strictBind: "eval arguments"
39081}; // And the keywords
39082
39083var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
39084var keywords = {
39085  5: ecma5AndLessKeywords,
39086  "5module": ecma5AndLessKeywords + " export import",
39087  6: ecma5AndLessKeywords + " const class extends export import super"
39088};
39089var keywordRelationalOperator = /^in(stanceof)?$/; // ## Character categories
39090// Big ugly regular expressions that match characters in the
39091// whitespace, identifier, and identifier-start categories. These
39092// are only applied when a character is found to actually have a
39093// code point above 128.
39094// Generated by `bin/generate-identifier-regex.js`.
39095
39096var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u
3909619b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7c6\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab67\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
39097var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
39098var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
39099var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
39100nonASCIIidentifierStartChars = nonASCIIidentifierChars = null; // These are a run-length and offset encoded representation of the
39101// >0xffff code points that are a valid part of identifiers. The
39102// offset starts at 0x10000, and each pair of numbers represents an
39103// offset to the next range, and then a size of the range. They were
39104// generated by bin/generate-identifier-regex.js
39105// eslint-disable-next-line comma-spacing
39106
39107var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 477, 28, 11, 0, 9, 21, 155, 22, 13, 52, 76, 44, 33, 24, 27, 35, 30, 0, 12, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 0, 33, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 230, 43, 117, 63, 32, 0, 161, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 270, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 754, 9486, 286, 50, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42710, 42, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541]; // eslint-disable-next-line comma-spacing
39108
39109var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 525, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 4, 9, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 232, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 19723, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 792487, 239]; // This has a complexity linear to the value of the code. The
39110// assumption is that looking up astral identifier characters is
39111// rare.
39112
39113function isInAstralSet(code, set) {
39114  var pos = 0x10000;
39115
39116  for (var i = 0; i < set.length; i += 2) {
39117    pos += set[i];
39118
39119    if (pos > code) {
39120      return false;
39121    }
39122
39123    pos += set[i + 1];
39124
39125    if (pos >= code) {
39126      return true;
39127    }
39128  }
39129} // Test whether a given character code starts an identifier.
39130
39131
39132function isIdentifierStart(code, astral) {
39133  if (code < 65) {
39134    return code === 36;
39135  }
39136
39137  if (code < 91) {
39138    return true;
39139  }
39140
39141  if (code < 97) {
39142    return code === 95;
39143  }
39144
39145  if (code < 123) {
39146    return true;
39147  }
39148
39149  if (code <= 0xffff) {
39150    return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
39151  }
39152
39153  if (astral === false) {
39154    return false;
39155  }
39156
39157  return isInAstralSet(code, astralIdentifierStartCodes);
39158} // Test whether a given character is part of an identifier.
39159
39160
39161function isIdentifierChar(code, astral) {
39162  if (code < 48) {
39163    return code === 36;
39164  }
39165
39166  if (code < 58) {
39167    return true;
39168  }
39169
39170  if (code < 65) {
39171    return false;
39172  }
39173
39174  if (code < 91) {
39175    return true;
39176  }
39177
39178  if (code < 97) {
39179    return code === 95;
39180  }
39181
39182  if (code < 123) {
39183    return true;
39184  }
39185
39186  if (code <= 0xffff) {
39187    return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
39188  }
39189
39190  if (astral === false) {
39191    return false;
39192  }
39193
39194  return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
39195} // ## Token types
39196// The assignment of fine-grained, information-carrying type objects
39197// allows the tokenizer to store the information it has about a
39198// token in a way that is very cheap for the parser to look up.
39199// All token type variables start with an underscore, to make them
39200// easy to recognize.
39201// The `beforeExpr` property is used to disambiguate between regular
39202// expressions and divisions. It is set on all token types that can
39203// be followed by an expression (thus, a slash after them would be a
39204// regular expression).
39205//
39206// The `startsExpr` property is used to check if the token ends a
39207// `yield` expression. It is set on all token types that either can
39208// directly start an expression (like a quotation mark) or can
39209// continue an expression (like the body of a string).
39210//
39211// `isLoop` marks a keyword as starting a loop, which is important
39212// to know when parsing a label, in order to allow or disallow
39213// continue jumps to that label.
39214
39215
39216var TokenType = function TokenType(label, conf) {
39217  if (conf === void 0) conf = {};
39218  this.label = label;
39219  this.keyword = conf.keyword;
39220  this.beforeExpr = !!conf.beforeExpr;
39221  this.startsExpr = !!conf.startsExpr;
39222  this.isLoop = !!conf.isLoop;
39223  this.isAssign = !!conf.isAssign;
39224  this.prefix = !!conf.prefix;
39225  this.postfix = !!conf.postfix;
39226  this.binop = conf.binop || null;
39227  this.updateContext = null;
39228};
39229
39230exports.TokenType = TokenType;
39231
39232function binop(name, prec) {
39233  return new TokenType(name, {
39234    beforeExpr: true,
39235    binop: prec
39236  });
39237}
39238
39239var beforeExpr = {
vendor: 2,933 bytes, lines 39240-39344
39240  beforeExpr: true
39241},
39242    startsExpr = {
39243  startsExpr: true
39244}; // Map keyword names to token types.
39245
39246var keywords$1 = {}; // Succinct definitions of keyword token types
39247
39248exports.keywordTypes = keywords$1;
39249
39250function kw(name, options) {
39251  if (options === void 0) options = {};
39252  options.keyword = name;
39253  return keywords$1[name] = new TokenType(name, options);
39254}
39255
39256var types = {
39257  num: new TokenType("num", startsExpr),
39258  regexp: new TokenType("regexp", startsExpr),
39259  string: new TokenType("string", startsExpr),
39260  name: new TokenType("name", startsExpr),
39261  eof: new TokenType("eof"),
39262  // Punctuation token types.
39263  bracketL: new TokenType("[", {
39264    beforeExpr: true,
39265    startsExpr: true
39266  }),
39267  bracketR: new TokenType("]"),
39268  braceL: new TokenType("{", {
39269    beforeExpr: true,
39270    startsExpr: true
39271  }),
39272  braceR: new TokenType("}"),
39273  parenL: new TokenType("(", {
39274    beforeExpr: true,
39275    startsExpr: true
39276  }),
39277  parenR: new TokenType(")"),
39278  comma: new TokenType(",", beforeExpr),
39279  semi: new TokenType(";", beforeExpr),
39280  colon: new TokenType(":", beforeExpr),
39281  dot: new TokenType("."),
39282  question: new TokenType("?", beforeExpr),
39283  arrow: new TokenType("=>", beforeExpr),
39284  template: new TokenType("template"),
39285  invalidTemplate: new TokenType("invalidTemplate"),
39286  ellipsis: new TokenType("...", beforeExpr),
39287  backQuote: new TokenType("`", startsExpr),
39288  dollarBraceL: new TokenType("${", {
39289    beforeExpr: true,
39290    startsExpr: true
39291  }),
39292  // Operators. These carry several kinds of properties to help the
39293  // parser use them properly (the presence of these properties is
39294  // what categorizes them as operators).
39295  //
39296  // `binop`, when present, specifies that this operator is a binary
39297  // operator, and will refer to its precedence.
39298  //
39299  // `prefix` and `postfix` mark the operator as a prefix or postfix
39300  // unary operator.
39301  //
39302  // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
39303  // binary operators with a very low precedence, that should result
39304  // in AssignmentExpression nodes.
39305  eq: new TokenType("=", {
39306    beforeExpr: true,
39307    isAssign: true
39308  }),
39309  assign: new TokenType("_=", {
39310    beforeExpr: true,
39311    isAssign: true
39312  }),
39313  incDec: new TokenType("++/--", {
39314    prefix: true,
39315    postfix: true,
39316    startsExpr: true
39317  }),
39318  prefix: new TokenType("!/~", {
39319    beforeExpr: true,
39320    prefix: true,
39321    startsExpr: true
39322  }),
39323  logicalOR: binop("||", 1),
39324  logicalAND: binop("&&", 2),
39325  bitwiseOR: binop("|", 3),
39326  bitwiseXOR: binop("^", 4),
39327  bitwiseAND: binop("&", 5),
39328  equality: binop("==/!=/===/!==", 6),
39329  relational: binop("</>/<=/>=", 7),
39330  bitShift: binop("<</>>/>>>", 8),
39331  plusMin: new TokenType("+/-", {
39332    beforeExpr: true,
39333    binop: 9,
39334    prefix: true,
39335    startsExpr: true
39336  }),
39337  modulo: binop("%", 10),
39338  star: binop("*", 10),
39339  slash: binop("/", 10),
39340  starstar: new TokenType("**", {
39341    beforeExpr: true
39342  }),
39343  // Keyword token types.
39344  _break: kw("break"),
39345  _case: kw("case", beforeExpr),
39346  _catch: kw("catch"),
39347  _continue: kw("continue"),
39348  _debugger: kw("debugger"),
39349  _default: kw("default", beforeExpr),
39350  _do: kw("do", {
39351    isLoop: true,
39352    beforeExpr: true
39353  }),
39354  _else: kw("else", beforeExpr),
39355  _finally: kw("finally"),
39356  _for: kw("for", {
39357    isLoop: true
39358  }),
39359  _function: kw("function", startsExpr),
39360  _if: kw("if"),
39361  _return: kw("return", beforeExpr),
39362  _switch: kw("switch"),
39363  _throw: kw("throw", beforeExpr),
39364  _try: kw("try"),
39365  _var: kw("var"),
39366  _const: kw("const"),
39367  _while: kw("while", {
39368    isLoop: true
39369  }),
39370  _with: kw("with"),
39371  _new: kw("new", {
39372    beforeExpr: true,
39373    startsExpr: true
39374  }),
39375  _this: kw("this", startsExpr),
39376  _super: kw("super", startsExpr),
39377  _class: kw("class", startsExpr),
39378  _extends: kw("extends", beforeExpr),
39379  _export: kw("export"),
39380  _import: kw("import", startsExpr),
39381  _null: kw("null", startsExpr),
39382  _true: kw("true", startsExpr),
39383  _false: kw("false", startsExpr),
39384  _in: kw("in", {
39385    beforeExpr: true,
39386    binop: 7
39387  }),
39388  _instanceof: kw("instanceof", {
39389    beforeExpr: true,
39390    binop: 7
39391  }),
39392  _typeof: kw("typeof", {
39393    beforeExpr: true,
39394    prefix: true,
39395    startsExpr: true
39396  }),
39397  _void: kw("void", {
39398    beforeExpr: true,
39399    prefix: true,
39400    startsExpr: true
39401  }),
39402  _delete: kw("delete", {
39403    beforeExpr: true,
39404    prefix: true,
39405    startsExpr: true
39406  })
39407}; // Matches a whole line break (where CRLF is considered a single
39408// line break). Used to count lines.
39409
39410exports.tokTypes = types;
39411var lineBreak = /\r\n?|\n|\u2028|\u2029/;
39412exports.lineBreak = lineBreak;
39413var lineBreakG = new RegExp(lineBreak.source, "g");
39414exports.lineBreakG = lineBreakG;
39415
39416function isNewLine(code, ecma2019String) {
39417  return code === 10 || code === 13 || !ecma2019String && (code === 0x2028 || code === 0x2029);
39418}
39419
39420var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
39421exports.nonASCIIwhitespace = nonASCIIwhitespace;
39422var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
39423var ref = Object.prototype;
39424var hasOwnProperty = ref.hasOwnProperty;
39425var toString = ref.toString; // Checks if an object has a property.
39426
39427function has(obj, propName) {
39428  return hasOwnProperty.call(obj, propName);
39429}
39430
39431var isArray = Array.isArray || function (obj) {
39432  return toString.call(obj) === "[object Array]";
39433};
39434
39435function wordsRegexp(words) {
39436  return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$");
39437} // These are used when `options.locations` is on, for the
39438// `startLoc` and `endLoc` properties.
39439
39440
39441var Position = function Position(line, col) {
39442  this.line = line;
39443  this.column = col;
39444};
39445
39446exports.Position = Position;
39447
39448Position.prototype.offset = function offset(n) {
39449  return new Position(this.line, this.column + n);
39450};
39451
39452var SourceLocation = function SourceLocation(p, start, end) {
39453  this.start = start;
39454  this.end = end;
39455
39456  if (p.sourceFile !== null) {
39457    this.source = p.sourceFile;
39458  }
39459}; // The `getLineInfo` function is mostly useful when the
39460// `locations` option is off (for performance reasons) and you
39461// want to find the line/column position for a given character
39462// offset. `input` should be the code string that the offset refers
39463// into.
39464
39465
39466exports.SourceLocation = SourceLocation;
39467
39468function getLineInfo(input, offset) {
39469  for (var line = 1, cur = 0;;) {
39470    lineBreakG.lastIndex = cur;
39471    var match = lineBreakG.exec(input);
39472
39473    if (match && match.index < offset) {
39474      ++line;
39475      cur = match.index + match[0].length;
39476    } else {
39477      return new Position(line, offset - cur);
39478    }
39479  }
39480} // A second optional argument can be given to further configure
39481// the parser process. These options are recognized:
39482
39483
39484var defaultOptions = {
39485  // `ecmaVersion` indicates the ECMAScript version to parse. Must be
39486  // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10
39487  // (2019). This influences support for strict mode, the set of
39488  // reserved words, and support for new syntax features. The default
39489  // is 9.
39490  ecmaVersion: 9,
39491  // `sourceType` indicates the mode the code should be parsed in.
39492  // Can be either `"script"` or `"module"`. This influences global
39493  // strict mode and parsing of `import` and `export` declarations.
39494  sourceType: "script",
39495  // `onInsertedSemicolon` can be a callback that will be called
39496  // when a semicolon is automatically inserted. It will be passed
39497  // the position of the comma as an offset, and if `locations` is
39498  // enabled, it is given the location as a `{line, column}` object
39499  // as second argument.
39500  onInsertedSemicolon: null,
39501  // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
39502  // trailing commas.
39503  onTrailingComma: null,
39504  // By default, reserved words are only enforced if ecmaVersion >= 5.
39505  // Set `allowReserved` to a boolean value to explicitly turn this on
39506  // an off. When this option has the value "never", reserved words
39507  // and keywords can also not be used as property names.
39508  allowReserved: null,
39509  // When enabled, a return at the top level is not considered an
39510  // error.
39511  allowReturnOutsideFunction: false,
39512  // When enabled, import/export statements are not constrained to
39513  // appearing at the top of the program.
39514  allowImportExportEverywhere: false,
39515  // When enabled, await identifiers are allowed to appear at the top-level scope,
39516  // but they are still not allowed in non-async functions.
39517  allowAwaitOutsideFunction: false,
39518  // When enabled, hashbang directive in the beginning of file
39519  // is allowed and treated as a line comment.
39520  allowHashBang: false,
39521  // When `locations` is on, `loc` properties holding objects with
39522  // `start` and `end` properties in `{line, column}` form (with
39523  // line being 1-based and column 0-based) will be attached to the
39524  // nodes.
39525  locations: false,
39526  // A function can be passed as `onToken` option, which will
39527  // cause Acorn to call that function with object in the same
39528  // format as tokens returned from `tokenizer().getToken()`. Note
39529  // that you are not allowed to call the parser from the
39530  // callback—that will corrupt its internal state.
39531  onToken: null,
39532  // A function can be passed as `onComment` option, which will
39533  // cause Acorn to call that function with `(block, text, start,
39534  // end)` parameters whenever a comment is skipped. `block` is a
39535  // boolean indicating whether this is a block (`/* */`) comment,
39536  // `text` is the content of the comment, and `start` and `end` are
39537  // character offsets that denote the start and end of the comment.
39538  // When the `locations` option is on, two more parameters are
39539  // passed, the full `{line, column}` locations of the start and
39540  // end of the comments. Note that you are not allowed to call the
39541  // parser from the callback—that will corrupt its internal state.
39542  onComment: null,
39543  // Nodes have their start and end characters offsets recorded in
39544  // `start` and `end` properties (directly on the node, rather than
39545  // the `loc` object, which holds line/column data. To also add a
39546  // [semi-standardized][range] `range` property holding a `[start,
39547  // end]` array with the same numbers, set the `ranges` option to
39548  // `true`.
39549  //
39550  // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
39551  ranges: false,
39552  // It is possible to parse multiple files into a single AST by
39553  // passing the tree produced by parsing the first file as
39554  // `program` option in subsequent parses. This will add the
39555  // toplevel forms of the parsed file to the `Program` (top) node
39556  // of an existing parse tree.
39557  program: null,
39558  // When `locations` is on, you can pass this to record the source
39559  // file in every node's `loc` object.
39560  sourceFile: null,
39561  // This value, if given, is stored in every node, whether
39562  // `locations` is on or off.
39563  directSourceFile: null,
39564  // When enabled, parenthesized expressions are represented by
39565  // (non-standard) ParenthesizedExpression nodes
39566  preserveParens: false
39567}; // Interpret and default an options object
39568
39569exports.defaultOptions = defaultOptions;
39570
39571function getOptions(opts) {
39572  var options = {};
39573
39574  for (var opt in defaultOptions) {
39575    options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt];
39576  }
39577
39578  if (options.ecmaVersion >= 2015) {
39579    options.ecmaVersion -= 2009;
39580  }
39581
39582  if (options.allowReserved == null) {
39583    options.allowReserved = options.ecmaVersion < 5;
39584  }
39585
39586  if (isArray(options.onToken)) {
39587    var tokens = options.onToken;
39588
39589    options.onToken = function (token) {
39590      return tokens.push(token);
39591    };
39592  }
39593
39594  if (isArray(options.onComment)) {
39595    options.onComment = pushComment(options, options.onComment);
39596  }
39597
39598  return options;
39599}
39600
39601function pushComment(options, array) {
39602  return function (block, text, start, end, startLoc, endLoc) {
39603    var comment = {
39604      type: block ? "Block" : "Line",
39605      value: text,
39606      start: start,
39607      end: end
39608    };
39609
39610    if (options.locations) {
39611      comment.loc = new SourceLocation(this, startLoc, endLoc);
39612    }
39613
39614    if (options.ranges) {
39615      comment.range = [start, end];
39616    }
39617
39618    array.push(comment);
39619  };
39620} // Each scope gets a bitset that may contain these flags
39621
39622
39623var SCOPE_TOP = 1,
39624    SCOPE_FUNCTION = 2,
39625    SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION,
39626    SCOPE_ASYNC = 4,
39627    SCOPE_GENERATOR = 8,
39628    SCOPE_ARROW = 16,
39629    SCOPE_SIMPLE_CATCH = 32,
39630    SCOPE_SUPER = 64,
39631    SCOPE_DIRECT_SUPER = 128;
39632
39633function functionFlags(async, generator) {
39634  return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0);
39635} // Used in checkLVal and declareName to determine the type of a binding
39636
39637
39638var BIND_NONE = 0,
39639    // Not a binding
39640BIND_VAR = 1,
39641    // Var-style binding
39642BIND_LEXICAL = 2,
39643    // Let- or const-style binding
39644BIND_FUNCTION = 3,
39645    // Function declaration
39646BIND_SIMPLE_CATCH = 4,
39647    // Simple (identifier pattern) catch binding
39648BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
39649
39650var Parser = function Parser(options, input, startPos) {
39651  this.options = options = getOptions(options);
39652  this.sourceFile = options.sourceFile;
39653  this.keywords = wordsRegexp(keywords[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
39654  var reserved = "";
39655
39656  if (options.allowReserved !== true) {
39657    for (var v = options.ecmaVersion;; v--) {
39658      if (reserved = reservedWords[v]) {
39659        break;
39660      }
39661    }
39662
39663    if (options.sourceType === "module") {
39664      reserved += " await";
39665    }
39666  }
39667
39668  this.reservedWords = wordsRegexp(reserved);
39669  var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
39670  this.reservedWordsStrict = wordsRegexp(reservedStrict);
39671  this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
39672  this.input = String(input); // Used to signal to callers of `readWord1` whether the word
39673  // contained any escape sequences. This is needed because words with
39674  // escape sequences must not be interpreted as keywords.
39675
39676  this.containsEsc = false; // Set up token state
39677  // The current position of the tokenizer in the input.
39678
39679  if (startPos) {
39680    this.pos = startPos;
39681    this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
39682    this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
39683  } else {
39684    this.pos = this.lineStart = 0;
39685    this.curLine = 1;
39686  } // Properties of the current token:
39687  // Its type
39688
39689
39690  this.type = types.eof; // For tokens that include more information than their type, the value
39691
39692  this.value = null; // Its start and end offset
39693
39694  this.start = this.end = this.pos; // And, if locations are used, the {line, column} object
39695  // corresponding to those offsets
39696
39697  this.startLoc = this.endLoc = this.curPosition(); // Position information for the previous token
39698
39699  this.lastTokEndLoc = this.lastTokStartLoc = null;
39700  this.lastTokStart = this.lastTokEnd = this.pos; // The context stack is used to superficially track syntactic
39701  // context to predict whether a regular expression is allowed in a
39702  // given position.
39703
39704  this.context = this.initialContext();
39705  this.exprAllowed = true; // Figure out if it's a module code.
39706
39707  this.inModule = options.sourceType === "module";
39708  this.strict = this.inModule || this.strictDirective(this.pos); // Used to signify the start of a potential arrow function
39709
39710  this.potentialArrowAt = -1; // Positions to delayed-check that yield/await does not exist in default parameters.
39711
39712  this.yieldPos = this.awaitPos = this.awaitIdentPos = 0; // Labels in scope.
39713
39714  this.labels = []; // Thus-far undefined exports.
39715
39716  this.undefinedExports = {}; // If enabled, skip leading hashbang line.
39717
39718  if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!") {
39719    this.skipLineComment(2);
39720  } // Scope tracking for duplicate variable names (see scope.js)
39721
39722
39723  this.scopeStack = [];
39724  this.enterScope(SCOPE_TOP); // For RegExp validation
39725
39726  this.regexpState = null;
39727};
39728
39729exports.Parser = Parser;
39730var prototypeAccessors = {
39731  inFunction: {
39732    configurable: true
39733  },
39734  inGenerator: {
39735    configurable: true
39736  },
39737  inAsync: {
39738    configurable: true
39739  },
39740  allowSuper: {
39741    configurable: true
39742  },
39743  allowDirectSuper: {
39744    configurable: true
39745  },
39746  treatFunctionsAsVar: {
39747    configurable: true
39748  }
39749};
39750
39751Parser.prototype.parse = function parse() {
39752  var node = this.options.program || this.startNode();
39753  this.nextToken();
39754  return this.parseTopLevel(node);
39755};
39756
39757prototypeAccessors.inFunction.get = function () {
39758  return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
39759};
39760
39761prototypeAccessors.inGenerator.get = function () {
39762  return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0;
39763};
39764
39765prototypeAccessors.inAsync.get = function () {
39766  return (this.currentVarScope().flags & SCOPE_ASYNC) > 0;
39767};
39768
39769prototypeAccessors.allowSuper.get = function () {
39770  return (this.currentThisScope().flags & SCOPE_SUPER) > 0;
39771};
39772
39773prototypeAccessors.allowDirectSuper.get = function () {
39774  return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;
39775};
39776
39777prototypeAccessors.treatFunctionsAsVar.get = function () {
39778  return this.treatFunctionsAsVarInScope(this.currentScope());
39779}; // Switch to a getter for 7.0.0.
39780
39781
39782Parser.prototype.inNonArrowFunction = function inNonArrowFunction() {
39783  return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0;
39784};
39785
39786Parser.extend = function extend() {
39787  var plugins = [],
39788      len = arguments.length;
39789
39790  while (len--) plugins[len] = arguments[len];
39791
39792  var cls = this;
39793
39794  for (var i = 0; i < plugins.length; i++) {
39795    cls = plugins[i](cls);
39796  }
39797
39798  return cls;
39799};
39800
39801Parser.parse = function parse(input, options) {
39802  return new this(options, input).parse();
39803};
39804
39805Parser.parseExpressionAt = function parseExpressionAt(input, pos, options) {
39806  var parser = new this(options, input, pos);
39807  parser.nextToken();
39808  return parser.parseExpression();
39809};
39810
39811Parser.tokenizer = function tokenizer(input, options) {
39812  return new this(options, input);
39813};
39814
39815Object.defineProperties(Parser.prototype, prototypeAccessors);
39816var pp = Parser.prototype; // ## Parser utilities
39817
39818var literal = /^(?:'((?:\\.|[^'])*?)'|"((?:\\.|[^"])*?)")/;
39819
39820pp.strictDirective = function (start) {
39821  for (;;) {
39822    // Try to find string literal.
39823    skipWhiteSpace.lastIndex = start;
39824    start += skipWhiteSpace.exec(this.input)[0].length;
39825    var match = literal.exec(this.input.slice(start));
39826
39827    if (!match) {
39828      return false;
39829    }
39830
39831    if ((match[1] || match[2]) === "use strict") {
39832      return true;
39833    }
39834
39835    start += match[0].length; // Skip semicolon, if any.
39836
39837    skipWhiteSpace.lastIndex = start;
39838    start += skipWhiteSpace.exec(this.input)[0].length;
39839
39840    if (this.input[start] === ";") {
39841      start++;
39842    }
39843  }
39844}; // Predicate that tests whether the next token is of the given
39845// type, and if yes, consumes it as a side effect.
39846
39847
39848pp.eat = function (type) {
39849  if (this.type === type) {
39850    this.next();
39851    return true;
39852  } else {
39853    return false;
39854  }
39855}; // Tests whether parsed token is a contextual keyword.
39856
39857
39858pp.isContextual = function (name) {
39859  return this.type === types.name && this.value === name && !this.containsEsc;
39860}; // Consumes contextual keyword if possible.
39861
39862
39863pp.eatContextual = function (name) {
39864  if (!this.isContextual(name)) {
39865    return false;
39866  }
39867
39868  this.next();
39869  return true;
39870}; // Asserts that following token is given contextual keyword.
39871
39872
39873pp.expectContextual = function (name) {
39874  if (!this.eatContextual(name)) {
39875    this.unexpected();
39876  }
39877}; // Test whether a semicolon can be inserted at the current position.
39878
39879
39880pp.canInsertSemicolon = function () {
39881  return this.type === types.eof || this.type === types.braceR || lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
39882};
39883
39884pp.insertSemicolon = function () {
39885  if (this.canInsertSemicolon()) {
39886    if (this.options.onInsertedSemicolon) {
39887      this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc);
39888    }
39889
39890    return true;
39891  }
39892}; // Consume a semicolon, or, failing that, see if we are allowed to
39893// pretend that there is a semicolon at this position.
39894
39895
39896pp.semicolon = function () {
39897  if (!this.eat(types.semi) && !this.insertSemicolon()) {
39898    this.unexpected();
39899  }
39900};
39901
39902pp.afterTrailingComma = function (tokType, notNext) {
39903  if (this.type === tokType) {
39904    if (this.options.onTrailingComma) {
39905      this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc);
39906    }
39907
39908    if (!notNext) {
39909      this.next();
39910    }
39911
39912    return true;
39913  }
39914}; // Expect a token of a given type. If found, consume it, otherwise,
39915// raise an unexpected token error.
39916
39917
39918pp.expect = function (type) {
39919  this.eat(type) || this.unexpected();
39920}; // Raise an unexpected token error.
39921
39922
39923pp.unexpected = function (pos) {
39924  this.raise(pos != null ? pos : this.start, "Unexpected token");
39925};
39926
39927function DestructuringErrors() {
39928  this.shorthandAssign = this.trailingComma = this.parenthesizedAssign = this.parenthesizedBind = this.doubleProto = -1;
39929}
39930
39931pp.checkPatternErrors = function (refDestructuringErrors, isAssign) {
39932  if (!refDestructuringErrors) {
39933    return;
39934  }
39935
39936  if (refDestructuringErrors.trailingComma > -1) {
39937    this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element");
39938  }
39939
39940  var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
39941
39942  if (parens > -1) {
39943    this.raiseRecoverable(parens, "Parenthesized pattern");
39944  }
39945};
39946
39947pp.checkExpressionErrors = function (refDestructuringErrors, andThrow) {
39948  if (!refDestructuringErrors) {
39949    return false;
39950  }
39951
39952  var shorthandAssign = refDestructuringErrors.shorthandAssign;
39953  var doubleProto = refDestructuringErrors.doubleProto;
39954
39955  if (!andThrow) {
39956    return shorthandAssign >= 0 || doubleProto >= 0;
39957  }
39958
39959  if (shorthandAssign >= 0) {
39960    this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns");
39961  }
39962
39963  if (doubleProto >= 0) {
39964    this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property");
39965  }
39966};
39967
39968pp.checkYieldAwaitInDefaultParams = function () {
39969  if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) {
39970    this.raise(this.yieldPos, "Yield expression cannot be a default value");
39971  }
39972
39973  if (this.awaitPos) {
39974    this.raise(this.awaitPos, "Await expression cannot be a default value");
39975  }
39976};
39977
39978pp.isSimpleAssignTarget = function (expr) {
39979  if (expr.type === "ParenthesizedExpression") {
39980    return this.isSimpleAssignTarget(expr.expression);
39981  }
39982
39983  return expr.type === "Identifier" || expr.type === "MemberExpression";
39984};
39985
39986var pp$1 = Parser.prototype; // ### Statement parsing
39987// Parse a program. Initializes the parser, reads any number of
39988// statements, and wraps them in a Program node.  Optionally takes a
39989// `program` argument.  If present, the statements will be appended
39990// to its body instead of creating a new node.
39991
39992pp$1.parseTopLevel = function (node) {
39993  var exports = {};
39994
39995  if (!node.body) {
39996    node.body = [];
39997  }
39998
39999  while (this.type !== types.eof) {
40000    var stmt = this.parseStatement(null, true, exports);
40001    node.body.push(stmt);
40002  }
40003
40004  if (this.inModule) {
40005    for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1) {
40006      var name = list[i];
40007      this.raiseRecoverable(this.undefinedExports[name].start, "Export '" + name + "' is not defined");
40008    }
40009  }
40010
40011  this.adaptDirectivePrologue(node.body);
40012  this.next();
40013  node.sourceType = this.options.sourceType;
40014  return this.finishNode(node, "Program");
40015};
40016
40017var loopLabel = {
40018  kind: "loop"
40019},
40020    switchLabel = {
40021  kind: "switch"
40022};
40023
40024pp$1.isLet = function (context) {
40025  if (this.options.ecmaVersion < 6 || !this.isContextual("let")) {
40026    return false;
40027  }
40028
40029  skipWhiteSpace.lastIndex = this.pos;
40030  var skip = skipWhiteSpace.exec(this.input);
40031  var next = this.pos + skip[0].length,
40032      nextCh = this.input.charCodeAt(next); // For ambiguous cases, determine if a LexicalDeclaration (or only a
40033  // Statement) is allowed here. If context is not empty then only a Statement
40034  // is allowed. However, `let [` is an explicit negative lookahead for
40035  // ExpressionStatement, so special-case it first.
40036
40037  if (nextCh === 91) {
40038    return true;
40039  } // '['
40040
40041
40042  if (context) {
40043    return false;
40044  }
40045
40046  if (nextCh === 123) {
40047    return true;
40048  } // '{'
40049
40050
40051  if (isIdentifierStart(nextCh, true)) {
40052    var pos = next + 1;
40053
40054    while (isIdentifierChar(this.input.charCodeAt(pos), true)) {
40055      ++pos;
40056    }
40057
40058    var ident = this.input.slice(next, pos);
40059
40060    if (!keywordRelationalOperator.test(ident)) {
40061      return true;
40062    }
40063  }
40064
40065  return false;
40066}; // check 'async [no LineTerminator here] function'
40067// - 'async /*foo*/ function' is OK.
40068// - 'async /*\n*/ function' is invalid.
40069
40070
40071pp$1.isAsyncFunction = function () {
40072  if (this.options.ecmaVersion < 8 || !this.isContextual("async")) {
40073    return false;
40074  }
40075
40076  skipWhiteSpace.lastIndex = this.pos;
40077  var skip = skipWhiteSpace.exec(this.input);
40078  var next = this.pos + skip[0].length;
40079  return !lineBreak.test(this.input.slice(this.pos, next)) && this.input.slice(next, next + 8) === "function" && (next + 8 === this.input.length || !isIdentifierChar(this.input.charAt(next + 8)));
40080}; // Parse a single statement.
40081//
40082// If expecting a statement and finding a slash operator, parse a
40083// regular expression literal. This is to handle cases like
40084// `if (foo) /blah/.exec(foo)`, where looking at the previous token
40085// does not help.
40086
40087
40088pp$1.parseStatement = function (context, topLevel, exports) {
40089  var starttype = this.type,
40090      node = this.startNode(),
40091      kind;
40092
40093  if (this.isLet(context)) {
40094    starttype = types._var;
40095    kind = "let";
40096  } // Most types of statements are recognized by the keyword they
40097  // start with. Many are trivial to parse, some require a bit of
40098  // complexity.
40099
40100
40101  switch (starttype) {
40102    case types._break:
40103    case types._continue:
40104      return this.parseBreakContinueStatement(node, starttype.keyword);
40105
40106    case types._debugger:
40107      return this.parseDebuggerStatement(node);
40108
40109    case types._do:
40110      return this.parseDoStatement(node);
40111
40112    case types._for:
40113      return this.parseForStatement(node);
40114
40115    case types._function:
40116      // Function as sole body of either an if statement or a labeled statement
40117      // works, but not when it is part of a labeled statement that is the sole
40118      // body of an if statement.
40119      if (context && (this.strict || context !== "if" && context !== "label") && this.options.ecmaVersion >= 6) {
40120        this.unexpected();
40121      }
40122
40123      return this.parseFunctionStatement(node, false, !context);
40124
40125    case types._class:
40126      if (context) {
40127        this.unexpected();
40128      }
40129
40130      return this.parseClass(node, true);
40131
40132    case types._if:
40133      return this.parseIfStatement(node);
40134
40135    case types._return:
40136      return this.parseReturnStatement(node);
40137
40138    case types._switch:
40139      return this.parseSwitchStatement(node);
40140
40141    case types._throw:
40142      return this.parseThrowStatement(node);
40143
40144    case types._try:
40145      return this.parseTryStatement(node);
40146
40147    case types._const:
40148    case types._var:
40149      kind = kind || this.value;
40150
40151      if (context && kind !== "var") {
40152        this.unexpected();
40153      }
40154
40155      return this.parseVarStatement(node, kind);
40156
40157    case types._while:
40158      return this.parseWhileStatement(node);
40159
40160    case types._with:
40161      return this.parseWithStatement(node);
40162
40163    case types.braceL:
40164      return this.parseBlock(true, node);
40165
40166    case types.semi:
40167      return this.parseEmptyStatement(node);
40168
40169    case types._export:
40170    case types._import:
40171      if (this.options.ecmaVersion > 10 && starttype === types._import) {
40172        skipWhiteSpace.lastIndex = this.pos;
40173        var skip = skipWhiteSpace.exec(this.input);
40174        var next = this.pos + skip[0].length,
40175            nextCh = this.input.charCodeAt(next);
40176
40177        if (nextCh === 40) // '('
40178          {
40179            return this.parseExpressionStatement(node, this.parseExpression());
40180          }
40181      }
40182
40183      if (!this.options.allowImportExportEverywhere) {
40184        if (!topLevel) {
40185          this.raise(this.start, "'import' and 'export' may only appear at the top level");
40186        }
40187
40188        if (!this.inModule) {
40189          this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'");
40190        }
40191      }
40192
40193      return starttype === types._import ? this.parseImport(node) : this.parseExport(node, exports);
40194    // If the statement does not start with a statement keyword or a
40195    // brace, it's an ExpressionStatement or LabeledStatement. We
40196    // simply start parsing an expression, and afterwards, if the
40197    // next token is a colon and the expression was a simple
40198    // Identifier node, we switch to interpreting it as a label.
40199
40200    default:
40201      if (this.isAsyncFunction()) {
40202        if (context) {
40203          this.unexpected();
40204        }
40205
40206        this.next();
40207        return this.parseFunctionStatement(node, true, !context);
40208      }
40209
40210      var maybeName = this.value,
40211          expr = this.parseExpression();
40212
40213      if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon)) {
40214        return this.parseLabeledStatement(node, maybeName, expr, context);
40215      } else {
40216        return this.parseExpressionStatement(node, expr);
40217      }
40218
40219  }
40220};
40221
40222pp$1.parseBreakContinueStatement = function (node, keyword) {
40223  var isBreak = keyword === "break";
40224  this.next();
40225
40226  if (this.eat(types.semi) || this.insertSemicolon()) {
40227    node.label = null;
40228  } else if (this.type !== types.name) {
40229    this.unexpected();
40230  } else {
40231    node.label = this.parseIdent();
40232    this.semicolon();
40233  } // Verify that there is an actual destination to break or
40234  // continue to.
40235
40236
40237  var i = 0;
40238
40239  for (; i < this.labels.length; ++i) {
40240    var lab = this.labels[i];
40241
40242    if (node.label == null || lab.name === node.label.name) {
40243      if (lab.kind != null && (isBreak || lab.kind === "loop")) {
40244        break;
40245      }
40246
40247      if (node.label && isBreak) {
40248        break;
40249      }
40250    }
40251  }
40252
40253  if (i === this.labels.length) {
40254    this.raise(node.start, "Unsyntactic " + keyword);
40255  }
40256
40257  return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
40258};
40259
40260pp$1.parseDebuggerStatement = function (node) {
40261  this.next();
40262  this.semicolon();
40263  return this.finishNode(node, "DebuggerStatement");
40264};
40265
40266pp$1.parseDoStatement = function (node) {
40267  this.next();
40268  this.labels.push(loopLabel);
40269  node.body = this.parseStatement("do");
40270  this.labels.pop();
40271  this.expect(types._while);
40272  node.test = this.parseParenExpression();
40273
40274  if (this.options.ecmaVersion >= 6) {
40275    this.eat(types.semi);
40276  } else {
40277    this.semicolon();
40278  }
40279
40280  return this.finishNode(node, "DoWhileStatement");
40281}; // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
40282// loop is non-trivial. Basically, we have to parse the init `var`
40283// statement or expression, disallowing the `in` operator (see
40284// the second parameter to `parseExpression`), and then check
40285// whether the next token is `in` or `of`. When there is no init
40286// part (semicolon immediately after the opening parenthesis), it
40287// is a regular `for` loop.
40288
40289
40290pp$1.parseForStatement = function (node) {
40291  this.next();
40292  var awaitAt = this.options.ecmaVersion >
40292= 9 && (this.inAsync || !this.inFunction && this.options.allowAwaitOutsideFunction) && this.eatContextual("await") ? this.lastTokStart : -1;
40293  this.labels.push(loopLabel);
40294  this.enterScope(0);
40295  this.expect(types.parenL);
40296
40297  if (this.type === types.semi) {
40298    if (awaitAt > -1) {
40299      this.unexpected(awaitAt);
40300    }
40301
40302    return this.parseFor(node, null);
40303  }
40304
40305  var isLet = this.isLet();
40306
40307  if (this.type === types._var || this.type === types._const || isLet) {
40308    var init$1 = this.startNode(),
40309        kind = isLet ? "let" : this.value;
40310    this.next();
40311    this.parseVar(init$1, true, kind);
40312    this.finishNode(init$1, "VariableDeclaration");
40313
40314    if ((this.type === types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) && init$1.declarations.length === 1) {
40315      if (this.options.ecmaVersion >= 9) {
40316        if (this.type === types._in) {
40317          if (awaitAt > -1) {
40318            this.unexpected(awaitAt);
40319          }
40320        } else {
40321          node.await = awaitAt > -1;
40322        }
40323      }
40324
40325      return this.parseForIn(node, init$1);
40326    }
40327
40328    if (awaitAt > -1) {
40329      this.unexpected(awaitAt);
40330    }
40331
40332    return this.parseFor(node, init$1);
40333  }
40334
40335  var refDestructuringErrors = new DestructuringErrors();
40336  var init = this.parseExpression(true, refDestructuringErrors);
40337
40338  if (this.type === types._in || this.options.ecmaVersion >= 6 && this.isContextual("of")) {
40339    if (this.options.ecmaVersion >= 9) {
40340      if (this.type === types._in) {
40341        if (awaitAt > -1) {
40342          this.unexpected(awaitAt);
40343        }
40344      } else {
40345        node.await = awaitAt > -1;
40346      }
40347    }
40348
40349    this.toAssignable(init, false, refDestructuringErrors);
40350    this.checkLVal(init);
40351    return this.parseForIn(node, init);
40352  } else {
40353    this.checkExpressionErrors(refDestructuringErrors, true);
40354  }
40355
40356  if (awaitAt > -1) {
40357    this.unexpected(awaitAt);
40358  }
40359
40360  return this.parseFor(node, init);
40361};
40362
40363pp$1.parseFunctionStatement = function (node, isAsync, declarationPosition) {
40364  this.next();
40365  return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync);
40366};
40367
40368pp$1.parseIfStatement = function (node) {
40369  this.next();
40370  node.test = this.parseParenExpression(); // allow function declarations in branches, but only in non-strict mode
40371
40372  node.consequent = this.parseStatement("if");
40373  node.alternate = this.eat(types._else) ? this.parseStatement("if") : null;
40374  return this.finishNode(node, "IfStatement");
40375};
40376
40377pp$1.parseReturnStatement = function (node) {
40378  if (!this.inFunction && !this.options.allowReturnOutsideFunction) {
40379    this.raise(this.start, "'return' outside of function");
40380  }
40381
40382  this.next(); // In `return` (and `break`/`continue`), the keywords with
40383  // optional arguments, we eagerly look for a semicolon or the
40384  // possibility to insert one.
40385
40386  if (this.eat(types.semi) || this.insertSemicolon()) {
40387    node.argument = null;
40388  } else {
40389    node.argument = this.parseExpression();
40390    this.semicolon();
40391  }
40392
40393  return this.finishNode(node, "ReturnStatement");
40394};
40395
40396pp$1.parseSwitchStatement = function (node) {
40397  this.next();
40398  node.discriminant = this.parseParenExpression();
40399  node.cases = [];
40400  this.expect(types.braceL);
40401  this.labels.push(switchLabel);
40402  this.enterScope(0); // Statements under must be grouped (by label) in SwitchCase
40403  // nodes. `cur` is used to keep the node that we are currently
40404  // adding statements to.
40405
40406  var cur;
40407
40408  for (var sawDefault = false; this.type !== types.braceR;) {
40409    if (this.type === types._case || this.type === types._default) {
40410      var isCase = this.type === types._case;
40411
40412      if (cur) {
40413        this.finishNode(cur, "SwitchCase");
40414      }
40415
40416      node.cases.push(cur = this.startNode());
40417      cur.consequent = [];
40418      this.next();
40419
40420      if (isCase) {
40421        cur.test = this.parseExpression();
40422      } else {
40423        if (sawDefault) {
40424          this.raiseRecoverable(this.lastTokStart, "Multiple default clauses");
40425        }
40426
40427        sawDefault = true;
40428        cur.test = null;
40429      }
40430
40431      this.expect(types.colon);
40432    } else {
40433      if (!cur) {
40434        this.unexpected();
40435      }
40436
vendor: 4,141 bytes, lines 40437-40591
40437      cur.consequent.push(this.parseStatement(null));
40438    }
40439  }
40440
40441  this.exitScope();
40442
40443  if (cur) {
40444    this.finishNode(cur, "SwitchCase");
40445  }
40446
40447  this.next(); // Closing brace
40448
40449  this.labels.pop();
40450  return this.finishNode(node, "SwitchStatement");
40451};
40452
40453pp$1.parseThrowStatement = function (node) {
40454  this.next();
40455
40456  if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) {
40457    this.raise(this.lastTokEnd, "Illegal newline after throw");
40458  }
40459
40460  node.argument = this.parseExpression();
40461  this.semicolon();
40462  return this.finishNode(node, "ThrowStatement");
40463}; // Reused empty array added for node fields that are always empty.
40464
40465
40466var empty = [];
40467
40468pp$1.parseTryStatement = function (node) {
40469  this.next();
40470  node.block = this.parseBlock();
40471  node.handler = null;
40472
40473  if (this.type === types._catch) {
40474    var clause = this.startNode();
40475    this.next();
40476
40477    if (this.eat(types.parenL)) {
40478      clause.param = this.parseBindingAtom();
40479      var simple = clause.param.type === "Identifier";
40480      this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
40481      this.checkLVal(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
40482      this.expect(types.parenR);
40483    } else {
40484      if (this.options.ecmaVersion < 10) {
40485        this.unexpected();
40486      }
40487
40488      clause.param = null;
40489      this.enterScope(0);
40490    }
40491
40492    clause.body = this.parseBlock(false);
40493    this.exitScope();
40494    node.handler = this.finishNode(clause, "CatchClause");
40495  }
40496
40497  node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
40498
40499  if (!node.handler && !node.finalizer) {
40500    this.raise(node.start, "Missing catch or finally clause");
40501  }
40502
40503  return this.finishNode(node, "TryStatement");
40504};
40505
40506pp$1.parseVarStatement = function (node, kind) {
40507  this.next();
40508  this.parseVar(node, false, kind);
40509  this.semicolon();
40510  return this.finishNode(node, "VariableDeclaration");
40511};
40512
40513pp$1.parseWhileStatement = function (node) {
40514  this.next();
40515  node.test = this.parseParenExpression();
40516  this.labels.push(loopLabel);
40517  node.body = this.parseStatement("while");
40518  this.labels.pop();
40519  return this.finishNode(node, "WhileStatement");
40520};
40521
40522pp$1.parseWithStatement = function (node) {
40523  if (this.strict) {
40524    this.raise(this.start, "'with' in strict mode");
40525  }
40526
40527  this.next();
40528  node.object = this.parseParenExpression();
40529  node.body = this.parseStatement("with");
40530  return this.finishNode(node, "WithStatement");
40531};
40532
40533pp$1.parseEmptyStatement = function (node) {
40534  this.next();
40535  return this.finishNode(node, "EmptyStatement");
40536};
40537
40538pp$1.parseLabeledStatement = function (node, maybeName, expr, context) {
40539  for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1) {
40540    var label = list[i$1];
40541
40542    if (label.name === maybeName) {
40543      this.raise(expr.start, "Label '" + maybeName + "' is already declared");
40544    }
40545  }
40546
40547  var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
40548
40549  for (var i = this.labels.length - 1; i >= 0; i--) {
40550    var label$1 = this.labels[i];
40551
40552    if (label$1.statementStart === node.start) {
40553      // Update information about previous labels on this node
40554      label$1.statementStart = this.start;
40555      label$1.kind = kind;
40556    } else {
40557      break;
40558    }
40559  }
40560
40561  this.labels.push({
40562    name: maybeName,
40563    kind: kind,
40564    statementStart: this.start
40565  });
40566  node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
40567  this.labels.pop();
40568  node.label = expr;
40569  return this.finishNode(node, "LabeledStatement");
40570};
40571
40572pp$1.parseExpressionStatement = function (node, expr) {
40573  node.expression = expr;
40574  this.semicolon();
40575  return this.finishNode(node, "ExpressionStatement");
40576}; // Parse a semicolon-enclosed block of statements, handling `"use
40577// strict"` declarations when `allowStrict` is true (used for
40578// function bodies).
40579
40580
40581pp$1.parseBlock = function (createNewLexicalScope, node) {
40582  if (createNewLexicalScope === void 0) createNewLexicalScope = true;
40583  if (node === void 0) node = this.startNode();
40584  node.body = [];
40585  this.expect(types.braceL);
40586
40587  if (createNewLexicalScope) {
40588    this.enterScope(0);
40589  }
40590
40591  while (!this.eat(types.braceR)) {
40592    var stmt = this.parseStatement(null);
40593    node.body.push(stmt);
40594  }
40595
40596  if (createNewLexicalScope) {
40597    this.exitScope();
40598  }
40599
40600  return this.finishNode(node, "BlockStatement");
40601}; // Parse a regular `for` loop. The disambiguation code in
40602// `parseStatement` will already have parsed the init statement or
40603// expression.
40604
40605
40606pp$1.parseFor = function (node, init) {
40607  node.init = init;
40608  this.expect(types.semi);
40609  node.test = this.type === types.semi ? null : this.parseExpression();
40610  this.expect(types.semi);
40611  node.update = this.type === types.parenR ? null : this.parseExpression();
40612  this.expect(types.parenR);
40613  node.body = this.parseStatement("for");
40614  this.exitScope();
40615  this.labels.pop();
40616  return this.finishNode(node, "ForStatement");
40617}; // Parse a `for`/`in` and `for`/`of` loop, which are almost
40618// same from parser's perspective.
40619
40620
40621pp$1.parseForIn = function (node, init) {
40622  var isForIn = this.type === types._in;
40623  this.next();
40624
40625  if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.options.ecmaVersion < 8 || this.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
40626    this.raise(init.start, (isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer");
40627  } else if (init.type === "AssignmentPattern") {
40628    this.raise(init.start, "Invalid left-hand side in for-loop");
40629  }
40630
40631  node.left = init;
40632  node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
40633  this.expect(types.parenR);
40634  node.body = this.parseStatement("for");
40635  this.exitScope();
40636  this.labels.pop();
40637  return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
40638}; // Parse a list of variable declarations.
40639
40640
40641pp$1.parseVar = function (node, isFor, kind) {
40642  node.declarations = [];
40643  node.kind = kind;
40644
40645  for (;;) {
40646    var decl = this.startNode();
40647    this.parseVarId(decl, kind);
40648
40649    if (this.eat(types.eq)) {
40650      decl.init = this.parseMaybeAssign(isFor);
40651    } else if (kind === "const" && !(this.type === types._in || this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
40652      this.unexpected();
40653    }
40653 else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types._in || this.isContextual("of")))) {
40654      this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
40655    } else {
40656      decl.init = null;
40657    }
40658
40659    node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
40660
40661    if (!this.eat(types.comma)) {
40662      break;
40663    }
40664  }
40665
40666  return node;
40667};
40668
40669pp$1.parseVarId = function (decl, kind) {
40670  decl.id = this.parseBindingAtom();
40671  this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
40672};
40673
40674var FUNC_STATEMENT = 1,
40675    FUNC_HANGING_STATEMENT = 2,
40676    FUNC_NULLABLE_ID = 4; // Parse a function declaration or literal (depending on the
40677// `statement & FUNC_STATEMENT`).
40678// Remove `allowExpressionBody` for 7.0.0, as it is only called with false
40679
40680pp$1.parseFunction = function (node, statement, allowExpressionBody, isAsync) {
40681  this.initFunction(node);
40682
40683  if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
40684    if (this.type === types.star && statement & FUNC_HANGING_STATEMENT) {
40685      this.unexpected();
40686    }
40687
40688    node.generator = this.eat(types.star);
40689  }
40690
40691  if (this.options.ecmaVersion >= 8) {
40692    node.async = !!isAsync;
40693  }
40694
40695  if (statement & FUNC_STATEMENT) {
40696    node.id = statement & FUNC_NULLABLE_ID && this.type !== types.name ? null : this.parseIdent();
40697
40698    if (node.id && !(statement & FUNC_HANGING_STATEMENT)) // If it is a regular function declaration in sloppy mode, then it is
40699      // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
40700      // mode depends on properties of the current scope (see
40701      // treatFunctionsAsVar).
40702      {
40703        this.checkLVal(node.id, this.strict || node.generator || node.async ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION);
40704      }
40705  }
40706
40707  var oldYieldPos = this.yieldPos,
40708      oldAwaitPos = this.awaitPos,
40709      oldAwaitIdentPos = this.awaitIdentPos;
40710  this.yieldPos = 0;
40711  this.awaitPos = 0;
40712  this.awaitIdentPos = 0;
40713  this.enterScope(functionFlags(node.async, node.generator));
40714
40715  if (!(statement & FUNC_STATEMENT)) {
40716    node.id = this.type === types.name ? this.parseIdent() : null;
40717  }
40718
40719  this.parseFunctionParams(node);
40720  this.parseFunctionBody(node, allowExpressionBody, false);
40721  this.yieldPos = oldYieldPos;
40722  this.awaitPos = oldAwaitPos;
40723  this.awaitIdentPos = oldAwaitIdentPos;
40724  return this.finishNode(node, statement & FUNC_STATEMENT ? "FunctionDeclaration" : "FunctionExpression");
40725};
40726
40727pp$1.parseFunctionParams = function (node) {
40728  this.expect(types.parenL);
40729  node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
40730  this.checkYieldAwaitInDefaultParams();
40731}; // Parse a class declaration or literal (depending on the
40732// `isStatement` parameter).
40733
40734
40735pp$1.parseClass = function (node, isStatement) {
40736  this.next(); // ecma-262 14.6 Class Definitions
40737  // A class definition is always strict mode code.
40738
40739  var oldStrict = this.strict;
40740  this.strict = true;
40741  this.parseClassId(node, isStatement);
40742  this.parseClassSuper(node);
40743  var classBody = this.startNode();
40744  var hadConstructor = false;
40745  classBody.body = [];
40746  this.expect(types.braceL);
40747
40748  while (!this.eat(types.braceR)) {
40749    var element = this.parseClassElement(node.superClass !== null);
40750
40751    if (element) {
40752      classBody.body.push(element);
40753
40754      if (element.type === "MethodDefinition" && element.kind === "constructor") {
40755        if (hadConstructor) {
40756          this.raise(element.start, "Duplicate constructor in the same class");
40757        }
40758
40759        hadConstructor = true;
40760      }
40761    }
40762  }
40763
40764  node.body = this.finishNode(classBody, "ClassBody");
40765  this.strict = oldStrict;
40766  return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
40767};
40768
40769pp$1.parseClassElement = function (constructorAllowsSuper) {
40770  var this$1 = this;
40771
40772  if (this.eat(types.semi)) {
40773    return null;
40774  }
40775
40776  var method = this.startNode();
40777
40778  var tryContextual = function (k, noLineBreak) {
40779    if (noLineBreak === void 0) noLineBreak = false;
40780    var start = this$1.start,
40781        startLoc = this$1.startLoc;
40782
40783    if (!this$1.eatContextual(k)) {
40784      return false;
vendor: 8,449 bytes, lines 40785-41085
40785    }
40786
40787    if (this$1.type !== types.parenL && (!noLineBreak || !this$1.canInsertSemicolon())) {
40788      return true;
40789    }
40790
40791    if (method.key) {
40792      this$1.unexpected();
40793    }
40794
40795    method.computed = false;
40796    method.key = this$1.startNodeAt(start, startLoc);
40797    method.key.name = k;
40798    this$1.finishNode(method.key, "Identifier");
40799    return false;
40800  };
40801
40802  method.kind = "method";
40803  method.static = tryContextual("static");
40804  var isGenerator = this.eat(types.star);
40805  var isAsync = false;
40806
40807  if (!isGenerator) {
40808    if (this.options.ecmaVersion >= 8 && tryContextual("async", true)) {
40809      isAsync = true;
40810      isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
40811    } else if (tryContextual("get")) {
40812      method.kind = "get";
40813    } else if (tryContextual("set")) {
40814      method.kind = "set";
40815    }
40816  }
40817
40818  if (!method.key) {
40819    this.parsePropertyName(method);
40820  }
40821
40822  var key = method.key;
40823  var allowsDirectSuper = false;
40824
40825  if (!method.computed && !method.static && (key.type === "Identifier" && key.name === "constructor" || key.type === "Literal" && key.value === "constructor")) {
40826    if (method.kind !== "method") {
40827      this.raise(key.start, "Constructor can't have get/set modifier");
40828    }
40829
40830    if (isGenerator) {
40831      this.raise(key.start, "Constructor can't be a generator");
40832    }
40833
40834    if (isAsync) {
40835      this.raise(key.start, "Constructor can't be an async method");
40836    }
40837
40838    method.kind = "constructor";
40839    allowsDirectSuper = constructorAllowsSuper;
40840  } else if (method.static && key.type === "Identifier" && key.name === "prototype") {
40841    this.raise(key.start, "Classes may not have a static property named prototype");
40842  }
40843
40844  this.parseClassMethod(method, isGenerator, isAsync, allowsDirectSuper);
40845
40846  if (method.kind === "get" && method.value.params.length !== 0) {
40847    this.raiseRecoverable(method.value.start, "getter should have no params");
40848  }
40849
40850  if (method.kind === "set" && method.value.params.length !== 1) {
40851    this.raiseRecoverable(method.value.start, "setter should have exactly one param");
40852  }
40853
40854  if (method.kind === "set" && method.value.params[0].type === "RestElement") {
40855    this.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params");
40856  }
40857
40858  return method;
40859};
40860
40861pp$1.parseClassMethod = function (method, isGenerator, isAsync, allowsDirectSuper) {
40862  method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
40863  return this.finishNode(method, "MethodDefinition");
40864};
40865
40866pp$1.parseClassId = function (node, isStatement) {
40867  if (this.type === types.name) {
40868    node.id = this.parseIdent();
40869
40870    if (isStatement) {
40871      this.checkLVal(node.id, BIND_LEXICAL, false);
40872    }
40873  } else {
40874    if (isStatement === true) {
40875      this.unexpected();
40876    }
40877
40878    node.id = null;
40879  }
40880};
40881
40882pp$1.parseClassSuper = function (node) {
40883  node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
40884}; // Parses module export declaration.
40885
40886
40887pp$1.parseExport = function (node, exports) {
40888  this.next(); // export * from '...'
40889
40890  if (this.eat(types.star)) {
40891    this.expectContextual("from");
40892
40893    if (this.type !== types.string) {
40894      this.unexpected();
40895    }
40896
40897    node.source = this.parseExprAtom();
40898    this.semicolon();
40899    return this.finishNode(node, "ExportAllDeclaration");
40900  }
40901
40902  if (this.eat(types._default)) {
40903    // export default ...
40904    this.checkExport(exports, "default", this.lastTokStart);
40905    var isAsync;
40906
40907    if (this.type === types._function || (isAsync = this.isAsyncFunction())) {
40908      var fNode = this.startNode();
40909      this.next();
40910
40911      if (isAsync) {
40912        this.next();
40913      }
40914
40915      node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
40916    } else if (this.type === types._class) {
40917      var cNode = this.startNode();
40918      node.declaration = this.parseClass(cNode, "nullableID");
40919    } else {
40920      node.declaration = this.parseMaybeAssign();
40921      this.semicolon();
40922    }
40923
40924    return this.finishNode(node, "ExportDefaultDeclaration");
40925  } // export var|const|let|function|class ...
40926
40927
40928  if (this.shouldParseExportStatement()) {
40929    node.declaration = this.parseStatement(null);
40930
40931    if (node.declaration.type === "VariableDeclaration") {
40932      this.checkVariableExport(exports, node.declaration.declarations);
40933    } else {
40934      this.checkExport(exports, node.declaration.id.name, node.declaration.id.start);
40935    }
40936
40937    node.specifiers = [];
40938    node.source = null;
40939  } else {
40940    // export { x, y as z } [from '...']
40941    node.declaration = null;
40942    node.specifiers = this.parseExportSpecifiers(exports);
40943
40944    if (this.eatContextual("from")) {
40945      if (this.type !== types.string) {
40946        this.unexpected();
40947      }
40948
40949      node.source = this.parseExprAtom();
40950    } else {
40951      for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
40952        // check for keywords used as local names
40953        var spec = list[i];
40954        this.checkUnreserved(spec.local); // check if export is defined
40955
40956        this.checkLocalExport(spec.local);
40957      }
40958
40959      node.source = null;
40960    }
40961
40962    this.semicolon();
40963  }
40964
40965  return this.finishNode(node, "ExportNamedDeclaration");
40966};
40967
40968pp$1.checkExport = function (exports, name, pos) {
40969  if (!exports) {
40970    return;
40971  }
40972
40973  if (has(exports, name)) {
40974    this.raiseRecoverable(pos, "Duplicate export '" + name + "'");
40975  }
40976
40977  exports[name] = true;
40978};
40979
40980pp$1.checkPatternExport = function (exports, pat) {
40981  var type = pat.type;
40982
40983  if (type === "Identifier") {
40984    this.checkExport(exports, pat.name, pat.start);
40985  } else if (type === "ObjectPattern") {
40986    for (var i = 0, list = pat.properties; i < list.length; i += 1) {
40987      var prop = list[i];
40988      this.checkPatternExport(exports, prop);
40989    }
40990  } else if (type === "ArrayPattern") {
40991    for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
40992      var elt = list$1[i$1];
40993
40994      if (elt) {
40995        this.checkPatternExport(exports, elt);
40996      }
40997    }
40998  } else if (type === "Property") {
40999    this.checkPatternExport(exports, pat.value);
41000  } else if (type === "AssignmentPattern") {
41001    this.checkPatternExport(exports, pat.left);
41002  } else if (type === "RestElement") {
41003    this.checkPatternExport(exports, pat.argument);
41004  } else if (type === "ParenthesizedExpression") {
41005    this.checkPatternExport(exports, pat.expression);
41006  }
41007};
41008
41009pp$1.checkVariableExport = function (exports, decls) {
41010  if (!exports) {
41011    return;
41012  }
41013
41014  for (var i = 0, list = decls; i < list.length; i += 1) {
41015    var decl = list[i];
41016    this.checkPatternExport(exports, decl.id);
41017  }
41018};
41019
41020pp$1.shouldParseExportStatement = function () {
41021  return this.type.keyword === "var" || this.type.keyword === "const" || this.type.keyword === "class" || this.type.keyword === "function" || this.isLet() || this.isAsyncFunction();
41022}; // Parses a comma-separated list of module exports.
41023
41024
41025pp$1.parseExportSpecifiers = function (exports) {
41026  var nodes = [],
41027      first = true; // export { x, y as z } [from '...']
41028
41029  this.expect(types.braceL);
41030
41031  while (!this.eat(types.braceR)) {
41032    if (!first) {
41033      this.expect(types.comma);
41034
41035      if (this.afterTrailingComma(types.braceR)) {
41036        break;
41037      }
41038    } else {
41039      first = false;
41040    }
41041
41042    var node = this.startNode();
41043    node.local = this.parseIdent(true);
41044    node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
41045    this.checkExport(exports, node.exported.name, node.exported.start);
41046    nodes.push(this.finishNode(node, "ExportSpecifier"));
41047  }
41048
41049  return nodes;
41050}; // Parses import declaration.
41051
41052
41053pp$1.parseImport = function (node) {
41054  this.next(); // import '...'
41055
41056  if (this.type === types.string) {
41057    node.specifiers = empty;
41058    node.source = this.parseExprAtom();
41059  } else {
41060    node.specifiers = this.parseImportSpecifiers();
41061    this.expectContextual("from");
41062    node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
41063  }
41064
41065  this.semicolon();
41066  return this.finishNode(node, "ImportDeclaration");
41067}; // Parses a comma-separated list of module imports.
41068
41069
41070pp$1.parseImportSpecifiers = function () {
41071  var nodes = [],
41072      first = true;
41073
41074  if (this.type === types.name) {
41075    // import defaultObj, { x, y as z } from '...'
41076    var node = this.startNode();
41077    node.local = this.parseIdent();
41078    this.checkLVal(node.local, BIND_LEXICAL);
41079    nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
41080
41081    if (!this.eat(types.comma)) {
41082      return nodes;
41083    }
41084  }
41085
41086  if (this.type === types.star) {
41087    var node$1 = this.startNode();
41088    this.next();
41089    this.expectContextual("as");
41090    node$1.local = this.parseIdent();
41091    this.checkLVal(node$1.local, BIND_LEXICAL);
41092    nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
41093    return nodes;
41094  }
41095
41096  this.expect(types.braceL);
41097
41098  while (!this.eat(types.braceR)) {
41099    if (!first) {
41100      this.expect(types.comma);
41101
41102      if (this.afterTrailingComma(types.braceR)) {
41103        break;
41104      }
41105    } else {
41106      first = false;
41107    }
41108
41109    var node$2 = this.startNode();
41110    node$2.imported = this.parseIdent(true);
41111
41112    if (this.eatContextual("as")) {
41113      node$2.local = this.parseIdent();
41114    } else {
41115      this.checkUnreserved(node$2.imported);
41116      node$2.local = node$2.imported;
41117    }
41118
41119    this.checkLVal(node$2.local, BIND_LEXICAL);
41120    nodes.push(this.finishNode(node$2, "ImportSpecifier"));
41121  }
41122
41123  return nodes;
41124}; // Set `ExpressionStatement#directive` property for directive prologues.
41125
41126
41127pp$1.adaptDirectivePrologue = function (statements) {
41128  for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
41129    statements[i].directive = statements[i].expression.raw.slice(1, -1);
41130  }
41131};
41132
41133pp$1.isDirectiveCandidate = function (statement) {
41134  return statement.type === "ExpressionStatement" && statement.expression.type === "Literal" && typeof statement.expression.value === "string" && ( // Reject parenthesized strings.
41135  this.input[statement.start] === "\"" || this.input[statement.start] === "'");
41136};
41137
41138var pp$2 = Parser.prototype; // Convert existing expression atom to assignable pattern
41139// if possible.
41140
41141pp$2.toAssignable = function (node, isBinding, refDestructuringErrors) {
41142  if (this.options.ecmaVersion >= 6 && node) {
41143    switch (node.type) {
41144      case "Identifier":
41145        if (this.inAsync && node.name === "await") {
41146          this.raise(node.start, "Cannot use 'await' as identifier inside an async function");
41147        }
41148
41149        break;
41150
41151      case "ObjectPattern":
41152      case "ArrayPattern":
41153      case "RestElement":
41154        break;
41155
41156      case "ObjectExpression":
41157        node.type = "ObjectPattern";
41158
41159        if (refDestructuringErrors) {
41160          this.checkPatternErrors(refDestructuringErrors, true);
41161        }
41162
41163        for (var i = 0, list = node.properties; i < list.length; i += 1) {
41164          var prop = list[i];
41165          this.toAssignable(prop, isBinding); // Early error:
41166          //   AssignmentRestProperty[Yield, Await] :
41167          //     `...` DestructuringAssignmentTarget[Yield, Await]
41168          //
41169          //   It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
41170
41171          if (prop.type === "RestElement" && (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")) {
41172            this.raise(prop.argument.start, "Unexpected token");
41173          }
41174        }
41175
41176        break;
41177
41178      case "Property":
41179        // AssignmentProperty has type === "Property"
41180        if (node.kind !== "init") {
41181          this.raise(node.key.start, "Object pattern can't contain getter or setter");
41182        }
41183
41184        this.toAssignable(node.value, isBinding);
41185        break;
41186
41187      case "ArrayExpression":
41188        node.type = "ArrayPattern";
41189
41190        if (refDestructuringErrors) {
41191          this.checkPatternErrors(refDestructuringErrors, true);
41192        }
41193
41194        this.toAssignableList(node.elements, isBinding);
41195        break;
41196
41197      case "SpreadElement":
41198        node.type = "RestElement";
41199        this.toAssignable(node.argument, isBinding);
41200
41201        if (node.argument.type === "AssignmentPattern") {
41202          this.raise(node.argument.start, "Rest elements cannot have a default value");
41203        }
41204
41205        break;
41206
41207      case "AssignmentExpression":
41208        if (node.operator !== "=") {
41209          this.raise(node.left.end, "Only '=' operator can be used for specifying default value.");
41210        }
41211
41212        node.type = "AssignmentPattern";
41213        delete node.operator;
41214        this.toAssignable(node.left, isBinding);
41215      // falls through to AssignmentPattern
41216
41217      case "AssignmentPattern":
41218        break;
41219
41220      case "ParenthesizedExpression":
41221        this.toAssignable(node.expression, isBinding, refDestructuringErrors);
41222        break;
41223
41224      case "MemberExpression":
41225        if (!isBinding) {
41226          break;
41227        }
41228
41229      default:
41230        this.raise(node.start, "Assigning to rvalue");
41231    }
41232  } else if (refDestructuringErrors) {
41233    this.checkPatternErrors(refDestructuringErrors, true);
41234  }
41235
41236  return node;
41237}; // Convert list of expression atoms to binding list.
41238
41239
41240pp$2.toAssignableList = function (exprList, isBinding) {
41241  var end = exprList.length;
41242
41243  for (var i = 0; i < end; i++) {
41244    var elt = exprList[i];
41245
41246    if (elt) {
41247      this.toAssignable(elt, isBinding);
41248    }
41249  }
41250
41251  if (end) {
41252    var last = exprList[end - 1];
41253
41254    if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") {
41255      this.unexpected(last.argument.start);
41256    }
41257  }
41258
41259  return exprList;
41260}; // Parses spread element.
41261
41262
41263pp$2.parseSpread = function (refDestructuringErrors) {
41264  var node = this.startNode();
41265  this.next();
41266  node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
41267  return this.finishNode(node, "SpreadElement");
41268};
41269
41270pp$2.parseRestBinding = function () {
41271  var node = this.startNode();
41272  this.next(); // RestElement inside of a function parameter must be an identifier
41273
41274  if (this.options.ecmaVersion === 6 && this.type !== types.name) {
41275    this.unexpected();
41276  }
41277
41278  node.argument = this.parseBindingAtom();
41279  return this.finishNode(node, "RestElement");
41280}; // Parses lvalue (assignable) atom.
41281
41282
41283pp$2.parseBindingAtom = function () {
41284  if (this.options.ecmaVersion >= 6) {
41285    switch (this.type) {
41286      case types.bracketL:
41287        var node = this.startNode();
41288        this.next();
41289        node.elements = this.parseBindingList(types.bracketR, true, true);
41290        return this.finishNode(node, "ArrayPattern");
41291
41292      case types.braceL:
41293        return this.parseObj(true);
41294    }
41295  }
41296
41297  return this.parseIdent();
41298};
41299
41300pp$2.parseBindingList = function (close, allowEmpty, allowTrailingComma) {
41301  var elts = [],
41302      first = true;
41303
41304  while (!this.eat(close)) {
41305    if (first) {
41306      first = false;
41307    } else {
41308      this.expect(types.comma);
41309    }
41310
41311    if (allowEmpty && this.type === types.comma) {
41312      elts.push(null);
41313    } else if (allowTrailingComma && this.afterTrailingComma(close)) {
41314      break;
41315    } else if (this.type === types.ellipsis) {
41316      var rest = this.parseRestBinding();
41317      this.parseBindingListItem(rest);
41318      elts.push(rest);
41319
41320      if (this.type === types.comma) {
41321        this.raise(this.start, "Comma is not permitted after the rest element");
41322      }
41323
41324      this.expect(close);
41325      break;
41326    } else {
41327      var elem = this.parseMaybeDefault(this.start, this.startLoc);
41328      this.parseBindingListItem(elem);
41329      elts.push(elem);
41330    }
41331  }
41332
41333  return elts;
41334};
41335
41336pp$2.parseBindingListItem = function (param) {
41337  return param;
41338}; // Parses assignment pattern around given atom if possible.
41339
41340
41341pp$2.parseMaybeDefault = function (startPos, startLoc, left) {
41342  left = left || this.parseBindingAtom();
41343
41344  if (this.options.ecmaVersion < 6 || !this.eat(types.eq)) {
41345    return left;
41346  }
41347
41348  var node = this.startNodeAt(startPos, startLoc);
41349  node.left = left;
41350  node.right = this.parseMaybeAssign();
41351  return this.finishNode(node, "AssignmentPattern");
41352}; // Verify that a node is an lval — something that can be assigned
41353// to.
41354// bindingType can be either:
41355// 'var' indicating that the lval creates a 'var' binding
41356// 'let' indicating that the lval creates a lexical ('let' or 'const') binding
41357// 'none' indicating that the binding should be checked for illegal identifiers, but not for duplicate references
41358
41359
41360pp$2.checkLVal = function (expr, bindingType, checkClashes) {
41361  if (bindingType === void 0) bindingType = BIND_NONE;
41362
41363  switch (expr.type) {
41364    case "Identifier":
41365      if (bindingType === BIND_LEXICAL && expr.name === "let") {
41366        this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name");
41367      }
41368
41369      if (this.strict && this.reservedWordsStrictBind.test(expr.name)) {
41370        this.raiseRecoverable(expr.start, (bindingType ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
41371      }
41372
41373      if (checkClashes) {
41374        if (has(checkClashes, expr.name)) {
41375          this.raiseRecoverable(expr.start, "Argument name clash");
41376        }
41377
41378        checkClashes[expr.name] = true;
41379      }
41380
41381      if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) {
41382        this.declareName(expr.name, bindingType, expr.start);
41383      }
41384
41385      break;
41386
41387    case "MemberExpression":
41388      if (bindingType) {
41389        this.raiseRecoverable(expr.start, "Binding member expression");
41390      }
41391
41392      break;
41393
41394    case "ObjectPattern":
41395      for (var i = 0, list = expr.properties; i < list.length; i += 1) {
41396        var prop = list[i];
41397        this.checkLVal(prop, bindingType, checkClashes);
41398      }
41399
41400      break;
41401
41402    case "Property":
41403      // AssignmentProperty has type === "Property"
41404      this.checkLVal(expr.value, bindingType, checkClashes);
41405      break;
41406
41407    case "ArrayPattern":
41408      for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
41409        var elem = list$1[i$1];
41410
41411        if (elem) {
41412          this.checkLVal(elem, bindingType, checkClashes);
41413        }
41414      }
41415
41416      break;
41417
41418    case "AssignmentPattern":
41419      this.checkLVal(expr.left, bindingType, checkClashes);
41420      break;
41421
41422    case "RestElement":
41423      this.checkLVal(expr.argument, bindingType, checkClashes);
41424      break;
41425
41426    case "ParenthesizedExpression":
41427      this.checkLVal(expr.expression, bindingType, checkClashes);
41428      break;
41429
41430    default:
41431      this.raise(expr.start, (bindingType ? "Binding" : "Assigning to") + " rvalue");
41432  }
41433}; // A recursive descent parser operates by defining functions for all
41434
41435
41436var pp$3 = Parser.prototype; // Check if property name clashes with already added.
41437// Object/class getters and setters are not allowed to clash —
41438// either with each other or with an init property — and in
41439// strict mode, init properties are also not allowed to be repeated.
41440
41441pp$3.checkPropClash = function (prop, propHash, refDestructuringErrors) {
41442  if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement") {
41443    return;
41444  }
41445
41446  if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) {
41447    return;
41448  }
41449
41450  var key = prop.key;
41451  var name;
41452
41453  switch (key.type) {
41454    case "Identifier":
41455      name = key.name;
41456      break;
41457
41458    case "Literal":
41459      name = String(key.value);
41460      break;
41461
41462    default:
41463      return;
41464  }
41465
41466  var kind = prop.kind;
41467
41468  if (this.options.ecmaVersion >= 6) {
41469    if (name === "__proto__" && kind === "init") {
41470      if (propHash.proto) {
41471        if (refDestructuringErrors && refDestructuringErrors.doubleProto < 0) {
41472          refDestructuringErrors.doubleProto = key.start;
41473        } // Backwards-compat kludge. Can be removed in version 6.0
41474        else {
41475            this.raiseRecoverable(key.start, "Redefinition of __proto__ property");
41476          }
41477      }
41478
41479      propHash.proto = true;
41480    }
41481
41482    return;
41483  }
41484
41485  name = "$" + name;
41486  var other = propHash[name];
41487
41488  if (other) {
41489    var redefinition;
41490
41491    if (kind === "init") {
41492      redefinition = this.strict && other.init || other.get || other.set;
41493    } else {
41494      redefinition = other.init || other[kind];
41495    }
41496
41497    if (redefinition) {
41498      this.raiseRecoverable(key.start, "Redefinition of property");
41499    }
41500  } else {
41501    other = propHash[name] = {
41502      init: false,
41503      get: false,
41504      set: false
41505    };
41506  }
41507
41508  other[kind] = true;
41509}; // ### Expression parsing
41510// These nest, from the most general expression type at the top to
41511// 'atomic', nondivisible expression types at the bottom. Most of
41512// the functions will simply let the function(s) below them parse,
41513// and, *if* the syntactic construct they handle is present, wrap
41514// the AST node that the inner parser gave them in another node.
41515// Parse a full expression. The optional arguments are used to
41516// forbid the `in` operator (in for loops initalization expressions)
41517// and provide reference for storing '=' operator inside shorthand
41518// property assignment in contexts where both object expression
41519// and object pattern might appear (so it's possible to raise
41520// delayed syntax error at correct position).
41521
41522
41523pp$3.parseExpression = function (noIn, refDestructuringErrors) {
41524  var startPos = this.start,
41525      startLoc = this.startLoc;
41526  var expr = this.parseMaybeAssign(noIn, refDestructuringErrors);
41527
41528  if (this.type === types.comma) {
41529    var node = this.startNodeAt(startPos, startLoc);
41530    node.expressions = [expr];
41531
41532    while (this.eat(types.comma)) {
41533      node.expressions.push(this.parseMaybeAssign(noIn, refDestructuringErrors));
41534    }
41535
41536    return this.finishNode(node, "SequenceExpression");
41537  }
41538
41539  return expr;
41540}; // Parse an assignment expression. This includes applications of
41541// operators like `+=`.
41542
41543
41544pp$3.parseMaybeAssign = function (noIn, refDestructuringErrors, afterLeftParse) {
41545  if (this.isContextual("yield")) {
41546    if (this.inGenerator) {
41547      return this.parseYield(noIn);
41548    } // The tokenizer will assume an expression is allowed after
41549    // `yield`, but this isn't that kind of yield
41550    else {
41551        this.exprAllowed = false;
41552      }
41553  }
41554
41555  var ownDestructuringErrors = false,
41556      oldParenAssign = -1,
41557      oldTrailingComma = -1,
41558      oldShorthandAssign = -1;
41559
41560  if (refDestructuringErrors) {
41561    oldParenAssign = refDestructuringErrors.parenthesizedAssign;
41562    oldTrailingComma = refDestructuringErrors.trailingComma;
41563    oldShorthandAssign = refDestructuringErrors.shorthandAssign;
41564    refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.shorthandAssign = 
41564-1;
41565  } else {
41566    refDestructuringErrors = new DestructuringErrors();
41567    ownDestructuringErrors = true;
41568  }
41569
41570  var startPos = this.start,
41571      startLoc = this.startLoc;
41572
41573  if (this.type === types.parenL || this.type === types.name) {
41574    this.potentialArrowAt = this.start;
41575  }
41576
41577  var left = this.parseMaybeConditional(noIn, refDestructuringErrors);
41578
41579  if (afterLeftParse) {
41580    left = afterLeftParse.call(this, left, startPos, startLoc);
41581  }
41582
41583  if (this.type.isAssign) {
41584    var node = this.startNodeAt(startPos, startLoc);
41585    node.operator = this.value;
41586    node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left;
41587
41588    if (!ownDestructuringErrors) {
41589      DestructuringErrors.call(refDestructuringErrors);
41590    }
41591
41592    refDestructuringErrors.shorthandAssign = -1; // reset because shorthand default was used correctly
41593
41594    this.checkLVal(left);
41595    this.next();
41596    node.right = this.parseMaybeAssign(noIn);
41597    return this.finishNode(node, "AssignmentExpression");
41598  } else {
41599    if (ownDestructuringErrors) {
41600      this.checkExpressionErrors(refDestructuringErrors, true);
41601    }
41602  }
41603
41604  if (oldParenAssign > -1) {
41605    refDestructuringErrors.parenthesizedAssign = oldParenAssign;
41606  }
41607
41608  if (oldTrailingComma > -1) {
41609    refDestructuringErrors.trailingComma = oldTrailingComma;
41610  }
41611
41612  if (oldShorthandAssign > -1) {
41613    refDestructuringErrors.shorthandAssign = oldShorthandAssign;
41614  }
41615
41616  return left;
41617}; // Parse a ternary conditional (`?:`) operator.
41618
41619
41620pp$3.parseMaybeConditional = function (noIn, refDestructuringErrors) {
41621  var startPos = this.start,
41622      startLoc = this.startLoc;
41623  var expr = this.parseExprOps(noIn, refDestructuringErrors);
41624
41625  if (this.checkExpressionErrors(refDestructuringErrors)) {
41626    return expr;
41627  }
41628
41629  if (this.eat(types.question)) {
41630    var node = this.startNodeAt(startPos, startLoc);
41631    node.test = expr;
41632    node.consequent = this.parseMaybeAssign();
41633    this.expect(types.colon);
41634    node.alternate = this.parseMaybeAssign(noIn);
41635    return this.finishNode(node, "ConditionalExpression");
41636  }
41637
41638  return expr;
41639}; // Start the precedence parser.
41640
41641
41642pp$3.parseExprOps = function (noIn, refDestructuringErrors) {
41643  var startPos = this.start,
41644      startLoc = this.startLoc;
41645  var expr = this.parseMaybeUnary(refDestructuringErrors, false);
41646
41647  if (this.checkExpressionErrors(refDestructuringErrors)) {
41648    return expr;
41649  }
41650
41651  return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn);
41652}; // Parse binary operators with the operator precedence parsing
41653// algorithm. `left` is the left-hand side of the operator.
41654// `minPrec` provides context that allows the function to stop and
41655// defer further parser to one of its callers when it encounters an
41656// operator that has a lower precedence than the set it is parsing.
41657
41658
41659pp$3.parseExprOp = function (left, leftStartPos, leftStartLoc, minPrec, noIn) {
41660  var prec = this.type.binop;
41661
41662  if (prec != null && (!noIn || this.type !== types._in)) {
41663    if (prec > minPrec) {
41664      var logical = this.type === types.logicalOR || this.type === types.logicalAND;
41665      var op = this.value;
41666      this.next();
41667      var startPos = this.start,
41668          startLoc = this.startLoc;
41669      var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn);
41670      var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical);
41671      return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn);
41672    }
41673  }
41674
41675  return left;
41676};
41677
41678pp$3.buildBinary = function (startPos, startLoc, left, right, op, logical) {
41679  var node = this.startNodeAt(startPos, startLoc);
41680  node.left = left;
41681  node.operator = op;
41682  node.right = right;
41683  return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression");
41684}; // Parse unary operators, both prefix and postfix.
41685
41686
41687pp$3.parseMaybeUnary = function (refDestructuringErrors, sawUnary) {
41688  var startPos = this.start,
41689      startLoc = this.startLoc,
41690      expr;
41691
41692  if (this.isContextual("await") && (this.inAsync || !this.inFunction && this.options.allowA
41692waitOutsideFunction)) {
41693    expr = this.parseAwait();
41694    sawUnary = true;
41695  } else if (this.type.prefix) {
41696    var node = this.startNode(),
41697        update = this.type === types.incDec;
41698    node.operator = this.value;
41699    node.prefix = true;
41700    this.next();
41701    node.argument = this.parseMaybeUnary(null, true);
41702    this.checkExpressionErrors(refDestructuringErrors, true);
41703
41704    if (update) {
41705      this.checkLVal(node.argument);
41706    } else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") {
41707      this.raiseRecoverable(node.start, "Deleting local variable in strict mode");
41708    } else {
41709      sawUnary = true;
41710    }
41711
41712    expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
41713  } else {
41714    expr = this.parseExprSubscripts(refDestructuringErrors);
41715
41716    if (this.checkExpressionErrors(refDestructuringErrors)) {
41717      return expr;
41718    }
41719
41720    while (this.type.postfix && !this.canInsertSemicolon()) {
41721      var node$1 = this.startNodeAt(startPos, startLoc);
41722      node$1.operator = this.value;
41723      node$1.prefix = false;
41724      node$1.argument = expr;
41725      this.checkLVal(expr);
41726      this.next();
41727      expr = this.finishNode(node$1, "UpdateExpression");
41728    }
41729  }
41730
41731  if (!sawUnary && this.eat(types.starstar)) {
41732    return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false);
41733  } else {
41734    return expr;
41735  }
41736}; // Parse call, dot, and `[]`-subscript expressions.
41737
41738
41739pp$3.parseExprSubscripts = function (refDestructuringErrors) {
41740  var startPos = this.start,
41741      startLoc = this.startLoc;
41742  var expr = this.parseExprAtom(refDestructuringErrors);
41743  var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")";
41744
41745  if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) {
41746    return expr;
41747  }
41748
41749  var result = this.parseSubscripts(expr, startPos, startLoc);
41750
41751  if (refDestructuringErrors && result.type === "MemberExpression") {
41752    if (refDestructuringErrors.parenthesizedAssign >= result.start) {
41753      refDestructuringErrors.parenthesizedAssign = -1;
41754    }
41755
41756    if (refDestructuringErrors.parenthesizedBind >= result.start) {
41757      refDestructuringErrors.parenthesizedBind = -1;
41758    }
41759  }
41760
41761  return result;
41762};
41763
41764pp$3.parseSubscripts = function (base, startPos, startLoc, noCalls) {
41765  var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async";
41766
41767  while (true) {
41768    var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow);
41769
41770    if (element === base || element.type === "ArrowFunctionExpression") {
41771      return element;
41772    }
41773
41774    base = element;
41775  }
41776};
41777
41778pp$3.parseSubscript = function (base, startPos, startLoc, noCalls, maybeAsyncArrow) {
41779  var computed = this.eat(types.bracketL);
41780
41781  if (computed || this.eat(types.dot)) {
41782    var node = this.startNodeAt(startPos, startLoc);
41783    node.object = base;
41784    node.property = computed ? this.parseExpression() : this.parseIdent(this.options.allowReserved !== "never");
41785    node.computed = !!computed;
41786
41787    if (computed) {
41788      this.expect(types.bracketR);
41789    }
41790
41791    base = this.finishNode(node, "MemberExpression");
41792  } else if (!noCalls && this.eat(types.parenL)) {
41793    var refDestructuringErrors = new DestructuringErrors(),
41794        oldYieldPos = this.yieldPos,
41795        oldAwaitPos = this.awaitPos,
41796        oldAwaitIdentPos = this.awaitIdentPos;
41797    this.yieldPos = 0;
41798    this.awaitPos = 0;
41799    this.awaitIdentPos = 0;
41800    var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8 && base.type !== "Import", false, refDestructuringErrors);
41801
41802    if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
41803      this.checkPatternErrors(refDestructuringErrors, false);
41804      this.checkYieldAwaitInDefaultParams();
41805
41806      if (this.awaitIdentPos > 0) {
41807        this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function");
41808      }
41809
41810      this.yieldPos = oldYieldPos;
41811      this.awaitPos = oldAwaitPos;
41812      this.awaitIdentPos = oldAwaitIdentPos;
41813      return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true);
41814    }
41815
41816    this.checkExpressionErrors(refDestructuringErrors, true);
41817    this.yieldPos = oldYieldPos || this.yieldPos;
41818    this.awaitPos = oldAwaitPos || this.awaitPos;
41819    this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
41820    var node$1 = this.startNodeAt(startPos, startLoc);
41821    node$1.callee = base;
41822    node$1.arguments = exprList;
41823
41824    if (node$1.callee.type === "Import") {
41825      if (node$1.arguments.length !== 1) {
41826        this.raise(node$1.start, "import() requires exactly one argument");
41827      }
41828
41829      var importArg = node$1.arguments[0];
41830
41831      if (importArg && importArg.type === "SpreadElement") {
41832        this.raise(importArg.start, "... is not allowed in import()");
41833      }
41834    }
41835
41836    base = this.finishNode(node$1, "CallExpression");
41837  }
41837 else if (this.type === types.backQuote) {
41838    var node$2 = this.startNodeAt(startPos, startLoc);
41839    node$2.tag = base;
41840    node$2.quasi = this.parseTemplate({
41841      isTagged: true
41842    });
41843    base = this.finishNode(node$2, "TaggedTemplateExpression");
41844  }
41845
41846  return base;
41847}; // Parse an atomic expression — either a single token that is an
41848// expression, an expression started by a keyword like `function` or
41849// `new`, or an expression wrapped in punctuation like `()`, `[]`,
41850// or `{}`.
41851
41852
41853pp$3.parseExprAtom = function (refDestructuringErrors) {
41854  // If a division operator appears in an expression position, the
41855  // tokenizer got confused, and we force it to read a regexp instead.
41856  if (this.type === types.slash) {
41857    this.readRegexp();
41858  }
41859
41860  var node,
41861      canBeArrow = this.potentialArrowAt === this.start;
41862
41863  switch (this.type) {
41864    case types._super:
41865      if (!this.allowSuper) {
41866        this.raise(this.start, "'super' keyword outside a method");
41867      }
41868
41869      node = this.startNode();
41870      this.next();
41871
41872      if (this.type === types.parenL && !this.allowDirectSuper) {
41873        this.raise(node.start, "super() call outside constructor of a subclass");
41874      } // The `super` keyword can appear at below:
41875      // SuperProperty:
41876      //     super [ Expression ]
41877      //     super . IdentifierName
41878      // SuperCall:
41879      //     super Arguments
41880
41881
41882      if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL) {
41883        this.unexpected();
41884      }
41885
41886      return this.finishNode(node, "Super");
41887
41888    case types._this:
41889      node = this.startNode();
41890      this.next();
41891      return this.finishNode(node, "ThisExpression");
41892
41893    case types.name:
41894      var startPos = this.start,
41895          startLoc = this.startLoc,
41896          containsEsc = this.containsEsc;
41897      var id = this.parseIdent(false);
41898
41899      if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function)) {
41900        return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true);
41901      }
41902
41903      if (canBeArrow && !this.canInsertSemicolon()) {
41904        if (this.eat(types.arrow)) {
41905          return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false);
41906        }
41907
41908        if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc) {
41909          id = this.parseIdent(false);
41910
41911          if (this.canInsertSemicolon() || !this.eat(types.arrow)) {
41912            this.unexpected();
41913          }
41914
41915          return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true);
41916        }
41917      }
41918
41919      return id;
41920
41921    case types.regexp:
41922      var value = this.value;
41923      node = this.parseLiteral(value.value);
41924      node.regex = {
41925        pattern: value.pattern,
41926        flags: value.flags
41927      };
41928      return node;
41929
41930    case types.num:
41931    case types.string:
41932      return this.parseLiteral(this.value);
41933
41934    case types._null:
41935    case types._true:
41936    case types._false:
41937      node = this.startNode();
41938      node.value = this.type === types._null ? null : this.type === types._true;
41939      node.raw = this.type.keyword;
41940      this.next();
41941      return this.finishNode(node, "Literal");
41942
41943    case types.parenL:
41944      var start = this.start,
41945          expr = this.parseParenAndDistinguishExpression(canBeArrow);
41946
41947      if (refDestructuringErrors) {
41948        if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr)) {
41949          refDestructuringErrors.parenthesizedAssign = start;
41950        }
41951
41952        if (refDestructuringErrors.parenthesizedBind < 0) {
41953          refDestructuringErrors.parenthesizedBind = start;
41954        }
41955      }
41956
41957      return expr;
41958
41959    case types.bracketL:
41960      node = this.startNode();
41961      this.next();
41962      node.elements = this.parseExprList(types.bracketR, true, true, refDestructuringErrors);
41963      return this.finishNode(node, "ArrayExpression");
41964
41965    case types.braceL:
41966      return this.parseObj(false, refDestructuringErrors);
41967
41968    case types._function:
41969      node = this.startNode();
41970      this.next();
41971      return this.parseFunction(node, 0);
41972
41973    case types._class:
41974      return this.parseClass(this.startNode(), false);
41975
41976    case types._new:
41977      return this.parseNew();
41978
41979    case types.backQuote:
41980      return this.parseTemplate();
41981
41982    case types._import:
41983      if (this.options.ecmaVersion > 10) {
41984        return this.parseDynamicImport();
41985      } else {
41986        return this.unexpected();
41987      }
41988
41989    default:
41990      this.unexpected();
41991  }
41992};
41993
41994pp$3.parseDynamicImport = function () {
41995  var node = this.startNode();
41996  this.next();
41997
41998  if (this.type !== types.parenL) {
41999    this.unexpected();
42000  }
42001
42002  return this.finishNode(node, "Import");
42003};
42004
42005pp$3.parseLiteral = function (value) {
42006  var node = this.startNode();
42007  node.value = value;
42008  node.raw = this.input.slice(this.start, this.end);
42009
42010  if (node.raw.charCodeAt(node.raw.length - 1) === 110) {
42011    node.bigint = node.raw.slice(0, -1);
42012  }
42013
42014  this.next();
42015  return this.finishNode(node, "Literal");
42016};
42017
42018pp$3.parseParenExpression = function () {
42019  this.expect(types.parenL);
42020  var val = this.parseExpression();
42021  this.expect(types.parenR);
42022  return val;
42023};
42024
42025pp$3.parseParenAndDistinguishExpression = function (canBeArrow) {
42026  var startPos = this.start,
42027      startLoc = this.startLoc,
42028      val,
42029      allowTrailingComma = this.options.ecmaVersion >= 8;
42030
42031  if (this.options.ecmaVersion >= 6) {
42032    this.next();
42033    var innerStartPos = this.start,
42034        innerStartLoc = this.startLoc;
42035    var exprList = [],
42036        first = true,
42037        lastIsComma = false;
42038    var refDestructuringErrors = new DestructuringErrors(),
42039        oldYieldPos = this.yieldPos,
42040        oldAwaitPos = this.awaitPos,
42041        spreadStart;
42042    this.yieldPos = 0;
42043    this.awaitPos = 0; // Do not save awaitIdentPos to allow checking awaits nested in parameters
42044
42045    while (this.type !== types.parenR) {
42046      first ? first = false : this.expect(types.comma);
42047
42048      if (allowTrailingComma && this.afterTrailingComma(types.parenR, true)) {
42049        lastIsComma = true;
42050        break;
42051      } else if (this.type === types.ellipsis) {
42052        spreadStart = this.start;
42053        exprList.push(this.parseParenItem(this.parseRestBinding()));
42054
42055        if (this.type === types.comma) {
42056          this.raise(this.start, "Comma is not permitted after the rest element");
42057        }
42058
42059        break;
42060      } else {
42061        exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
42062      }
42063    }
42064
42065    var innerEndPos = this.start,
42066        innerEndLoc = this.startLoc;
42067    this.expect(types.parenR);
42068
42069    if (canBeArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
42070      this.checkPatternErrors(refDestructuringErrors, false);
42071      this.checkYieldAwaitInDefaultParams();
42072      this.yieldPos = oldYieldPos;
42073      this.awaitPos = oldAwaitPos;
42074      return this.parseParenArrowList(startPos, startLoc, exprList);
42075    }
42076
42077    if (!exprList.length || lastIsComma) {
42078      this.unexpected(this.lastTokStart);
42079    }
42080
42081    if (spreadStart) {
42082      this.unexpected(spreadStart);
42083    }
42084
42085    this.checkExpressionErrors(refDestructuringErrors, true);
42086    this.yieldPos = oldYieldPos || this.yieldPos;
42087    this.awaitPos = oldAwaitPos || this.awaitPos;
42088
42089    if (exprList.length > 1) {
42090      val = this.startNodeAt(innerStartPos, innerStartLoc);
42091      val.expressions = exprList;
42092      this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
42093    } else {
42094      val = exprList[0];
42095    }
42096  } else {
42097    val = this.parseParenExpression();
42098  }
42099
42100  if (this.options.preserveParens) {
42101    var par = this.startNodeAt(startPos, startLoc);
42102    par.expression = val;
42103    return this.finishNode(par, "ParenthesizedExpression");
42104  } else {
42105    return val;
42106  }
42107};
42108
42109pp$3.parseParenItem = function (item) {
42110  return item;
42111};
42112
42113pp$3.parseParenArrowList = function (startPos, startLoc, exprList) {
42114  return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList);
42115}; // New's precedence is slightly tricky. It must allow its argument to
42116// be a `[]` or dot subscript expression, but not a call — at least,
42117// not without wrapping it in parentheses. Thus, it uses the noCalls
42118// argument to parseSubscripts to prevent it from consuming the
42119// argument list.
42120
42121
42122var empty$1 = [];
42123
42124pp$3.parseNew = function () {
42125  var node = this.startNode();
42126  var meta = this.parseIdent(true);
42127
42128  if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
42129    node.meta = meta;
42130    var containsEsc = this.containsEsc;
42131    node.property = this.parseIdent(true);
42132
42133    if (node.property.name !== "target" || containsEsc) {
42134      this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target");
42135    }
42136
42137    if (!this.inNonArrowFunction()) {
42138      this.raiseRecoverable(node.start, "new.target can only be used in functions");
42139    }
42140
42141    return this.finishNode(node, "MetaProperty");
42142  }
42143
42144  var startPos = this.start,
42145      startLoc = this.startLoc;
42146  node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
42147
42148  if (this.options.ecmaVersion > 10 && node.callee.type === "Import") {
42149    this.raise(node.callee.start, "Cannot use new with import(...)");
42150  }
42151
42152  if (this.eat(types.parenL)) {
42153    node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8 && node.callee.type !== "Import", false);
42154  } else {
42155    node.arguments = empty$1;
42156  }
42157
42158  return this.finishNode(node, "NewExpression");
42159}; // Parse template expression.
42160
42161
42162pp$3.parseTemplateElement = function (ref) {
42163  var isTagged = ref.isTagged;
42164  var elem = this.startNode();
42165
vendor: 1,355 bytes, lines 42166-42217
42166  if (this.type === types.invalidTemplate) {
42167    if (!isTagged) {
42168      this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
42169    }
42170
42171    elem.value = {
42172      raw: this.value,
42173      cooked: null
42174    };
42175  } else {
42176    elem.value = {
42177      raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
42178      cooked: this.value
42179    };
42180  }
42181
42182  this.next();
42183  elem.tail = this.type === types.backQuote;
42184  return this.finishNode(elem, "TemplateElement");
42185};
42186
42187pp$3.parseTemplate = function (ref) {
42188  if (ref === void 0) ref = {};
42189  var isTagged = ref.isTagged;
42190  if (isTagged === void 0) isTagged = false;
42191  var node = this.startNode();
42192  this.next();
42193  node.expressions = [];
42194  var curElt = this.parseTemplateElement({
42195    isTagged: isTagged
42196  });
42197  node.quasis = [curElt];
42198
42199  while (!curElt.tail) {
42200    if (this.type === types.eof) {
42201      this.raise(this.pos, "Unterminated template literal");
42202    }
42203
42204    this.expect(types.dollarBraceL);
42205    node.expressions.push(this.parseExpression());
42206    this.expect(types.braceR);
42207    node.quasis.push(curElt = this.parseTemplateElement({
42208      isTagged: isTagged
42209    }));
42210  }
42211
42212  this.next();
42213  return this.finishNode(node, "TemplateLiteral");
42214};
42215
42216pp$3.isAsyncProp = function (prop) {
42217  return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" && (this.t
42217ype === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword || this.options.ecmaVersion >= 9 && this.type === types.star) && !lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
42218}; // Parse an object literal or binding pattern.
42219
42220
42221pp$3.parseObj = function (isPattern, refDestructuringErrors) {
42222  var node = this.startNode(),
42223      first = true,
42224      propHash = {};
42225  node.properties = [];
42226  this.next();
42227
42228  while (!this.eat(types.braceR)) {
42229    if (!first) {
42230      this.expect(types.comma);
42231
42232      if (this.afterTrailingComma(types.braceR)) {
42233        break;
42234      }
42235    } else {
42236      first = false;
42237    }
42238
42239    var prop = this.parseProperty(isPattern, refDestructuringErrors);
42240
42241    if (!isPattern) {
42242      this.checkPropClash(prop, propHash, refDestructuringErrors);
42243    }
42244
42245    node.properties.push(prop);
42246  }
42247
42248  return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression");
42249};
42250
42251pp$3.parseProperty = function (isPattern, refDestructuringErrors) {
42252  var prop = this.startNode(),
42253      isGenerator,
42254      isAsync,
42255      startPos,
42256      startLoc;
42257
42258  if (this.options.ecmaVersion >= 9 && this.eat(types.ellipsis)) {
42259    if (isPattern) {
42260      prop.argument = this.parseIdent(false);
42261
42262      if (this.type === types.comma) {
42263        this.raise(this.start, "Comma is not permitted after the rest element");
42264      }
42265
42266      return this.finishNode(prop, "RestElement");
42267    } // To disallow parenthesized identifier via `this.toAssignable()`.
42268
42269
42270    if (this.type === types.parenL && refDestructuringErrors) {
42271      if (refDestructuringErrors.parenthesizedAssign < 0) {
42272        refDestructuringErrors.parenthesizedAssign = this.start;
42273      }
42274
42275      if (refDestructuringErrors.parenthesizedBind < 0) {
42276        refDestructuringErrors.parenthesizedBind = this.start;
42277      }
42278    } // Parse argument.
42279
42280
42281    prop.argument = this.parseMaybeAssign(false, refDestructuringErrors); // To disallow trailing comma via `this.toAssignable()`.
42282
42283    if (this.type === types.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
42284      refDestructuringErrors.trailingComma = this.start;
42285    }
vendor: 5,977 bytes, lines 42285-42475
42285 // Finish
42286
42287
42288    return this.finishNode(prop, "SpreadElement");
42289  }
42290
42291  if (this.options.ecmaVersion >= 6) {
42292    prop.method = false;
42293    prop.shorthand = false;
42294
42295    if (isPattern || refDestructuringErrors) {
42296      startPos = this.start;
42297      startLoc = this.startLoc;
42298    }
42299
42300    if (!isPattern) {
42301      isGenerator = this.eat(types.star);
42302    }
42303  }
42304
42305  var containsEsc = this.containsEsc;
42306  this.parsePropertyName(prop);
42307
42308  if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
42309    isAsync = true;
42310    isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
42311    this.parsePropertyName(prop, refDestructuringErrors);
42312  } else {
42313    isAsync = false;
42314  }
42315
42316  this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
42317  return this.finishNode(prop, "Property");
42318};
42319
42320pp$3.parsePropertyValue = function (prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
42321  if ((isGenerator || isAsync) && this.type === types.colon) {
42322    this.unexpected();
42323  }
42324
42325  if (this.eat(types.colon)) {
42326    prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
42327    prop.kind = "init";
42328  } else if (this.options.ecmaVersion >= 6 && this.type === types.parenL) {
42329    if (isPattern) {
42330      this.unexpected();
42331    }
42332
42333    prop.kind = "init";
42334    prop.method = true;
42335    prop.value = this.parseMethod(isGenerator, isAsync);
42336  } else if (!isPattern && !containsEsc && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set") && this.type !== types.comma && this.type !== types.braceR) {
42337    if (isGenerator || isAsync) {
42338      this.unexpected();
42339    }
42340
42341    prop.kind = prop.key.name;
42342    this.parsePropertyName(prop);
42343    prop.value = this.parseMethod(false);
42344    var paramCount = prop.kind === "get" ? 0 : 1;
42345
42346    if (prop.value.params.length !== paramCount) {
42347      var start = prop.value.start;
42348
42349      if (prop.kind === "get") {
42350        this.raiseRecoverable(start, "getter should have no params");
42351      } else {
42352        this.raiseRecoverable(start, "setter should have exactly one param");
42353      }
42354    } else {
42355      if (prop.kind === "set" && prop.value.params[0].type === "RestElement") {
42356        this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params");
42357      }
42358    }
42359  } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
42360    if (isGenerator || isAsync) {
42361      this.unexpected();
42362    }
42363
42364    this.checkUnreserved(prop.key);
42365
42366    if (prop.key.name === "await" && !this.awaitIdentPos) {
42367      this.awaitIdentPos = startPos;
42368    }
42369
42370    prop.kind = "init";
42371
42372    if (isPattern) {
42373      prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
42374    } else if (this.type === types.eq && refDestructuringErrors) {
42375      if (refDestructuringErrors.shorthandAssign < 0) {
42376        refDestructuringErrors.shorthandAssign = this.start;
42377      }
42378
42379      prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
42380    } else {
42381      prop.value = prop.key;
42382    }
42383
42384    prop.shorthand = true;
42385  } else {
42386    this.unexpected();
42387  }
42388};
42389
42390pp$3.parsePropertyName = function (prop) {
42391  if (this.options.ecmaVersion >= 6) {
42392    if (this.eat(types.bracketL)) {
42393      prop.computed = true;
42394      prop.key = this.parseMaybeAssign();
42395      this.expect(types.bracketR);
42396      return prop.key;
42397    } else {
42398      prop.computed = false;
42399    }
42400  }
42401
42402  return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never");
42403}; // Initialize empty function node.
42404
42405
42406pp$3.initFunction = function (node) {
42407  node.id = null;
42408
42409  if (this.options.ecmaVersion >= 6) {
42410    node.generator = node.expression = false;
42411  }
42412
42413  if (this.options.ecmaVersion >= 8) {
42414    node.async = false;
42415  }
42416}; // Parse object or class method.
42417
42418
42419pp$3.parseMethod = function (isGenerator, isAsync, allowDirectSuper) {
42420  var node = this.startNode(),
42421      oldYieldPos = this.yieldPos,
42422      oldAwaitPos = this.awaitPos,
42423      oldAwaitIdentPos = this.awaitIdentPos;
42424  this.initFunction(node);
42425
42426  if (this.options.ecmaVersion >= 6) {
42427    node.generator = isGenerator;
42428  }
42429
42430  if (this.options.ecmaVersion >= 8) {
42431    node.async = !!isAsync;
42432  }
42433
42434  this.yieldPos = 0;
42435  this.awaitPos = 0;
42436  this.awaitIdentPos = 0;
42437  this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
42438  this.expect(types.parenL);
42439  node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
42440  this.checkYieldAwaitInDefaultParams();
42441  this.parseFunctionBody(node, false, true);
42442  this.yieldPos = oldYieldPos;
42443  this.awaitPos = oldAwaitPos;
42444  this.awaitIdentPos = oldAwaitIdentPos;
42445  return this.finishNode(node, "FunctionExpression");
42446}; // Parse arrow function expression with given parameters.
42447
42448
42449pp$3.parseArrowExpression = function (node, params, isAsync) {
42450  var oldYieldPos = this.yieldPos,
42451      oldAwaitPos = this.awaitPos,
42452      oldAwaitIdentPos = this.awaitIdentPos;
42453  this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
42454  this.initFunction(node);
42455
42456  if (this.options.ecmaVersion >= 8) {
42457    node.async = !!isAsync;
42458  }
42459
42460  this.yieldPos = 0;
42461  this.awaitPos = 0;
42462  this.awaitIdentPos = 0;
42463  node.params = this.toAssignableList(params, true);
42464  this.parseFunctionBody(node, true, false);
42465  this.yieldPos = oldYieldPos;
42466  this.awaitPos = oldAwaitPos;
42467  this.awaitIdentPos = oldAwaitIdentPos;
42468  return this.finishNode(node, "ArrowFunctionExpression");
42469}; // Parse function body and check parameters.
42470
42471
42472pp$3.parseFunctionBody = function (node, isArrowFunction, isMethod) {
42473  var isExpression = isArrowFunction && this.type !== types.braceL;
42474  var oldStrict = this.strict,
42475      useStrict = false;
42476
42477  if (isExpression) {
42478    node.body = this.parseMaybeAssign();
42479    node.expression = true;
42480    this.checkParams(node, false);
42481  } else {
42482    var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
42483
42484    if (!oldStrict || nonSimple) {
42485      useStrict = this.strictDirective(this.end); // If this is a strict mode function, verify that argument names
42486      // are not repeated, and it does not try to bind the words `eval`
42487      // or `arguments`.
42488
42489      if (useStrict && nonSimple) {
42490        this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list");
42491      }
42492    } // Start a new scope with regard to labels and the `inFunction`
42493    // flag (restore them to their old value afterwards).
42494
42495
42496    var oldLabels = this.labels;
42497    this.labels = [];
42498
42499    if (useStrict) {
42500      this.strict = true;
42501    } // Add the params to varDeclaredNames to ensure that an error is thrown
42502    // if a let/const declaration in the function clashes with one of the params.
42503
42504
42505    this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
42506    node.body = this.parseBlock(false);
42507    node.expression = false;
42508    this.adaptDirectivePrologue(node.body.body);
42509    this.labels = oldLabels;
42510  }
42511
42512  this.exitScope(); // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
42513
42514  if (this.strict && node.id) {
42515    this.checkLVal(node.id, BIND_OUTSIDE);
42516  }
42517
42518  this.strict = oldStrict;
42519};
42520
42521pp$3.isSimpleParamList = function (params) {
42522  for (var i = 0, list = params; i < list.length; i += 1) {
42523    var param = list[i];
42524
42525    if (param.type !== "Identifier") {
42526      return false;
42527    }
42528  }
42529
42530  return true;
42531}; // Checks function params for various disallowed patterns such as using "eval"
42532// or "arguments" and duplicate parameters.
42533
42534
42535pp$3.checkParams = function (node, allowDuplicates) {
42536  var nameHash = {};
42537
42538  for (var i = 0, list = node.params; i < list.length; i += 1) {
42539    var param = list[i];
42540    this.checkLVal(param, BIND_VAR, allowDuplicates ? null : nameHash);
42541  }
42542}; // Parses a comma-separated list of expressions, and returns them as
42543// an array. `close` is the token type that ends the list, and
42544// `allowEmpty` can be turned on to allow subsequent commas with
42545// nothing in between them to be parsed as `null` (which is needed
42546// for array literals).
42547
42548
42549pp$3.parseExprList = function (close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
42550  var elts = [],
42551      first = true;
42552
42553  while (!this.eat(close)) {
42554    if (!first) {
42555      this.expect(types.comma);
42556
42557      if (allowTrailingComma && this.afterTrailingComma(close)) {
42558        break;
42559      }
42560    } else {
42561      first = false;
42562    }
42563
42564    var elt = void 0;
42565
42566    if (allowEmpty && this.type === types.comma) {
42567      elt = null;
42568    } else if (this.type === types.ellipsis) {
42569      elt = this.parseSpread(refDestructuringErrors);
42570
42571      if (refDestructuringErrors && this.type === types.comma && refDestructuringErrors.trailingComma < 0) {
42572        refDestructuringErrors.trailingComma = this.start;
42573      }
42574    } else {
42575      elt = this.parseMaybeAssign(false, refDestructuringErrors);
42576    }
42577
42578    elts.push(elt);
42579  }
42580
42581  return elts;
42582};
42583
42584pp$3.checkUnreserved = function (ref) {
42585  var start = ref.start;
42586  var end = ref.end;
42587  var name = ref.name;
42588
42589  if (this.inGenerator && name === "yield") {
42590    this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator");
42591  }
42592
42593  if (this.inAsync && name === "await") {
42594    this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function");
42595  }
42596
42597  if (this.keywords.test(name)) {
42598    this.raise(start, "Unexpected keyword '" + name + "'");
42599  }
42600
42601  if (this.options.ecmaVersion < 6 && this.input.slice(start, end).indexOf("\\") !== -1) {
42602    return;
42603  }
42604
42605  var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
42606
42607  if (re.test(name)) {
42608    if (!this.inAsync && name === "await") {
42609      this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function");
42610    }
42611
42612    this.raiseRecoverable(start, "The keyword '" + name + "' is reserved");
42613  }
42614}; // Parse the next token as an identifier. If `liberal` is true (used
42615// when parsing properties), it will also convert keywords into
42616// identifiers.
42617
42618
42619pp$3.parseIdent = function (liberal, isBinding) {
42620  var node = this.startNode();
42621
42622  if (this.type === types.name) {
42623    node.name = this.value;
42624  } else if (this.type.keyword) {
42625    node.name = this.type.keyword; // To fix https://github.com/acornjs/acorn/issues/575
42626    // `class` and `function` keywords push new context into this.context.
42627    // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
42628    // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
42629
42630    if ((node.name === "class" || node.name === "function") && (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
42631      this.context.pop();
42632    }
42633  } else {
42634    this.unexpected();
42635  }
42636
42637  this.next();
42638  this.finishNode(node, "Identifier");
42639
42640  if (!liberal) {
42641    this.checkUnreserved(node);
42642
42643    if (node.name === "await" && !this.awaitIdentPos) {
42644      this.awaitIdentPos = node.start;
42645    }
42646  }
42647
42648  return node;
42649}; // Parses yield expression inside generator.
42650
42651
42652pp$3.parseYield = function (noIn) {
42653  if (!this.yieldPos) {
42654    this.yieldPos = this.start;
42655  }
42656
42657  var node = this.startNode();
42658  this.next();
42659
42660  if (this.type === types.semi || this.canInsertSemicolon() || this.type !== types.star && !this.type.startsExpr) {
42661    node.delegate = false;
42662    node.argument = null;
42663  } else {
42664    node.delegate = this.eat(types.star);
42665    node.argument = this.parseMaybeAssign(noIn);
42666  }
42667
42668  return this.finishNode(node, "YieldExpression");
42669};
42670
42671pp$3.parseAwait = function () {
42672  if (!this.awaitPos) {
42673    this.awaitPos = this.start;
42674  }
42675
42676  var node = this.startNode();
42677  this.next();
42678  node.argument = this.parseMaybeUnary(null, true);
42679  return this.finishNode(node, "AwaitExpression");
42680};
42681
42682var pp$4 = Parser.prototype; // This function is used to raise exceptions on parse errors. It
42683// takes an offset integer (into the current `input`) to indicate
42684// the location of the error, attaches the position to the end
42685// of the error message, and then raises a `SyntaxError` with that
42686// message.
42687
42688pp$4.raise = function (pos, message) {
42689  var loc = getLineInfo(this.input, pos);
42690  message += " (" + loc.line + ":" + loc.column + ")";
42691  var err = new SyntaxError(message);
42692  err.pos = pos;
42693  err.loc = loc;
42694  err.raisedAt = this.pos;
42695  throw err;
42696};
42697
42698pp$4.raiseRecoverable = pp$4.raise;
42699
42700pp$4.curPosition = function () {
42701  if (this.options.locations) {
42702    return new Position(this.curLine, this.pos - this.lineStart);
42703  }
42704};
42705
42706var pp$5 = Parser.prototype;
42707
42708var Scope = function Scope(flags) {
42709  this.flags = flags; // A list of var-declared names in the current lexical scope
42710
42711  this.var = []; // A list of lexically-declared names in the current lexical scope
42712
42713  this.lexical = []; // A list of lexically-declared FunctionDeclaration names in the current lexical scope
42714
42715  this.functions = [];
42716}; // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
42717
42718
42719pp$5.enterScope = function (flags) {
42720  this.scopeStack.push(new Scope(flags));
42721};
42722
42723pp$5.exitScope = function () {
42724  this.scopeStack.pop();
42725}; // The spec says:
42726// > At the top level of a function, or script, function declarations are
42727// > treated like var declarations rather than like lexical declarations.
42728
42729
42730pp$5.treatFunctionsAsVarInScope = function (scope) {
42731  return scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_TOP;
42732};
42733
42734pp$5.declareName = function (name, bindingType, pos) {
42735  var redeclared = false;
42736
42737  if (bindingType === BIND_LEXICAL) {
42738    var scope = this.currentScope();
42739    redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
42740    scope.lexical.push(name);
42741
42742    if (this.inModule && scope.flags & SCOPE_TOP) {
42743      delete this.undefinedExports[name];
42744    }
42745  } else if (bindingType === BIND_SIMPLE_CATCH) {
42746    var scope$1 = this.currentScope();
42747    scope$1.lexical.push(name);
42748  } else if (bindingType === BIND_FUNCTION) {
42749    var scope$2 = this.currentScope();
42750
42751    if (this.treatFunctionsAsVar) {
42752      redeclared = scope$2.lexical.indexOf(name) > -1;
42753    } else {
42754      redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1;
42755    }
42756
42757    scope$2.functions.push(name);
42758  } else {
42759    for (var i = this.scopeStack.length - 1; i >= 0; --i) {
42760      var scope$3 = this.scopeStack[i];
42761
42762      if (scope$3.lexical.indexOf(name) > -1 && !(scope$3.flags & SCOPE_SIMPLE_CATCH && scope$3.lexical[0] === name) || !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
42763        redeclared = true;
42764        break;
42765      }
42766
42767      scope$3.var.push(name);
42768
42769      if (this.inModule && scope$3.flags & SCOPE_TOP) {
42770        delete this.undefinedExports[name];
42771      }
42772
42773      if (scope$3.flags & SCOPE_VAR) {
42774        break;
42775      }
42776    }
42777  }
42778
42779  if (redeclared) {
42780    this.raiseRecoverable(pos, "Identifier '" + name + "' has already been declared");
42781  }
42782};
42783
42784pp$5.checkLocalExport = function (id) {
42785  // scope.functions must be empty as Module code is always strict.
42786  if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1) {
42787    this.undefinedExports[id.name] = id;
42788  }
42789};
42790
42791pp$5.currentScope = function () {
42792  return this.scopeStack[this.scopeStack.length - 1];
42793};
42794
42795pp$5.currentVarScope = function () {
42796  for (var i = this.scopeStack.length - 1;; i--) {
42797    var scope = this.scopeStack[i];
42798
42799    if (scope.flags & SCOPE_VAR) {
42800      return scope;
42801    }
42802  }
42803}; // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
42804
42805
42806pp$5.currentThisScope = function () {
42807  for (var i = this.scopeStack.length - 1;; i--) {
42808    var scope = this.scopeStack[i];
42809
42810    if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) {
42811      return scope;
42812    }
42813  }
42814};
42815
42816var Node = function Node(parser, pos, loc) {
42817  this.type = "";
42818  this.start = pos;
42819  this.end = 0;
42820
42821  if (parser.options.locations) {
42822    this.loc = new SourceLocation(parser, loc);
42823  }
42824
42825  if (parser.options.directSourceFile) {
42826    this.sourceFile = parser.options.directSourceFile;
42827  }
42828
42829  if (parser.options.ranges) {
42830    this.range = [pos, 0];
42831  }
42832}; // Start an AST node, attaching a start offset.
42833
42834
42835exports.Node = Node;
42836var pp$6 = Parser.prototype;
42837
42838pp$6.startNode = function () {
42839  return new Node(this, this.start, this.startLoc);
42840};
42841
42842pp$6.startNodeAt = function (pos, loc) {
42843  return new Node(this, pos, loc);
42844}; // Finish an AST node, adding `type` and `end` properties.
42845
42846
42847function finishNodeAt(node, type, pos, loc) {
42848  node.type = type;
42849  node.end = pos;
42850
42851  if (this.options.locations) {
42852    node.loc.end = loc;
42853  }
42854
42855  if (this.options.ranges) {
42856    node.range[1] = pos;
42857  }
42858
42859  return node;
42860}
42861
42862pp$6.finishNode = function (node, type) {
42863  return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc);
42864}; // Finish node at given position
42865
42866
42867pp$6.finishNodeAt = function (node, type, pos, loc) {
42868  return finishNodeAt.call(this, node, type, pos, loc);
42869}; // The algorithm used to determine whether a regexp can appear at a
42870
42871
42872var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
42873  this.token = token;
42874  this.isExpr = !!isExpr;
42875  this.preserveSpace = !!preserveSpace;
42876  this.override = override;
42877  this.generator = !!generator;
42878};
42879
42880exports.TokContext = TokContext;
42881var types$1 = {
42882  b_stat: new TokContext("{", false),
42883  b_expr: new TokContext("{", true),
42884  b_tmpl: new TokContext("${", false),
42885  p_stat: new TokContext("(", false),
42886  p_expr: new TokContext("(", true),
42887  q_tmpl: new TokContext("`", true, true, function (p) {
42888    return p.tryReadTemplateToken();
42889  }),
42890  f_stat: new TokContext("function", false),
42891  f_expr: new TokContext("function", true),
42892  f_expr_gen: new TokContext("function", true, false, null, true),
42893  f_gen: new TokContext("function", false, false, null, true)
42894};
42895exports.tokContexts = types$1;
42896var pp$7 = Parser.prototype;
42897
42898pp$7.initialContext = function () {
42899  return [types$1.b_stat];
42900};
42901
42902pp$7.braceIsBlock = function (prevType) {
42903  var parent = this.curContext();
42904
42905  if (parent === types$1.f_expr || parent === types$1.f_stat) {
42906    return true;
42907  }
42908
42909  if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr)) {
42910    return !parent.isExpr;
42911  } // The check for `tt.name && exprAllowed` detects whether we are
42912  // after a `yield` or `of` construct. See the `updateContext` for
42913  // `tt.name`.
42914
42915
42916  if (prevType === types._return || prevType === types.name && this.exprAllowed) {
42917    return lineBreak.test(this.input.slice(this.lastTokEnd, this.start));
42918  }
42919
42920  if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow) {
42921    return true;
42922  }
42923
42924  if (prevType === types.braceL) {
42925    return parent === types$1.b_stat;
42926  }
42927
42928  if (prevType === types._var || prevType === types._const || prevType === types.name) {
42929    return false;
42930  }
42931
42932  return !this.exprAllowed;
42933};
42934
42935pp$7.inGeneratorContext = function () {
42936  for (var i = this.context.length - 1; i >= 1; i--) {
42937    var context = this.context[i];
42938
42939    if (context.token === "function") {
42940      return context.generator;
42941    }
42942  }
42943
42944  return false;
42945};
42946
42947pp$7.updateContext = function (prevType) {
42948  var update,
42949      type = this.type;
42950
42951  if (type.keyword && prevType === types.dot) {
42952    this.exprAllowed = false;
42953  } else if (update = type.updateContext) {
42954    update.call(this, prevType);
42955  } else {
42956    this.exprAllowed = type.beforeExpr;
42957  }
42958}; // Token-specific context update code
42959
42960
42961types.parenR.updateContext = types.braceR.updateContext = function () {
42962  if (this.context.length === 1) {
42963    this.exprAllowed = true;
42964    return;
42965  }
42966
42967  var out = this.context.pop();
42968
42969  if (out === types$1.b_stat && this.curContext().token === "function") {
42970    out = this.context.pop();
42971  }
42972
42973  this.exprAllowed = !out.isExpr;
42974};
42975
42976types.braceL.updateContext = function (prevType) {
42977  this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr);
42978  this.exprAllowed = true;
42979};
42980
42981types.dollarBraceL.updateContext = function () {
42982  this.context.push(types$1.b_tmpl);
42983  this.exprAllowed = true;
42984};
42985
42986types.parenL.updateContext = function (prevType) {
42987  var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
42988  this.context.push(statementParens ? types$1.p_stat : types$1.p_expr);
42989  this.exprAllowed = true;
42990};
42991
42992types.incDec.updateContext = function () {// tokExprAllowed stays unchanged
42993}
vendor: 5,268 bytes, lines 42993-43056
42993;
42994
42995types._function.updateContext = types._class.updateContext = function (prevType) {
42996  if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else && !(prevType === types._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) && !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat)) {
42997    this.context.push(types$1.f_expr);
42998  } else {
42999    this.context.push(types$1.f_stat);
43000  }
43001
43002  this.exprAllowed = false;
43003};
43004
43005types.backQuote.updateContext = function () {
43006  if (this.curContext() === types$1.q_tmpl) {
43007    this.context.pop();
43008  } else {
43009    this.context.push(types$1.q_tmpl);
43010  }
43011
43012  this.exprAllowed = false;
43013};
43014
43015types.star.updateContext = function (prevType) {
43016  if (prevType === types._function) {
43017    var index = this.context.length - 1;
43018
43019    if (this.context[index] === types$1.f_expr) {
43020      this.context[index] = types$1.f_expr_gen;
43021    } else {
43022      this.context[index] = types$1.f_gen;
43023    }
43024  }
43025
43026  this.exprAllowed = true;
43027};
43028
43029types.name.updateContext = function (prevType) {
43030  var allowed = false;
43031
43032  if (this.options.ecmaVersion >= 6 && prevType !== types.dot) {
43033    if (this.value === "of" && !this.exprAllowed || this.value === "yield" && this.inGeneratorContext()) {
43034      allowed = true;
43035    }
43036  }
43037
43038  this.exprAllowed = allowed;
43039}; // This file contains Unicode properties extracted from the ECMAScript
43040// specification. The lists are extracted like so:
43041// $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
43042// #table-binary-unicode-properties
43043
43044
43045var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS";
43046var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
43047var ecma11BinaryProperties = ecma10BinaryProperties;
43048var unicodeBinaryProperties = {
43049  9: ecma9BinaryProperties,
43050  10: ecma10BinaryProperties,
43051  11: ecma11BinaryProperties
43052}; // #table-unicode-general-category-values
43053
43054var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu"; // #table-unicode-script-values
43055
43056var ecma9ScriptValues = "Adlam Adlm Ahom Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Re
43056jang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
43057var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
43058var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
43059var unicodeScriptValues = {
43060  9: ecma9ScriptValues,
43061  10: ecma10ScriptValues,
43062  11: ecma11ScriptValues
43063};
43064var data = {};
43065
43066function buildUnicodeData(ecmaVersion) {
43067  var d = data[ecmaVersion] = {
43068    binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
43069    nonBinary: {
43070      General_Category: wordsRegexp(unicodeGeneralCategoryValues),
43071      Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
43072    }
43073  };
43074  d.nonBinary.Script_Extensions = d.nonBinary.Script;
43075  d.nonBinary.gc = d.nonBinary.General_Category;
43076  d.nonBinary.sc = d.nonBinary.Script;
43077  d.nonBinary.scx = d.nonBinary.Script_Extensions;
43078}
43079
43080buildUnicodeData(9);
43081buildUnicodeData(10);
43082buildUnicodeData(11);
43083var pp$8 = Parser.prototype;
43084
43085var RegExpValidationState = function RegExpValidationState(parser) {
43086  this.parser = parser;
43087  this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "");
43088  this.unicodeProperties = data[parser.options.ecmaVersion >= 11 ? 11 : parser.options.ecmaVersion];
43089  this.source = "";
43090  this.flags = "";
43091  this.start = 0;
43092  this.switchU = false;
43093  this.switchN = false;
43094  this.pos = 0;
43095  this.lastIntValue = 0;
43096  this.lastStringValue = "";
43097  this.lastAssertionIsQuantifiable = false;
43098  this.numCapturingParens = 0;
43099  this.maxBackReference = 0;
43100  this.groupNames = [];
43101  this.backReferenceNames = [];
43102};
43103
43104RegExpValidationState.prototype.reset = function reset(start, pattern, flags) {
43105  var unicode = flags.indexOf("u") !== -1;
43106  this.start = start | 0;
43107  this.source = pattern + "";
43108  this.flags = flags;
43109  this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
43110  this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
43111};
43112
43113RegExpValidationState.prototype.raise = function raise(message) {
43114  this.parser.raiseRecoverable(this.start, "Invalid regular expression: /" + this.source + "/: " + message);
43115}; // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
43116// Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
43117
43118
43119RegExpValidationState.prototype.at = function at(i) {
43120  var s = this.source;
43121  var l = s.length;
43122
43123  if (i >= l) {
43124    return -1;
43125  }
43126
43127  var c = s.charCodeAt(i);
43128
43129  if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
43130    return c;
43131  }
43132
43133  var next = s.charCodeAt(i + 1);
43134  return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c;
43135};
43136
43137RegExpValidationState.prototype.nextIndex = function nextIndex(i) {
43138  var s = this.source;
43139  var l = s.length;
43140
43141  if (i >= l) {
43142    return l;
43143  }
43144
43145  var c = s.charCodeAt(i),
43146      next;
43147
43148  if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
43149    return i + 1;
43150  }
43151
43152  return i + 2;
43153};
43154
43155RegExpValidationState.prototype.current = function current() {
43156  return this.at(this.pos);
43157};
43158
43159RegExpValidationState.prototype.lookahead = function lookahead() {
43160  return this.at(this.nextIndex(this.pos));
43161};
43162
43163RegExpValidationState.prototype.advance = function advance() {
43164  this.pos = this.nextIndex(this.pos);
43165};
43166
43167RegExpValidationState.prototype.eat = function eat(ch) {
43168  if (this.current() === ch) {
43169    this.advance();
43170    return true;
43171  }
43172
43173  return false;
43174};
43175
43176function codePointToString(ch) {
43177  if (ch <= 0xFFFF) {
43178    return String.fromCharCode(ch);
43179  }
43180
43181  ch -= 0x10000;
43182  return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00);
43183}
43184/**
43185 * Validate the flags part of a given RegExpLiteral.
43186 *
43187 * @param {RegExpValidationState} state The state to validate RegExp.
43188 * @returns {void}
43189 */
43190
43191
43192pp$8.validateRegExpFlags = function (state) {
vendor: 4,116 bytes, lines 43193-43356
43193  var validFlags = state.validFlags;
43194  var flags = state.flags;
43195
43196  for (var i = 0; i < flags.length; i++) {
43197    var flag = flags.charAt(i);
43198
43199    if (validFlags.indexOf(flag) === -1) {
43200      this.raise(state.start, "Invalid regular expression flag");
43201    }
43202
43203    if (flags.indexOf(flag, i + 1) > -1) {
43204      this.raise(state.start, "Duplicate regular expression flag");
43205    }
43206  }
43207};
43208/**
43209 * Validate the pattern part of a given RegExpLiteral.
43210 *
43211 * @param {RegExpValidationState} state The state to validate RegExp.
43212 * @returns {void}
43213 */
43214
43215
43216pp$8.validateRegExpPattern = function (state) {
43217  this.regexp_pattern(state); // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
43218  // parsing contains a |GroupName|, reparse with the goal symbol
43219  // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
43220  // exception if _P_ did not conform to the grammar, if any elements of _P_
43221  // were not matched by the parse, or if any Early Error conditions exist.
43222
43223  if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
43224    state.switchN = true;
43225    this.regexp_pattern(state);
43226  }
43227}; // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
43228
43229
43230pp$8.regexp_pattern = function (state) {
43231  state.pos = 0;
43232  state.lastIntValue = 0;
43233  state.lastStringValue = "";
43234  state.lastAssertionIsQuantifiable = false;
43235  state.numCapturingParens = 0;
43236  state.maxBackReference = 0;
43237  state.groupNames.length = 0;
43238  state.backReferenceNames.length = 0;
43239  this.regexp_disjunction(state);
43240
43241  if (state.pos !== state.source.length) {
43242    // Make the same messages as V8.
43243    if (state.eat(0x29
43244    /* ) */
43245    )) {
43246      state.raise("Unmatched ')'");
43247    }
43248
43249    if (state.eat(0x5D
43250    /* [ */
43251    ) || state.eat(0x7D
43252    /* } */
43253    )) {
43254      state.raise("Lone quantifier brackets");
43255    }
43256  }
43257
43258  if (state.maxBackReference > state.numCapturingParens) {
43259    state.raise("Invalid escape");
43260  }
43261
43262  for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
43263    var name = list[i];
43264
43265    if (state.groupNames.indexOf(name) === -1) {
43266      state.raise("Invalid named capture referenced");
43267    }
43268  }
43269}; // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
43270
43271
43272pp$8.regexp_disjunction = function (state) {
43273  this.regexp_alternative(state);
43274
43275  while (state.eat(0x7C
43276  /* | */
43277  )) {
43278    this.regexp_alternative(state);
43279  } // Make the same message as V8.
43280
43281
43282  if (this.regexp_eatQuantifier(state, true)) {
43283    state.raise("Nothing to repeat");
43284  }
43285
43286  if (state.eat(0x7B
43287  /* { */
43288  )) {
43289    state.raise("Lone quantifier brackets");
43290  }
43291}; // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
43292
43293
43294pp$8.regexp_alternative = function (state) {
43295  while (state.pos < state.source.length && this.regexp_eatTerm(state)) {}
43296}; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
43297
43298
43299pp$8.regexp_eatTerm = function (state) {
43300  if (this.regexp_eatAssertion(state)) {
43301    // Handle `QuantifiableAssertion Quantifier` alternative.
43302    // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
43303    // is a QuantifiableAssertion.
43304    if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
43305      // Make the same message as V8.
43306      if (state.switchU) {
43307        state.raise("Invalid quantifier");
43308      }
43309    }
43310
43311    return true;
43312  }
43313
43314  if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
43315    this.regexp_eatQuantifier(state);
43316    return true;
43317  }
43318
43319  return false;
43320}; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
43321
43322
43323pp$8.regexp_eatAssertion = function (state) {
43324  var start = state.pos;
43325  state.lastAssertionIsQuantifiable = false; // ^, $
43326
43327  if (state.eat(0x5E
43328  /* ^ */
43329  ) || state.eat(0x24
43330  /* $ */
43331  )) {
43332    return true;
43333  } // \b \B
43334
43335
43336  if (state.eat(0x5C
43337  /* \ */
43338  )) {
43339    if (state.eat(0x42
43340    /* B */
43341    ) || state.eat(0x62
43342    /* b */
43343    )) {
43344      return true;
43345    }
43346
43347    state.pos = start;
43348  } // Lookahead / Lookbehind
43349
43350
43351  if (state.eat(0x28
43352  /* ( */
43353  ) && state.eat(0x3F
43354  /* ? */
43355  )) {
43356    var lookbehind = false;
43357
43358    if (this.options.ecmaVersion >= 9) {
43359      lookbehind = state.eat(0x3C
43360      /* < */
43361      );
43362    }
43363
43364    if (state.eat(0x3D
43365    /* = */
43366    ) || state.eat(0x21
43367    /* ! */
43368    )) {
43369      this.regexp_disjunction(state);
43370
43371      if (!state.eat(0x29
43372      /* ) */
43373      )) {
43374        state.raise("Unterminated group");
43375      }
43376
43377      state.lastAssertionIsQuantifiable = !lookbehind;
43378      return true;
43379    }
43380  }
43381
43382  state.pos = start;
43383  return false;
43384}; // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
43385
43386
43387pp$8.regexp_eatQuantifier = function (state, noError) {
43388  if (noError === void 0) noError = false;
43389
43390  if (this.regexp_eatQuantifierPrefix(state, noError)) {
43391    state.eat(0x3F
43392    /* ? */
43393    );
43394    return true;
43395  }
43396
43397  return false;
43398}; // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
43399
43400
43401pp$8.regexp_eatQuantifierPrefix = function (state, noError) {
43402  return state.eat(0x2A
43403  /* * */
43404  ) || state.eat(0x2B
43405  /* + */
43406  ) || state.eat(0x3F
43407  /* ? */
43408  ) || this.regexp_eatBracedQuantifier(state, noError);
43409};
43410
43411pp$8.regexp_eatBracedQuantifier = function (state, noError) {
43412  var start = state.pos;
43413
43414  if (state.eat(0x7B
43415  /* { */
43416  )) {
43417    var min = 0,
43418        max = -1;
43419
43420    if (this.regexp_eatDecimalDigits(state)) {
43421      min = state.lastIntValue;
43422
43423      if (state.eat(0x2C
43424      /* , */
43425      ) && this.regexp_eatDecimalDigits(state)) {
43426        max = state.lastIntValue;
43427      }
43428
43429      if (state.eat(0x7D
43430      /* } */
43431      )) {
43432        // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
43433        if (max !== -1 && max < min && !noError) {
43434          state.raise("numbers out of order in {} quantifier");
43435        }
43436
43437        return true;
43438      }
43439    }
43440
43441    if (state.switchU && !noError) {
43442      state.raise("Incomplete quantifier");
43443    }
43444
43445    state.pos = start;
43446  }
43447
43448  return false;
43449}; // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
43450
43451
43452pp$8.regexp_eatAtom = function (state) {
43453  return this.regexp_eatPatternCharacters(state) || state.eat(0x2E
43454  /* . */
43455  ) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state);
43456};
43457
43458pp$8.regexp_eatReverseSolidusAtomEscape = function (state) {
43459  var start = state.pos;
43460
43461  if (state.eat(0x5C
43462  /* \ */
43463  )) {
43464    if (this.regexp_eatAtomEscape(state)) {
43465      return true;
43466    }
43467
43468    state.pos = start;
43469  }
43470
43471  return false;
43472};
43473
43474pp$8.regexp_eatUncapturingGroup = function (state) {
43475  var start = state.pos;
43476
43477  if (state.eat(0x28
43478  /* ( */
43479  )) {
43480    if (state.eat(0x3F
43481    /* ? */
43482    ) && state.eat(0x3A
43483    /* : */
43484    )) {
43485      this.regexp_disjunction(state);
43486
43487      if (state.eat(0x29
43488      /* ) */
43489      )) {
43490        return true;
43491      }
43492
43493      state.raise("Unterminated group");
43494    }
43495
43496    state.pos = start;
43497  }
43498
43499  return false;
43500};
43501
43502pp$8.regexp_eatCapturingGroup = function (state) {
43503  if (state.eat(0x28
43504  /* ( */
43505  )) {
43506    if (this.options.ecmaVersion >= 9) {
43507      this.regexp_groupSpecifier(state);
43508    } else if (state.current() === 0x3F
43509    /* ? */
43510    ) {
43511        state.raise("Invalid group");
43512      }
43513
43514    this.regexp_disjunction(state);
43515
43516    if (state.eat(0x29
43517    /* ) */
43518    )) {
43519      state.numCapturingParens += 1;
43520      return true;
43521    }
43522
43523    state.raise("Unterminated group");
43524  }
43525
43526  return false;
43527}; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
43528
43529
43530pp$8.regexp_eatExtendedAtom = function (state) {
43531  return state.eat(0x2E
43532  /* . */
43533  ) || this.regexp_eatReverseSolidusAtomEscape(state) || this.regexp_eatCharacterClass(state) || this.regexp_eatUncapturingGroup(state) || this.regexp_eatCapturingGroup(state) || this.regexp_eatInvalidBracedQuantifier(state) || this.regexp_eatExtendedPatternCharacter(state);
43534}; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
43535
43536
43537pp$8.regexp_eatInvalidBracedQuantifier = function (state) {
43538  if (this.regexp_eatBracedQuantifier(state, true)) {
43539    state.raise("Nothing to repeat");
43540  }
43541
43542  return false;
43543}; // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
43544
43545
43546pp$8.regexp_eatSyntaxCharacter = function (state) {
43547  var ch = state.current();
43548
43549  if (isSyntaxCharacter(ch)) {
43550    state.lastIntValue = ch;
43551    state.advance();
43552    return true;
43553  }
43554
43555  return false;
43556};
43557
43558function isSyntaxCharacter(ch) {
43559  return ch === 0x24
43560  /* $ */
43561  || ch >= 0x28
43562  /* ( */
43563  && ch <= 0x2B
43564  /* + */
43565  || ch === 0x2E
43566  /* . */
43567  || ch === 0x3F
43568  /* ? */
43569  || ch >= 0x5B
43570  /* [ */
43571  && ch <= 0x5E
43572  /* ^ */
43573  || ch >= 0x7B
43574  /* { */
43575  && ch <= 0x7D
43576  /* } */
43577  ;
43578} // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
43579// But eat eager.
43580
43581
43582pp$8.regexp_eatPatternCharacters = function (state) {
43583  var start = state.pos;
43584  var ch = 0;
43585
43586  while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
43587    state.advance();
43588  }
43589
43590  return state.pos !== start;
43591}; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
43592
43593
43594pp$8.regexp_eatExtendedPatternCharacter = function (state) {
43595  var ch = state.current();
43596
43597  if (ch !== -1 && ch !== 0x24
43598  /* $ */
43599  && !(ch >= 0x28
43600  /* ( */
43601  && ch <= 0x2B
43602  /* + */
43603  ) && ch !== 0x2E
43604  /* . */
43605  && ch !== 0x3F
43606  /* ? */
43607  && ch !== 0x5B
43608  /* [ */
43609  && ch !== 0x5E
43610  /* ^ */
43611  && ch !== 0x7C
43612  /* | */
43613  ) {
43614      state.advance();
43615      return true;
43616    }
43617
43618  return false;
43619}; // GroupSpecifier[U] ::
43620//   [empty]
43621//   `?` GroupName[?U]
43622
43623
43624pp$8.regexp_groupSpecifier = function (state) {
43625  if (state.eat(0x3F
43626  /* ? */
43627  )) {
43628    if (this.regexp_eatGroupName(state)) {
43629      if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
43630        state.raise("Duplicate capture group name");
43631      }
43632
43633      state.groupNames.push(state.lastStringValue);
43634      return;
43635    }
43636
43637    state.raise("Invalid group");
43638  }
43639}; // GroupName[U] ::
43640//   `<` RegExpIdentifierName[?U] `>`
43641// Note: this updates `state.lastStringValue` property with the eaten name.
43642
43643
43644pp$8.regexp_eatGroupName = function (state) {
43645  state.lastStringValue = "";
43646
43647  if (state.eat(0x3C
43648  /* < */
43649  )) {
43650    if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E
43651    /* > */
43652    )) {
43653      return true;
43654    }
43655
43656    state.raise("Invalid capture group name");
43657  }
43658
43659  return false;
43660}; // RegExpIdentifierName[U] ::
43661//   RegExpIdentifierStart[?U]
43662//   RegExpIdentifierName[?U] RegExpIdentifierPart[?U]
43663// Note: this updates `state.lastStringValue` property with the eaten name.
43664
43665
43666pp$8.regexp_eatRegExpIdentifierName = function (state) {
43667  state.lastStringValue = "";
43668
43669  if (this.regexp_eatRegExpIdentifierStart(state)) {
43670    state.lastStringValue += codePointToString(state.lastIntValue);
43671
43672    while (this.regexp_eatRegExpIdentifierPart(state)) {
43673      state.lastStringValue += codePointToString(state.lastIntValue);
43674    }
43675
43676    return true;
43677  }
43678
43679  return false;
43680}; // RegExpIdentifierStart[U] ::
43681//   UnicodeIDStart
43682//   `$`
43683//   `_`
43684//   `\` RegExpUnicodeEscapeSequence[?U]
43685
43686
43687pp$8.regexp_eatRegExpIdentifierStart = function (state) {
43688  var start = state.pos;
43689  var ch = state.current();
43690  state.advance();
43691
43692  if (ch === 0x5C
43693  /* \ */
43694  && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {
43695    ch = state.lastIntValue;
43696  }
43697
43698  if (isRegExpIdentifierStart(ch)) {
43699    state.lastIntValue = ch;
43700    return true;
43701  }
43702
43703  state.pos = start;
43704  return false;
43705};
43706
43707function isRegExpIdentifierStart(ch) {
43708  return isIdentifierStart(ch, true) || ch === 0x24
43709  /* $ */
43710  || ch === 0x5F;
43711  /* _ */
43712} // RegExpIdentifierPart[U] ::
43713//   UnicodeIDContinue
43714//   `$`
43715//   `_`
43716//   `\` RegExpUnicodeEscapeSequence[?U]
43717//   <ZWNJ>
43718//   <ZWJ>
43719
43720
43721pp$8.regexp_eatRegExpIdentifierPart = function (state) {
43722  var start = state.pos;
43723  var ch = state.current();
43724  state.advance();
43725
43726  if (ch === 0x5C
43727  /* \ */
43728  && this.regexp_eatRegExpUnicodeEscapeSequence(state)) {
43729    ch = state.lastIntValue;
43730  }
43731
43732  if (isRegExpIdentifierPart(ch)) {
43733    state.lastIntValue = ch;
43734    return true;
43735  }
43736
43737  state.pos = start;
43738  return false;
43739};
43740
43741function isRegExpIdentifierPart(ch) {
43742  return isIdentifierChar(ch, true) || ch === 0x24
43743  /* $ */
43744  || ch === 0x5F
43745  /* _ */
43746  || ch === 0x200C
43747  /* <ZWNJ> */
43748  || ch === 0x200D;
43749  /* <ZWJ> */
43750} // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
43751
43752
43753pp$8.regexp_eatAtomEscape = function (state) {
43754  if (this.regexp_eatBackReference(state) || this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state) || state.switchN && this.regexp_eatKGroupName(state)) {
43755    return true;
43756  }
43757
43758  if (state.switchU) {
43759    // Make the same message as V8.
43760    if (state.current() === 0x63
43761    /* c */
43762    ) {
43763        state.raise("Invalid unicode escape");
43764      }
43765
43766    state.raise("Invalid escape");
43767  }
43768
43769  return false;
43770};
43771
43772pp$8.regexp_eatBackReference = function (state) {
43773  var start = state.pos;
43774
43775  if (this.regexp_eatDecimalEscape(state)) {
43776    var n = state.lastIntValue;
43777
43778    if (state.switchU) {
43779      // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
43780      if (n > state.maxBackReference) {
43781        state.maxBackReference = n;
43782      }
43783
43784      return true;
43785    }
43786
43787    if (n <= state.numCapturingParens) {
43788      return true;
43789    }
43790
43791    state.pos = start;
43792  }
43793
43794  return false;
43795};
43796
43797pp$8.regexp_eatKGroupName = function (state) {
43798  if (state.eat(0x6B
43799  /* k */
43800  )) {
43801    if (this.regexp_eatGroupName(state)) {
43802      state.backReferenceNames.push(state.lastStringValue);
43803      return true;
43804    }
43805
43806    state.raise("Invalid named reference");
43807  }
43808
43809  return false;
43810}; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
43811
43812
43813pp$8.regexp_eatCharacterEscape = function (state) {
43814  return this.regexp_eatControlEscape(state) || this.regexp_eatCControlLetter(state) || this.regexp_eatZero(state) || this.regexp_eatHexEscapeSequence(state) || this.regexp_eatRegExpUnicodeEscapeSequence(state) || !state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state) || this.regexp_eatIdentityEscape(state);
43815};
43816
43817pp$8.regexp_eatCControlLetter = function (state) {
43818  var start = state.pos;
43819
43820  if (state.eat(0x63
43821  /* c */
43822  )) {
43823    if (this.regexp_eatControlLetter(state)) {
43824      return true;
43825    }
43826
43827    state.pos = start;
43828  }
43829
43830  return false;
43831};
43832
43833pp$8.regexp_eatZero = function (state) {
43834  if (state.current() === 0x30
43835  /* 0 */
43836  && !isDecimalDigit(state.lookahead())) {
43837    state.lastIntValue = 0;
43838    state.advance();
43839    return true;
43840  }
43841
43842  return false;
43843}; // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
43844
43845
43846pp$8.regexp_eatControlEscape = function (state) {
43847  var ch = state.current();
43848
43849  if (ch === 0x74
43850  /* t */
43851  ) {
43852      state.lastIntValue = 0x09;
43853      /* \t */
43854
43855      state.advance();
43856      return true;
43857    }
43858
43859  if (ch === 0x6E
43860  /* n */
43861  ) {
43862      state.lastIntValue = 0x0A;
43863      /* \n */
43864
43865      state.advance();
43866      return true;
43867    }
43868
43869  if (ch === 0x76
43870  /* v */
43871  ) {
43872      state.lastIntValue = 0x0B;
43873      /* \v */
43874
43875      state.advance();
43876      return true;
43877    }
43878
43879  if (ch === 0x66
43880  /* f */
43881  ) {
43882      state.lastIntValue = 0x0C;
43883      /* \f */
43884
43885      state.advance();
43886      return true;
43887    }
43888
43889  if (ch === 0x72
43890  /* r */
43891  ) {
43892      state.lastIntValue = 0x0D;
43893      /* \r */
43894
43895      state.advance();
43896      return true;
43897    }
43898
43899  return false;
43900}; // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
43901
43902
43903pp$8.regexp_eatControlLetter = function (state) {
43904  var ch = state.current();
43905
43906  if (isControlLetter(ch)) {
43907    state.lastIntValue = ch % 0x20;
43908    state.advance();
43909    return true;
43910  }
43911
43912  return false;
43913};
43914
43915function isControlLetter(ch) {
43916  return ch >= 0x41
43917  /* A */
43918  && ch <= 0x5A
43919  /* Z */
43920  || ch >= 0x61
43921  /* a */
43922  && ch <= 0x7A
43923  /* z */
43924  ;
43925} // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
43926
43927
43928pp$8.regexp_eatRegExpUnicodeEscapeSequence = function (state) {
43929  var start = state.pos;
43930
43931  if (state.eat(0x75
43932  /* u */
43933  )) {
43934    if (this.regexp_eatFixedHexDigits(state, 4)) {
43935      var lead = state.lastIntValue;
43936
43937      if (state.switchU && lead >= 0xD800 && lead <= 0xDBFF) {
43938        var leadSurrogateEnd = state.pos;
43939
43940        if (state.eat(0x5C
43941        /* \ */
43942        ) && state.eat(0x75
43943        /* u */
43944        ) && this.regexp_eatFixedHexDigits(state, 4)) {
43945          var trail = state.lastIntValue;
43946
43947          if (trail >= 0xDC00 && trail <= 0xDFFF) {
43948            state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
43949            return true;
43950          }
43951        }
43952
43953        state.pos = leadSurrogateEnd;
43954        state.lastIntValue = lead;
43955      }
43956
43957      return true;
43958    }
43959
43960    if (state.switchU && state.eat(0x7B
43961    /* { */
43962    ) && this.regexp_eatHexDigits(state) && state.eat(0x7D
43963    /* } */
43964    ) && isValidUnicode(state.lastIntValue)) {
43965      return true;
43966    }
43967
43968    if (state.switchU) {
43969      state.raise("Invalid unicode escape");
43970    }
43971
43972    state.pos = start;
43973  }
43974
43975  return false;
43976};
43977
43978function isValidUnicode(ch) {
43979  return ch >= 0 && ch <= 0x10FFFF;
43980} // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
43981
43982
43983pp$8.regexp_eatIdentityEscape = function (state) {
43984  if (state.switchU) {
43985    if (this.regexp_eatSyntaxCharacter(state)) {
43986      return true;
43987    }
43988
43989    if (state.eat(0x2F
43990    /* / */
43991    )) {
43992      state.lastIntValue = 0x2F;
43993      /* / */
43994
43995      return true;
43996    }
43997
43998    return false;
43999  }
44000
44001  var ch = state.current();
44002
44003  if (ch !== 0x63
44004  /* c */
44005  && (!state.switchN || ch !== 0x6B
44006  /* k */
44007  )) {
44008    state.lastIntValue = ch;
44009    state.advance();
44010    return true;
44011  }
44012
44013  return false;
44014}; // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
44015
44016
44017pp$8.regexp_eatDecimalEscape = function (state) {
44018  state.lastIntValue = 0;
44019  var ch = state.current();
44020
44021  if (ch >= 0x31
44022  /* 1 */
44023  && ch <= 0x39
44024  /* 9 */
44025  ) {
44026      do {
44027        state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30
44028        /* 0 */
44029        );
44030        state.advance();
44031      } while ((ch = state.current()) >= 0x30
44032      /* 0 */
44033      && ch <= 0x39
44034      /* 9 */
44035      );
44036
44037      return true;
44038    }
44039
44040  return false;
44041}; // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
44042
44043
44044pp$8.regexp_eatCharacterClassEscape = function (state) {
44045  var ch = state.current();
44046
44047  if (isCharacterClassEscape(ch)) {
44048    state.lastIntValue = -1;
44049    state.advance();
44050    return true;
44051  }
44052
44053  if (state.switchU && this.options.ecmaVersion >= 9 && (ch === 0x50
44054  /* P */
44055  || ch === 0x70
44056  /* p */
44057  )) {
44058    state.lastIntValue = -1;
44059    state.advance();
44060
44061    if (state.eat(0x7B
44062    /* { */
44063    ) && this.regexp_eatUnicodePropertyValueExpression(state) && state.eat(0x7D
44064    /* } */
44065    )) {
44066      return true;
44067    }
44068
44069    state.raise("Invalid property name");
44070  }
44071
44072  return false;
44073};
44074
44075function isCharacterClassEscape(ch) {
44076  return ch === 0x64
44077  /* d */
44078  || ch === 0x44
44079  /* D */
44080  || ch === 0x73
44081  /* s */
44082  || ch === 0x53
44083  /* S */
44084  || ch === 0x77
44085  /* w */
44086  || ch === 0x57
44087  /* W */
44088  ;
44089} // UnicodePropertyValueExpression ::
44090//   UnicodePropertyName `=` UnicodePropertyValue
44091//   LoneUnicodePropertyNameOrValue
44092
44093
44094pp$8.regexp_eatUnicodePropertyValueExpression = function (state) {
44095  var start = state.pos; // UnicodePropertyName `=` UnicodePropertyValue
44096
44097  if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D
44098  /* = */
44099  )) {
44100    var name = state.lastStringValue;
44101
44102    if (this.regexp_eatUnicodePropertyValue(state)) {
44103      var value = state.lastStringValue;
44104      this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
44105      return true;
44106    }
44107  }
44108
44109  state.pos = start; // LoneUnicodePropertyNameOrValue
44110
44111  if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
44112    var nameOrValue = state.lastStringValue;
44113    this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
44114    return true;
44115  }
44116
44117  return false;
44118};
44119
44120pp$8.regexp_validateUnicodePropertyNameAndValue = function (state, name, value) {
44121  if (!has(state.unicodeProperties.nonBinary, name)) {
44122    state.raise("Invalid property name");
44123  }
44124
44125  if (!state.unicodeProperties.nonBinary[name].test(value)) {
44126    state.raise("Invalid property value");
44127  }
44128};
44129
44130pp$8.regexp_validateUnicodePropertyNameOrValue = function (state, nameOrValue) {
44131  if (!state.unicodeProperties.binary.test(nameOrValue)) {
44132    state.raise("Invalid property name");
44133  }
44134}; // UnicodePropertyName ::
44135//   UnicodePropertyNameCharacters
44136
44137
44138pp$8.regexp_eatUnicodePropertyName = function (state) {
44139  var ch = 0;
44140  state.lastStringValue = "";
44141
44142  while (isUnicodePropertyNameCharacter(ch = state.current())) {
44143    state.lastStringValue += codePointToString(ch);
44144    state.advance();
44145  }
44146
44147  return state.lastStringValue !== "";
44148};
44149
44150function isUnicodePropertyNameCharacter(ch) {
44151  return isControlLetter(ch) || ch === 0x5F;
44152  /* _ */
44153} // UnicodePropertyValue ::
44154//   UnicodePropertyValueCharacters
44155
44156
44157pp$8.regexp_eatUnicodePropertyValue = function (state) {
44158  var ch = 0;
44159  state.lastStringValue = "";
44160
44161  while (isUnicodePropertyValueCharacter(ch = state.current())) {
44162    state.lastStringValue += codePointToString(ch);
44163    state.advance();
44164  }
44165
44166  return state.lastStringValue !== "";
44167};
44168
44169function isUnicodePropertyValueCharacter(ch) {
44170  return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch);
44171} // LoneUnicodePropertyNameOrValue ::
44172//   UnicodePropertyValueCharacters
44173
44174
44175pp$8.regexp_eatLoneUnicodePropertyNameOrValue = function (state) {
44176  return this.regexp_eatUnicodePropertyValue(state);
44177}; // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
44178
44179
44180pp$8.regexp_eatCharacterClass = function (state) {
44181  if (state.eat(0x5B
44182  /* [ */
44183  )) {
44184    state.eat(0x5E
44185    /* ^ */
44186    );
44187    this.regexp_classRanges(state);
44188
44189    if (state.eat(0x5D
44190    /* [ */
44191    )) {
44192      return true;
44193    } // Unreachable since it threw "unterminated regular expression" error before.
44194
44195
44196    state.raise("Unterminated character class");
44197  }
44198
44199  return false;
44200}; // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
44201// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
44202// https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
44203
44204
44205pp$8.regexp_classRanges = function (state) {
44206  while (this.regexp_eatClassAtom(state)) {
44207    var left = state.lastIntValue;
44208
44209    if (state.eat(0x2D
44210    /* - */
44211    ) && this.regexp_eatClassAtom(state)) {
44212      var right = state.lastIntValue;
44213
44214      if (state.switchU && (left === -1 || right === -1)) {
44215        state.raise("Invalid character class");
44216      }
44217
44218      if (left !== -1 && right !== -1 && left > right) {
44219        state.raise("Range out of order in character class");
44220      }
44221    }
44222  }
44223}; // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
44224// https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
44225
44226
44227pp$8.regexp_eatClassAtom = function (state) {
44228  var start = state.pos;
44229
44230  if (state.eat(0x5C
44231  /* \ */
44232  )) {
44233    if (this.regexp_eatClassEscape(state)) {
44234      return true;
44235    }
44236
44237    if (state.switchU) {
44238      // Make the same message as V8.
44239      var ch$1 = state.current();
44240
44241      if (ch$1 === 0x63
44242      /* c */
44243      || isOctalDigit(ch$1)) {
44244        state.raise("Invalid class escape");
44245      }
44246
44247      state.raise("Invalid escape");
44248    }
44249
44250    state.pos = start;
44251  }
44252
44253  var ch = state.current();
44254
44255  if (ch !== 0x5D
44256  /* [ */
44257  ) {
44258      state.lastIntValue = ch;
44259      state.advance();
44260      return true;
44261    }
44262
44263  return false;
44264}; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
44265
44266
44267pp$8.regexp_eatClassEscape = function (state) {
44268  var start = state.pos;
44269
44270  if (state.eat(0x62
44271  /* b */
44272  )) {
44273    state.lastIntValue = 0x08;
44274    /* <BS> */
44275
44276    return true;
44277  }
44278
44279  if (state.switchU && state.eat(0x2D
44280  /* - */
44281  )) {
44282    state.lastIntValue = 0x2D;
44283    /* - */
44284
44285    return true;
44286  }
44287
44288  if (!state.switchU && state.eat(0x63
44289  /* c */
44290  )) {
44291    if (this.regexp_eatClassControlLetter(state)) {
44292      return true;
44293    }
44294
44295    state.pos = start;
44296  }
44297
44298  return this.regexp_eatCharacterClassEscape(state) || this.regexp_eatCharacterEscape(state);
44299}; // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
44300
44301
44302pp$8.regexp_eatClassControlLetter = function (state) {
44303  var ch = state.current();
44304
44305  if (isDecimalDigit(ch) || ch === 0x5F
44306  /* _ */
44307  ) {
44308      state.lastIntValue = ch % 0x20;
44309      state.advance();
44310      return true;
44311    }
44312
44313  return false;
44314}; // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
44315
44316
44317pp$8.regexp_eatHexEscapeSequence = function (state) {
44318  var start = state.pos;
44319
44320  if (state.eat(0x78
44321  /* x */
44322  )) {
44323    if (this.regexp_eatFixedHexDigits(state, 2)) {
44324      return true;
44325    }
44326
44327    if (state.switchU) {
44328      state.raise("Invalid escape");
44329    }
44330
44331    state.pos = start;
44332  }
44333
44334  return false;
44335}; // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
44336
44337
44338pp$8.regexp_eatDecimalDigits = function (state) {
44339  var start = state.pos;
44340  var ch = 0;
44341  state.lastIntValue = 0;
44342
44343  while (isDecimalDigit(ch = state.current())) {
44344    state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30
44345    /* 0 */
44346    );
44347    state.advance();
44348  }
44349
44350  return state.pos !== start;
44351};
44352
44353function isDecimalDigit(ch) {
44354  return ch >= 0x30
44355  /* 0 */
44356  && ch <= 0x39;
44357  /* 9 */
44358} // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
44359
44360
44361pp$8.regexp_eatHexDigits = function (state) {
44362  var start = state.pos;
44363  var ch = 0;
44364  state.lastIntValue = 0;
44365
44366  while (isHexDigit(ch = state.current())) {
44367    state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
44368    state.advance();
44369  }
44370
44371  return state.pos !== start;
44372};
44373
44374function isHexDigit(ch) {
44375  return ch >= 0x30
44376  /* 0 */
44377  && ch <= 0x39
44378  /* 9 */
44379  || ch >= 0x41
44380  /* A */
44381  && ch <= 0x46
44382  /* F */
44383  || ch >= 0x61
44384  /* a */
44385  && ch <= 0x66
44386  /* f */
44387  ;
44388}
44389
44390function hexToInt(ch) {
44391  if (ch >= 0x41
44392  /* A */
44393  && ch <= 0x46
44394  /* F */
44395  ) {
44396      return 10 + (ch - 0x41
44397      /* A */
44398      );
44399    }
44400
44401  if (ch >= 0x61
44402  /* a */
44403  && ch <= 0x66
44404  /* f */
44405  ) {
44406      return 10 + (ch - 0x61
44407      /* a */
44408      );
44409    }
44410
44411  return ch - 0x30;
44412  /* 0 */
44413} // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
44414// Allows only 0-377(octal) i.e. 0-255(decimal).
44415
44416
44417pp$8.regexp_eatLegacyOctalEscapeSequence = function (state) {
44418  if (this.regexp_eatOctalDigit(state)) {
44419    var n1 = state.lastIntValue;
44420
44421    if (this.regexp_eatOctalDigit(state)) {
44422      var n2 = state.lastIntValue;
44423
44424      if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
44425        state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
44426      } else {
44427        state.lastIntValue = n1 * 8 + n2;
44428      }
44429    } else {
44430      state.lastIntValue = n1;
44431    }
44432
44433    return true;
44434  }
44435
44436  return false;
44437}; // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
44438
44439
44440pp$8.regexp_eatOctalDigit = function (state) {
44441  var ch = state.current();
44442
44443  if (isOctalDigit(ch)) {
44444    state.lastIntValue = ch - 0x30;
44445    /* 0 */
44446
44447    state.advance();
44448    return true;
44449  }
44450
44451  state.lastIntValue = 0;
44452  return false;
44453};
44454
44455function isOctalDigit(ch) {
44456  return ch >= 0x30
44457  /* 0 */
44458  && ch <= 0x37;
44459  /* 7 */
44460} // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
44461// https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
44462// And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
44463
44464
44465pp$8.regexp_eatFixedHexDigits = function (state, length) {
44466  var start = state.pos;
44467  state.lastIntValue = 0;
44468
44469  for (var i = 0; i < length; ++i) {
44470    var ch = state.current();
44471
44472    if (!isHexDigit(ch)) {
44473      state.pos = start;
44474      return false;
44475    }
44476
44477    state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
44478    state.advance();
44479  }
44480
44481  return true;
44482}; // Object type used to represent tokens. Note that normally, tokens
44483// simply exist as properties on the parser object. This is only
44484// used for the onToken callback and the external tokenizer.
44485
44486
44487var Token = function Token(p) {
44488  this.type = p.type;
44489  this.value = p.value;
44490  this.start = p.start;
44491  this.end = p.end;
44492
44493  if (p.options.locations) {
44494    this.loc = new SourceLocation(p, p.startLoc, p.endLoc);
44495  }
44496
44497  if (p.options.ranges) {
44498    this.range = [p.start, p.end];
44499  }
44500}; // ## Tokenizer
44501
44502
44503exports.Token = Token;
44504var pp$9 = Parser.prototype; // Move to the next token
44505
44506pp$9.next = function () {
44507  if (this.options.onToken) {
44508    this.options.onToken(new Token(this));
44509  }
44510
44511  this.lastTokEnd = this.end;
44512  this.lastTokStart = this.start;
44513  this.lastTokEndLoc = this.endLoc;
44514  this.lastTokStartLoc = this.startLoc;
44515  this.nextToken();
44516};
44517
44518pp$9.getToken = function () {
44519  this.next();
44520  return new Token(this);
44521}; // If we're in an ES6 environment, make parsers iterable
44522
44523
44524if (typeof Symbol !== "undefined") {
44525  pp$9[Symbol.iterator] = function () {
44526    var this$1 = this;
44527    return {
44528      next: function () {
44529        var token = this$1.getToken();
44530        return {
44531          done: token.type === types.eof,
44532          value: token
44533        };
44534      }
44535    };
44536  };
44537} // Toggle strict mode. Re-reads the next number or string to please
44538// pedantic tests (`"use strict"; 010;` should fail).
44539
44540
44541pp$9.curContext = function () {
44542  return this.context[this.context.length - 1];
44543}; // Read a single token, updating the parser object's token-related
44544// properties.
44545
44546
44547pp$9.nextToken = function () {
44548  var curContext = this.curContext();
44549
44550  if (!curContext || !curContext.preserveSpace) {
44551    this.skipSpace();
44552  }
44553
44554  this.start = this.pos;
44555
44556  if (this.options.locations) {
44557    this.startLoc = this.curPosition();
44558  }
44559
44560  if (this.pos >= this.input.length) {
44561    return this.finishToken(types.eof);
44562  }
44563
44564  if (curContext.override) {
44565    return curContext.override(this);
44566  } else {
44567    this.readToken(this.fullCharCodeAtPos());
44568  }
44569};
44570
44571pp$9.readToken = function (code) {
44572  // Identifier or keyword. '\uXXXX' sequences are allowed in
44573  // identifiers, so '\' also dispatches to that.
44574  if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92
44575  /* '\' */
44576  ) {
44577      return this.readWord();
44578    }
44579
44580  return this.getTokenFromCode(code);
44581};
44582
44583pp$9.fullCharCodeAtPos = function () {
44584  var code = this.input.charCodeAt(this.pos);
44585
44586  if (code <= 0xd7ff || code >= 0xe000) {
44587    return code;
44588  }
44589
44590  var next = this.input.charCodeAt(this.pos + 1);
44591  return (code << 10) + next - 0x35fdc00;
44592};
44593
44594pp$9.skipBlockComment = function () {
44595  var startLoc = this.options.onComment && this.curPosition();
44596  var start = this.pos,
44597      end = this.input.indexOf("*/", this.pos += 2);
44598
44599  if (end === -1) {
44600    this.raise(this.pos - 2, "Unterminated comment");
44601  }
44602
44603  this.pos = end + 2;
44604
44605  if (this.options.locations) {
44606    lineBreakG.lastIndex = start;
44607    var match;
44608
44609    while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
44610      ++this.curLine;
44611      this.lineStart = match.index + match[0].length;
44612    }
44613  }
44614
44615  if (this.options.onComment) {
44616    this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, startLoc, this.curPosition());
44617  }
44618};
44619
44620pp$9.skipLineComment = function (startSkip) {
44621  var start = this.pos;
44622  var startLoc = this.options.onComment && this.curPosition();
44623  var ch = this.input.charCodeAt(this.pos += startSkip);
44624
44625  while (this.pos < this.input.length && !isNewLine(ch)) {
44626    ch = this.input.charCodeAt(++this.pos);
44627  }
44628
44629  if (this.options.onComment) {
44630    this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, startLoc, this.curPosition());
44631  }
44632}; // Called at the start of the parse and after every token. Skips
44633// whitespace and comments, and.
44634
44635
44636pp$9.skipSpace = function () {
44637  loop: while (this.pos < this.input.length) {
44638    var ch = this.input.charCodeAt(this.pos);
44639
44640    switch (ch) {
44641      case 32:
44642      case 160:
44643        // ' '
44644        ++this.pos;
44645        break;
44646
44647      case 13:
44648        if (this.input.charCodeAt(this.pos + 1) === 10) {
44649          ++this.pos;
44650        }
44651
44652      case 10:
44653      case 8232:
44654      case 8233:
44655        ++this.pos;
44656
44657        if (this.options.locations) {
44658          ++this.curLine;
44659          this.lineStart = this.pos;
44660        }
44661
44662        break;
44663
44664      case 47:
44665        // '/'
44666        switch (this.input.charCodeAt(this.pos + 1)) {
44667          case 42:
44668            // '*'
44669            this.skipBlockComment();
44670            break;
44671
44672          case 47:
44673            this.skipLineComment(2);
44674            break;
44675
44676          default:
44677            break loop;
44678        }
44679
44680        break;
44681
44682      default:
44683        if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
44684          ++this.pos;
44685        } else {
44686          break loop;
44687        }
44688
44689    }
44690  }
44691}; // Called at the end of every token. Sets `end`, `val`, and
44692// maintains `context` and `exprAllowed`, and skips the space after
44693// the token, so that the next one's `start` will point at the
44694// right position.
44695
44696
44697pp$9.finishToken = function (type, val) {
44698  this.end = this.pos;
44699
44700  if (this.options.locations) {
44701    this.endLoc = this.curPosition();
44702  }
44703
44704  var prevType = this.type;
44705  this.type = type;
44706  this.value = val;
44707  this.updateContext(prevType);
44708}; // ### Token reading
44709// This is the function that is called to fetch the next token. It
44710// is somewhat obscure, because it works in character codes rather
44711// than characters, and because operator parsing has been inlined
44712// into it.
44713//
44714// All in the name of speed.
44715//
44716
44717
44718pp$9.readToken_dot = function () {
44719  var next = this.input.charCodeAt(this.pos + 1);
44720
44721  if (next >= 48 && next <= 57) {
44722    return this.readNumber(true);
44723  }
44724
44725  var next2 = this.input.charCodeAt(this.pos + 2);
44726
44727  if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) {
44728    // 46 = dot '.'
44729    this.pos += 3;
44730    return this.finishToken(types.ellipsis);
44731  } else {
44732    ++this.pos;
44733    return this.finishToken(types.dot);
44734  }
44735};
44736
44737pp$9.readToken_slash = function () {
44738  // '/'
44739  var next = this.input.charCodeAt(this.pos + 1);
44740
44741  if (this.exprAllowed) {
44742    ++this.pos;
44743    return this.readRegexp();
44744  }
44745
44746  if (next === 61) {
44747    return this.finishOp(types.assign, 2);
44748  }
44749
44750  return this.finishOp(types.slash, 1);
44751};
44752
44753pp$9.readToken_mult_modulo_exp = function (code) {
44754  // '%*'
44755  var next = this.input.charCodeAt(this.pos + 1);
44756  var size = 1;
44757  var tokentype = code === 42 ? types.star : types.modulo; // exponentiation operator ** and **=
44758
44759  if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
44760    ++size;
44761    tokentype = types.starstar;
44762    next = this.input.charCodeAt(this.pos + 2);
44763  }
44764
44765  if (next === 61) {
44766    return this.finishOp(types.assign, size + 1);
44767  }
44768
44769  return this.finishOp(tokentype, size);
44770};
44771
44772pp$9.readToken_pipe_amp = function (code) {
44773  // '|&'
44774  var next = this.input.charCodeAt(this.pos + 1);
44775
44776  if (next === code) {
44777    return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2);
44778  }
44779
44780  if (next === 61) {
44781    return this.finishOp(types.assign, 2);
44782  }
44783
44784  return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1);
44785};
44786
44787pp$9.readToken_caret = function () {
44788  // '^'
44789  var next = this.input.charCodeAt(this.pos + 1);
44790
44791  if (next === 61) {
44792    return this.finishOp(types.assign, 2);
44793  }
44794
44795  return this.finishOp(types.bitwiseXOR, 1);
44796};
44797
44798pp$9.readToken_plus_min = function (code) {
44799  // '+-'
44800  var next = this.input.charCodeAt(this.pos + 1);
44801
44802  if (next === code) {
44803    if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 && (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
44804      // A `-->` line comment
44805      this.skipLineComment(3);
44806      this.skipSpace();
44807      return this.nextToken();
44808    }
44809
44810    return this.finishOp(types.incDec, 2);
44811  }
44812
44813  if (next === 61) {
44814    return this.finishOp(types.assign, 2);
44815  }
44816
44817  return this.finishOp(types.plusMin, 1);
44818};
44819
44820pp$9.readToken_lt_gt = function (code) {
44821  // '<>'
44822  var next = this.input.charCodeAt(this.pos + 1);
44823  var size = 1;
44824
44825  if (next === code) {
44826    size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
44827
44828    if (this.input.charCodeAt(this.pos + size) === 61) {
44829      return this.finishOp(types.assign, size + 1);
44830    }
44831
44832    return this.finishOp(types.bitShift, size);
44833  }
44834
44835  if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 && this.input.charCodeAt(this.pos + 3) === 45) {
44836    // `<!--`, an XML-style comment that should be interpreted as a line comment
44837    this.skipLineComment(4);
44838    this.skipSpace();
44839    return this.nextToken();
44840  }
44841
44842  if (next === 61) {
44843    size = 2;
44844  }
44845
44846  return this.finishOp(types.relational, size);
44847};
44848
44849pp$9.readToken_eq_excl = function (code) {
44850  // '=!'
44851  var next = this.input.charCodeAt(this.pos + 1);
44852
44853  if (next === 61) {
44854    return this.finishOp(types.equality, this.input.charCodeAt(this.pos + 2) === 61 ? 3 : 2);
44855  }
44856
44857  if (code === 61 && next === 62 && this.options.ecmaVersion >= 6) {
44858    // '=>'
44859    this.pos += 2;
44860    return this.finishToken(types.arrow);
44861  }
44862
44863  return this.finishOp(code === 61 ? types.eq : types.prefix, 1);
44864};
44865
44866pp$9.getTokenFromCode = function (code) {
44867  switch (code) {
44868    // The interpretation of a dot depends on whether it is followed
44869    // by a digit or another two dots.
44870    case 46:
44871      // '.'
44872      return this.readToken_dot();
44873    // Punctuation tokens.
44874
44875    case 40:
44876      ++this.pos;
44877      return this.finishToken(types.parenL);
44878
44879    case 41:
44880      ++this.pos;
44881      return this.finishToken(types.parenR);
44882
44883    case 59:
44884      ++this.pos;
44885      return this.finishToken(types.semi);
44886
44887    case 44:
44888      ++this.pos;
44889      return this.finishToken(types.comma);
44890
44891    case 91:
44892      ++this.pos;
44893      return this.finishToken(types.bracketL);
44894
44895    case 93:
44896      ++this.pos;
44897      return this.finishToken(types.bracketR);
44898
44899    case 123:
44900      ++this.pos;
44901      return this.finishToken(types.braceL);
44902
44903    case 125:
44904      ++this.pos;
44905      return this.finishToken(types.braceR);
44906
44907    case 58:
44908      ++this.pos;
44909      return this.finishToken(types.colon);
44910
44911    case 63:
44912      ++this.pos;
44913      return this.finishToken(types.question);
44914
44915    case 96:
44916      // '`'
44917      if (this.options.ecmaVersion < 6) {
44918        break;
44919      }
44920
44921      ++this.pos;
44922      return this.finishToken(types.backQuote);
44923
44924    case 48:
44925      // '0'
44926      var next = this.input.charCodeAt(this.pos + 1);
44927
44928      if (next === 120 || next === 88) {
44929        return this.readRadixNumber(16);
44930      } // '0x', '0X' - hex number
44931
44932
44933      if (this.options.ecmaVersion >= 6) {
44934        if (next === 111 || next === 79) {
44935          return this.readRadixNumber(8);
44936        } // '0o', '0O' - octal number
44937
44938
44939        if (next === 98 || next === 66) {
44940          return this.readRadixNumber(2);
44941        } // '0b', '0B' - binary number
44942
44943      }
44944
44945    // Anything else beginning with a digit is an integer, octal
44946    // number, or float.
44947
44948    case 49:
44949    case 50:
44950    case 51:
44951    case 52:
44952    case 53:
44953    case 54:
44954    case 55:
44955    case 56:
44956    case 57:
44957      // 1-9
44958      return this.readNumber(false);
44959    // Quotes produce strings.
44960
44961    case 34:
44962    case 39:
44963      // '"', "'"
44964      return this.readString(code);
44965    // Operators are parsed inline in tiny state machines. '=' (61) is
44966    // often referred to. `finishOp` simply skips the amount of
44967    // characters it is given as second argument, and returns a token
44968    // of the type given by its first argument.
44969
44970    case 47:
44971      // '/'
44972      return this.readToken_slash();
44973
44974    case 37:
44975    case 42:
44976      // '%*'
44977      return this.readToken_mult_modulo_exp(code);
44978
44979    case 124:
44980    case 38:
44981      // '|&'
44982      return this.readToken_pipe_amp(code);
44983
44984    case 94:
44985      // '^'
44986      return this.readToken_caret();
44987
44988    case 43:
44989    case 45:
44990      // '+-'
44991      return this.readToken_plus_min(code);
44992
44993    case 60:
44994    case 62:
44995      // '<>'
44996      return this.readToken_lt_gt(code);
44997
44998    case 61:
44999    case 33:
45000      // '=!'
45001      return this.readToken_eq_excl(code);
45002
45003    case 126:
45004      // '~'
45005      return this.finishOp(types.prefix, 1);
45006  }
45007
45008  this.raise(this.pos, "Unexpected character '" + codePointToString$1(code) + "'");
45009};
45010
45011pp$9.finishOp = function (type, size) {
45012  var str = this.input.slice(this.pos, this.pos + size);
45013  this.pos += size;
45014  return this.finishToken(type, str);
45015};
45016
45017pp$9.readRegexp = function () {
45018  var escaped,
45019      inClass,
45020      start = this.pos;
45021
45022  for (;;) {
45023    if (this.pos >= this.input.length) {
45024      this.raise(start, "Unterminated regular expression");
45025    }
45026
45027    var ch = this.input.charAt(this.pos);
45028
45029    if (lineBreak.test(ch)) {
45030      this.raise(start, "Unterminated regular expression");
45031    }
45032
45033    if (!escaped) {
45034      if (ch === "[") {
45035        inClass = true;
45036      } else if (ch === "]" && inClass) {
45037        inClass = false;
45038      } else if (ch === "/" && !inClass) {
45039        break;
45040      }
45041
45042      escaped = ch === "\\";
45043    } else {
45044      escaped = false;
45045    }
45046
45047    ++this.pos;
45048  }
45049
45050  var pattern = this.input.slice(start, this.pos);
45051  ++this.pos;
45052  var flagsStart = this.pos;
45053  var flags = this.readWord1();
45054
45055  if (this.containsEsc) {
45056    this.unexpected(flagsStart);
45057  } // Validate pattern
45058
45059
45060  var state = this.regexpState || (this.regexpState = new RegExpValidationState(this));
45061  state.reset(start, pattern, flags);
45062  this.validateRegExpFlags(state);
45063  this.validateRegExpPattern(state); // Create Literal#value property value.
45064
45065  var value = null;
45066
45067  try {
45068    value = new RegExp(pattern, flags);
45069  } catch (e) {// ESTree requires null if it failed to instantiate RegExp object.
45070    // https://github.com/estree/estree/blob/a27003adf4fd7bfad44de9cef372a2eacd527b1c/es5.md#regexpliteral
45071  }
45072
45073  return this.finishToken(types.regexp, {
45074    pattern: pattern,
45075    flags: flags,
45076    value: value
45077  });
45078}; // Read an integer in the given radix. Return null if zero digits
45079// were read, the integer value otherwise. When `len` is given, this
45080// will return `null` unless the integer has exactly `len` digits.
45081
45082
45083pp$9.readInt = function (radix, len) {
45084  var start = this.pos,
45085      total = 0;
45086
45087  for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
45088    var code = this.input.charCodeAt(this.pos),
45089        val = void 0;
45090
45091    if (code >= 97) {
45092      val = code - 97 + 10;
45093    } // a
45094    else if (code >= 65) {
45095        val = code - 65 + 10;
45096      } // A
45097      else if (code >= 48 && code <= 57) {
45098          val = code - 48;
45099        } // 0-9
45100        else {
45101            val = Infinity;
45102          }
45103
45104    if (val >= radix) {
45105      break;
45106    }
45107
45108    ++this.pos;
45109    total = total * radix + val;
45110  }
45111
45112  if (this.pos === start || len != null && this.pos - start !== len) {
45113    return null;
45114  }
45115
45116  return total;
45117};
45118
45119pp$9.readRadixNumber = function (radix) {
45120  var start = this.pos;
45121  this.pos += 2; // 0x
45122
45123  var val = this.readInt(radix);
45124
45125  if (val == null) {
45126    this.raise(this.start + 2, "Expected number in radix " + radix);
45127  }
45128
45129  if (this.options.ecmaVersion >= 11 && this.input.charCodeAt(this.pos) === 110) {
45130    val = typeof BigInt !== "undefined" ? BigInt(this.input.slice(start, this.pos)) : null;
45131    ++this.pos;
45132  } else if (isIdentifierStart(this.fullCharCodeAtPos())) {
45133    this.raise(this.pos, "Identifier directly after number");
45134  }
45135
45136  return this.finishToken(types.num, val);
45137}; // Read an integer, octal integer, or floating-point number.
45138
45139
45140pp$9.readNumber = function (startsWithDot) {
45141  var start = this.pos;
45142
45143  if (!startsWithDot && this.readInt(10) === null) {
45144    this.raise(start, "Invalid number");
45145  }
45146
45147  var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
45148
45149  if (octal && this.strict) {
45150    this.raise(start, "Invalid number");
45151  }
45152
45153  if (octal && /[89]/.test(this.input.slice(start, this.pos))) {
45154    octal = false;
45155  }
45156
45157  var next = this.input.charCodeAt(this.pos);
45158
45159  if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
45160    var str$1 = this.input.slice(start, this.pos);
45161    var val$1 = typeof BigInt !== "undefined" ? BigInt(str$1) : null;
45162    ++this.pos;
45163
45164    if (isIdentifierStart(this.fullCharCodeAtPos())) {
45165      this.raise(this.pos, "Identifier directly after number");
45166    }
45167
45168    return this.finishToken(types.num, val$1);
45169  }
45170
45171  if (next === 46 && !octal) {
45172    // '.'
45173    ++this.pos;
45174    this.readInt(10);
45175    next = this.input.charCodeAt(this.pos);
45176  }
45177
45178  if ((next === 69 || next === 101) && !octal) {
45179    // 'eE'
45180    next = this.input.charCodeAt(++this.pos);
45181
45182    if (next === 43 || next === 45) {
45183      ++this.pos;
45184    } // '+-'
45185
45186
45187    if (this.readInt(10) === null) {
45188      this.raise(start, "Invalid number");
45189    }
45190  }
45191
45192  if (isIdentifierStart(this.fullCharCodeAtPos())) {
45193    this.raise(this.pos, "Identifier directly after number");
45194  }
45195
45196  var str = this.input.slice(start, this.pos);
45197  var val = octal ? parseInt(str, 8) : parseFloat(str);
45198  return this.finishToken(types.num, val);
45199}; // Read a string value, interpreting backslash-escapes.
45200
45201
45202pp$9.readCodePoint = function () {
45203  var ch = this.input.charCodeAt(this.pos),
45204      code;
45205
45206  if (ch === 123) {
45207    // '{'
45208    if (this.options.ecmaVersion < 6) {
45209      this.unexpected();
45210    }
45211
45212    var codePos = ++this.pos;
45213    code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
45214    ++this.pos;
45215
45216    if (code > 0x10FFFF) {
45217      this.invalidStringToken(codePos, "Code point out of bounds");
45218    }
45219  } else {
45220    code = this.readHexChar(4);
45221  }
45222
45223  return code;
45224};
45225
45226function codePointToString$1(code) {
45227  // UTF-16 Decoding
45228  if (code <= 0xFFFF) {
45229    return String.fromCharCode(code);
45230  }
45231
45232  code -= 0x10000;
45233  return String.fromCharCode((code >> 10) + 0xD800, (code & 1023) + 0xDC00);
45234}
45235
45236pp$9.readString = function (quote) {
45237  var out = "",
45238      chunkStart = ++this.pos;
45239
45240  for (;;) {
45241    if (this.pos >= this.input.length) {
45242      this.raise(this.start, "Unterminated string constant");
45243    }
45244
45245    var ch = this.input.charCodeAt(this.pos);
45246
45247    if (ch === quote) {
45248      break;
45249    }
45250
45251    if (ch === 92) {
45252      // '\'
45253      out += this.input.slice(chunkStart, this.pos);
45254      out += this.readEscapedChar(false);
45255      chunkStart = this.pos;
45256    } else {
45257      if (isNewLine(ch, this.options.ecmaVersion >= 10)) {
45258        this.raise(this.start, "Unterminated string constant");
45259      }
45260
45261      ++this.pos;
45262    }
45263  }
45264
45265  out += this.input.slice(chunkStart, this.pos++);
45266  return this.finishToken(types.string, out);
45267}; // Reads template string tokens.
45268
45269
45270var INVALID_TEMPLATE_ESCAPE_ERROR = {};
45271
45272pp$9.tryReadTemplateToken = function () {
45273  this.inTemplateElement = true;
45274
45275  try {
45276    this.readTmplToken();
45277  } catch (err) {
45278    if (err === INVALID_TEMPLATE_ESCAPE_ERROR) {
45279      this.readInvalidTemplateToken();
45280    } else {
45281      throw err;
45282    }
45283  }
45284
45285  this.inTemplateElement = false;
45286};
45287
45288pp$9.invalidStringToken = function (position, message) {
45289  if (this.inTemplateElement && this.options.ecmaVersion >= 9) {
45290    throw INVALID_TEMPLATE_ESCAPE_ERROR;
45291  } else {
45292    this.raise(position, message);
45293  }
45294};
45295
45296pp$9.readTmplToken = function () {
45297  var out = "",
45298      chunkStart = this.pos;
45299
45300  for (;;) {
45301    if (this.pos >= this.input.length) {
45302      this.raise(this.start, "Unterminated template");
45303    }
45304
45305    var ch = this.input.charCodeAt(this.pos);
45306
45307    if (ch === 96 || ch === 36 && this.input.charCodeAt(this.pos + 1) === 123) {
45308      // '`', '${'
45309      if (this.pos === this.start && (this.type === types.template || this.type === types.invalidTemplate)) {
45310        if (ch === 36) {
45311          this.pos += 2;
45312          return this.finishToken(types.dollarBraceL);
45313        } else {
45314          ++this.pos;
45315          return this.finishToken(types.backQuote);
45316        }
45317      }
45318
45319      out += this.input.slice(chunkStart, this.pos);
45320      return this.finishToken(types.template, out);
45321    }
45322
45323    if (ch === 92) {
45324      // '\'
45325      out += this.input.slice(chunkStart, this.pos);
45326      out += this.readEscapedChar(true);
45327      chunkStart = this.pos;
45328    } else if (isNewLine(ch)) {
45329      out += this.input.slice(chunkStart, this.pos);
45330      ++this.pos;
45331
45332      switch (ch) {
45333        case 13:
45334          if (this.input.charCodeAt(this.pos) === 10) {
45335            ++this.pos;
45336          }
45337
45338        case 10:
45339          out += "\n";
45340          break;
45341
45342        default:
45343          out += String.fromCharCode(ch);
45344          break;
45345      }
45346
45347      if (this.options.locations) {
45348        ++this.curLine;
45349        this.lineStart = this.pos;
45350      }
45351
45352      chunkStart = this.pos;
45353    } else {
45354      ++this.pos;
45355    }
45356  }
45357}; // Reads a template token to search for the end, without validating any escape sequences
45358
45359
45360pp$9.readInvalidTemplateToken = function () {
45361  for (; this.pos < this.input.length; this.pos++) {
45362    switch (this.input[this.pos]) {
45363      case "\\":
45364        ++this.pos;
45365        break;
45366
45367      case "$":
45368        if (this.input[this.pos + 1] !== "{") {
45369          break;
45370        }
45371
45372      // falls through
45373
45374      case "`":
45375        return this.finishToken(types.invalidTemplate, this.input.slice(this.start, this.pos));
45376      // no default
45377    }
45378  }
45379
45380  this.raise(this.start, "Unterminated template");
45381}; // Used to read escaped characters
45382
45383
45384pp$9.readEscapedChar = function (inTemplate) {
45385  var ch = this.input.charCodeAt(++this.pos);
45386  ++this.pos;
45387
45388  switch (ch) {
45389    case 110:
45390      return "\n";
45391    // 'n' -> '\n'
45392
45393    case 114:
45394      return "\r";
45395    // 'r' -> '\r'
45396
45397    case 120:
45398      return String.fromCharCode(this.readHexChar(2));
45399    // 'x'
45400
45401    case 117:
45402      return codePointToString$1(this.readCodePoint());
45403    // 'u'
45404
45405    case 116:
45406      return "\t";
45407    // 't' -> '\t'
45408
45409    case 98:
45410      return "\b";
45411    // 'b' -> '\b'
45412
45413    case 118:
45414      return "\u000b";
45415    // 'v' -> '\u000b'
45416
45417    case 102:
45418      return "\f";
45419    // 'f' -> '\f'
45420
45421    case 13:
45422      if (this.input.charCodeAt(this.pos) === 10) {
45423        ++this.pos;
45424      }
45425
45426    // '\r\n'
45427
45428    case 10:
45429      // ' \n'
45430      if (this.options.locations) {
45431        this.lineStart = this.pos;
45432        ++this.curLine;
45433      }
45434
45435      return "";
45436
45437    default:
45438      if (ch >= 48 && ch <= 55) {
45439        var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
45440        var octal = parseInt(octalStr, 8);
45441
45442        if (octal > 255) {
45443          octalStr = octalStr.slice(0, -1);
45444          octal = parseInt(octalStr, 8);
45445        }
45446
45447        this.pos += octalStr.length - 1;
45448        ch = this.input.charCodeAt(this.pos);
45449
45450        if ((octalStr !== "0" || ch === 56 || ch === 57) && (this.strict || inTemplate)) {
45451          this.invalidStringToken(this.pos - 1 - octalStr.length, inTemplate ? "Octal literal in template string" : "Octal literal in strict mode");
45452        }
45453
45454        return String.fromCharCode(octal);
45455      }
45456
45457      if (isNewLine(ch)) {
45458        // Unicode new line characters after \ get removed from output in both
45459        // template literals and strings
45460        return "";
45461      }
45462
45463      return String.fromCharCode(ch);
45464  }
45465}; // Used to read character escape sequences ('\x', '\u', '\U').
45466
45467
45468pp$9.readHexChar = function (len) {
45469  var codePos = this.pos;
45470  var n = this.readInt(16, len);
45471
45472  if (n === null) {
45473    this.invalidStringToken(codePos, "Bad character escape sequence");
45474  }
45475
45476  return n;
45477}; // Read an identifier, and return it as a string. Sets `this.containsEsc`
45478// to whether the word contained a '\u' escape.
45479//
45480// Incrementally adds only escaped chars, adding other chunks as-is
45481// as a micro-optimization.
45482
45483
45484pp$9.readWord1 = function () {
45485  this.containsEsc = false;
45486  var word = "",
45487      first = true,
45488      chunkStart = this.pos;
45489  var astral = this.options.ecmaVersion >= 6;
45490
45491  while (this.pos < this.input.length) {
45492    var ch = this.fullCharCodeAtPos();
45493
45494    if (isIdentifierChar(ch, astral)) {
45495      this.pos += ch <= 0xffff ? 1 : 2;
45496    } else if (ch === 92) {
45497      // "\"
45498      this.containsEsc = true;
45499      word += this.input.slice(chunkStart, this.pos);
45500      var escStart = this.pos;
45501
45502      if (this.input.charCodeAt(++this.pos) !== 117) // "u"
45503        {
45504          this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX");
45505        }
45506
45507      ++this.pos;
45508      var esc = this.readCodePoint();
45509
45510      if (!(first ? isIdentifierStart : isIdentifierChar)(esc, astral)) {
45511        this.invalidStringToken(escStart, "Invalid Unicode escape");
45512      }
45513
45514      word += codePointToString$1(esc);
45515      chunkStart = this.pos;
45516    } else {
45517      break;
45518    }
45519
45520    first = false;
45521  }
45522
45523  return word + this.input.slice(chunkStart, this.pos);
45524}; // Read an identifier or keyword token. Will check for reserved
45525// words when necessary.
45526
45527
45528pp$9.readWord = function () {
45529  var word = this.readWord1();
45530  var type = types.name;
45531
45532  if (this.keywords.test(word)) {
45533    if (this.containsEsc) {
45534      this.raiseRecoverable(this.start, "Escape sequence in keyword " + word);
45535    }
45536
45537    type = keywords$1[word];
45538  }
45539
45540  return this.finishToken(type, word);
45541}; // Acorn is a tiny, fast JavaScript parser written in JavaScript.
45542
45543
45544var version = "6.4.0";
45545exports.version = version;
45546Parser.acorn = {
45547  Parser: Parser,
45548  version: version,
45549  defaultOptions: defaultOptions,
45550  Position: Position,
45551  SourceLocation: SourceLocation,
45552  getLineInfo: getLineInfo,
45553  Node: Node,
45554  TokenType: TokenType,
45555  tokTypes: types,
45556  keywordTypes: keywords$1,
45557  TokContext: TokContext,
45558  tokContexts: types$1,
45559  isIdentifierChar: isIdentifierChar,
45560  isIdentifierStart: isIdentifierStart,
45561  Token: Token,
45562  isNewLine: isNewLine,
45563  lineBreak: lineBreak,
45564  lineBreakG: lineBreakG,
45565  nonASCIIwhitespace: nonASCIIwhitespace
45566}; // The main exported interface (under `self.acorn` when in the
45567// browser) is a `parse` function that takes a code string and
45568// returns an abstract syntax tree as specified by [Mozilla parser
45569// API][api].
45570//
45571// [api]: https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
45572
45573function parse(input, options) {
45574  return Parser.parse(input, options);
45575} // This function tries to parse a single expression at a given
45576// offset in a string. Useful for parsing mixed-language formats
45577// that embed JavaScript expressions.
45578
45579
45580function parseExpressionAt(input, pos, options) {
45581  return Parser.parseExpressionAt(input, pos, options);
45582} // Acorn is organized as a tokenizer and a recursive-descent parser.
45583// The `tokenizer` export provides an interface to the tokenizer.
45584
45585
45586function tokenizer(input, options) {
45587  return Parser.tokenizer(input, options);
45588}
45589},{}],"node_modules/paper/dist/paper-full.js":[function(require,module,exports) {
45590var define;
45591var process = require("process");
45592var global = arguments[3];
45593function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
45594
45595/*!
45596 * Paper.js v0.12.4 - The Swiss Army Knife of Vector Graphics Scripting.
45597 * http://paperjs.org/
45598 *
45599 * Copyright (c) 2011 - 2019, Juerg Lehni & Jonathan Puckey
45600 * http://scratchdisk.com/ & https://puckey.studio/
45601 *
45602 * Distributed under the MIT license. See LICENSE file for details.
45603 *
45604 * All rights reserved.
45605 *
45606 * Date: Sun Dec 15 21:25:00 2019 +0100
45607 *
45608 ***
45609 *
45610 * Straps.js - Class inheritance library with support for bean-style accessors
45611 *
45612 * Copyright (c) 2006 - 2019 Juerg Lehni
45613 * http://scratchdisk.com/
45614 *
45615 * Distributed under the MIT license.
45616 *
45617 ***
45618 *
45619 * Acorn.js
45620 * https://marijnhaverbeke.nl/acorn/
45621 *
45622 * Acorn is a tiny, fast JavaScript parser written in JavaScript,
45623 * created by Marijn Haverbeke and released under an MIT license.
45624 *
45625 */
45626var paper = function (self, undefined) {
45627  self = self || require('./node/self.js');
45628  var window = self.window,
45629      document = self.document;
45630  var Base = new function () {
45631    var hidden = /^(statics|enumerable|beans|preserve)$/,
45632        array = [],
45633        _slice = array.slice,
45634        create = Object.create,
45635        describe = Object.getOwnPropertyDescriptor,
45636        define = Object.defineProperty,
45637        forEach = array.forEach || function (iter, bind) {
45638      for (var i = 0, l = this.length; i < l; i++) {
45639        iter.call(bind, this[i], i, this);
45640      }
45641    },
45642        forIn = function forIn(iter, bind) {
45643      for (var i in this) {
45644        if (this.hasOwnProperty(i)) iter.call(bind, this[i], i, this);
45645      }
45646    },
45647        set = Object.assign || function (dst) {
45648      for (var i = 1, l = arguments.length; i < l; i++) {
45649        var src = arguments[i];
45650
45651        for (var key in src) {
45652          if (src.hasOwnProperty(key)) dst[key] = src[key];
45653        }
45654      }
45655
45656      return dst;
45657    },
45658        _each = function each(obj, iter, bind) {
45659      if (obj) {
45660        var desc = describe(obj, 'length');
45661        (desc && typeof desc.value === 'number' ? forEach : forIn).call(obj, iter, bind = bind || obj);
45662      }
45663
45664      return bind;
45665    };
45666
45667    function _inject(dest, src, enumerable, beans, preserve) {
45668      var beansNames = {};
45669
45670      function field(name, val) {
45671        val = val || (val = describe(src, name)) && (val.get ? val : val.value);
45672        if (typeof val === 'string' && val[0] === '#') val = dest[val.substring(1)] || val;
45673        var isFunc = typeof val === 'function',
45674            res = val,
45675            prev = preserve || isFunc && !val.base ? val && val.get ? name in dest : dest[name] : null,
45676            bean;
45677
45678        if (!preserve || !prev) {
45679          if (isFunc && prev) val.base = prev;
45680          if (isFunc && beans !== false && (bean = name.match(/^([gs]et|is)(([A-Z])(.*))$/))) beansNames[bean[3].toLowerCase() + bean[4]] = bean[2];
45681
45682          if (!res || isFunc || !res.get || typeof res.get !== 'function' || !Base.isPlainObject(res)) {
45683            res = {
45684              value: res,
45685              writable: true
45686            };
45687          }
45688
45689          if ((describe(dest, name) || {
45690            configurable: true
45691          }).configurable) {
45692            res.configurable = true;
45693            res.enumerable = enumerable != null ? enumerable : !bean;
45694          }
45695
45696          define(dest, name, res);
45697        }
45698      }
45699
45700      if (src) {
45701        for (var name in src) {
45702          if (src.hasOwnProperty(name) && !hidden.test(name)) field(name);
45703        }
45704
45705        for (var name in beansNames) {
45706          var part = beansNames[name],
45707              set = dest['set' + part],
45708              get = dest['get' + part] || set && dest['is' + part];
45709          if (get && (beans === true || get.length === 0)) field(name, {
45710            get: get,
45711            set: set
45712          });
45713        }
45714      }
45715
45716      return dest;
45717    }
45718
45719    function Base() {
45720      for (var i = 0, l = arguments.length; i < l; i++) {
45721        var src = arguments[i];
45722        if (src) set(this, src);
45723      }
45724
45725      return this;
45726    }
45727
45728    return _inject(Base, {
45729      inject: function inject(src) {
45730        if (src) {
45731          var statics = src.statics === true ? src : src.statics,
45732              beans = src.beans,
45733              preserve = src.preserve;
45734          if (statics !== src) _inject(this.prototype, src, src.enumerable, beans, preserve);
45735
45736          _inject(this, statics, null, beans, preserve);
45737        }
45738
45739        for (var i = 1, l = arguments.length; i < l; i++) {
45740          this.inject(arguments[i]);
45741        }
45742
45743        return this;
45744      },
45745      extend: function extend() {
45746        var base = this,
45747            ctor,
45748            proto;
45749
45750        for (var i = 0, obj, l = arguments.length; i < l && !(ctor && proto); i++) {
45751          obj = arguments[i];
45752          ctor = ctor || obj.initialize;
45753          proto = proto || obj.prototype;
45754        }
45755
45756        ctor = ctor || function () {
45757          base.apply(this, arguments);
45758        };
45759
45760        proto = ctor.prototype = proto || create(this.prototype);
45761        define(proto, 'constructor', {
45762          value: ctor,
45763          writable: true,
45764          configurable: true
45765        });
45766
45767        _inject(ctor, this);
45768
45769        if (arguments.length) this.inject.apply(ctor, arguments);
45770        ctor.base = base;
45771        return ctor;
45772      }
45773    }).inject({
45774      enumerable: false,
45775      initialize: Base,
45776      set: Base,
45777      inject: function inject() {
45778        for (var i = 0, l = arguments.length; i < l; i++) {
45779          var src = arguments[i];
45780
45781          if (src) {
45782            _inject(this, src, src.enumerable, src.beans, src.preserve);
45783          }
45784        }
45785
45786        return this;
45787      },
45788      extend: function extend() {
45789        var res = create(this);
45790        return res.inject.apply(res, arguments);
45791      },
45792      each: function each(iter, bind) {
45793        return _each(this, iter, bind);
45794      },
45795      clone: function clone() {
45796        return new this.constructor(this);
45797      },
45798      statics: {
45799        set: set,
45800        each: _each,
45801        create: create,
45802        define: define,
45803        describe: describe,
45804        clone: function clone(obj) {
45805          return set(new obj.constructor(), obj);
45806        },
45807        isPlainObject: function isPlainObject(obj) {
45808          var ctor = obj != null && obj.constructor;
45809          return ctor && (ctor === Object || ctor === Base || ctor.name === 'Object');
45810        },
45811        pick: function pick(a, b) {
45812          return a !== undefined ? a : b;
45813        },
45814        slice: function slice(list, begin, end) {
45815          return _slice.call(list, begin, end);
45816        }
45817      }
45818    });
45819  }();
45820  if (typeof module !== 'undefined') module.exports = Base;
45821  Base.inject({
45822    enumerable: false,
45823    toString: function toString() {
45824      return this._id != null ? (this._class || 'Object') + (this._name ? " '" + this._name + "'" : ' @' + this._id) : '{ ' + Base.each(this, function (value, key) {
45825        if (!/^_/.test(key)) {
45826          var type = _typeof(value);
45827
45828          this.push(key + ': ' + (type === 'number' ? Formatter.instance.number(value) : type === 'string' ? "'" + value + "'" : value));
45829        }
45830      }, []).join(', ') + ' }';
45831    },
45832    getClassName: function getClassName() {
45833      return this._class || '';
45834    },
45835    importJSON: function importJSON(json) {
45836      return Base.importJSON(json, this);
45837    },
45838    exportJSON: function exportJSON(options) {
45839      return Base.exportJSON(this, options);
45840    },
45841    toJSON: function toJSON() {
45842      return Base.serialize(this);
45843    },
45844    set: function set(props, exclude) {
45845      if (props) Base.filter(this, props, exclude, this._prioritize);
45846      return this;
45847    }
45848  }, {
vendor: 9,451 bytes, lines 45849-46142
45849    beans: false,
45850    statics: {
45851      exports: {},
45852      extend: function extend() {
45853        var res = extend.base.apply(this, arguments),
45854            name = res.prototype._class;
45855        if (name && !Base.exports[name]) Base.exports[name] = res;
45856        return res;
45857      },
45858      equals: function equals(obj1, obj2) {
45859        if (obj1 === obj2) return true;
45860        if (obj1 && obj1.equals) return obj1.equals(obj2);
45861        if (obj2 && obj2.equals) return obj2.equals(obj1);
45862
45863        if (obj1 && obj2 && _typeof(obj1) === 'object' && _typeof(obj2) === 'object') {
45864          if (Array.isArray(obj1) && Array.isArray(obj2)) {
45865            var length = obj1.length;
45866            if (length !== obj2.length) return false;
45867
45868            while (length--) {
45869              if (!Base.equals(obj1[length], obj2[length])) return false;
45870            }
45871          } else {
45872            var keys = Object.keys(obj1),
45873                length = keys.length;
45874            if (length !== Object.keys(obj2).length) return false;
45875
45876            while (length--) {
45877              var key = keys[length];
45878              if (!(obj2.hasOwnProperty(key) && Base.equals(obj1[key], obj2[key]))) return false;
45879            }
45880          }
45881
45882          return true;
45883        }
45884
45885        return false;
45886      },
45887      read: function read(list, start, options, amount) {
45888        if (this === Base) {
45889          var value = this.peek(list, start);
45890          list.__index++;
45891          return value;
45892        }
45893
45894        var proto = this.prototype,
45895            readIndex = proto._readIndex,
45896            begin = start || readIndex && list.__index || 0,
45897            length = list.length,
45898            obj = list[begin];
45899        amount = amount || length - begin;
45900
45901        if (obj instanceof this || options && options.readNull && obj == null && amount <= 1) {
45902          if (readIndex) list.__index = begin + 1;
45903          return obj && options && options.clone ? obj.clone() : obj;
45904        }
45905
45906        obj = Base.create(proto);
45907        if (readIndex) obj.__read = true;
45908        obj = obj.initialize.apply(obj, begin > 0 || begin + amount < length ? Base.slice(list, begin, begin + amount) : list) || obj;
45909
45910        if (readIndex) {
45911          list.__index = begin + obj.__read;
45912          var filtered = obj.__filtered;
45913
45914          if (filtered) {
45915            list.__filtered = filtered;
45916            obj.__filtered = undefined;
45917          }
45918
45919          obj.__read = undefined;
45920        }
45921
45922        return obj;
45923      },
45924      peek: function peek(list, start) {
45925        return list[list.__index = start || list.__index || 0];
45926      },
45927      remain: function remain(list) {
45928        return list.length - (list.__index || 0);
45929      },
45930      readList: function readList(list, start, options, amount) {
45931        var res = [],
45932            entry,
45933            begin = start || 0,
45934            end = amount ? begin + amount : list.length;
45935
45936        for (var i = begin; i < end; i++) {
45937          res.push(Array.isArray(entry = list[i]) ? this.read(entry, 0, options) : this.read(list, i, options, 1));
45938        }
45939
45940        return res;
45941      },
45942      readNamed: function readNamed(list, name, start, options, amount) {
45943        var value = this.getNamed(list, name),
45944            hasValue = value !== undefined;
45945
45946        if (hasValue) {
45947          var filtered = list.__filtered;
45948
45949          if (!filtered) {
45950            var source = this.getSource(list);
45951            filtered = list.__filtered = Base.create(source);
45952            filtered.__unfiltered = source;
45953          }
45954
45955          filtered[name] = undefined;
45956        }
45957
45958        return this.read(hasValue ? [value] : list, start, options, amount);
45959      },
45960      readSupported: function readSupported(list, dest) {
45961        var source = this.getSource(list),
45962            that = this,
45963            read = false;
45964
45965        if (source) {
45966          Object.keys(source).forEach(function (key) {
45967            if (key in dest) {
45968              var value = that.readNamed(list, key);
45969
45970              if (value !== undefined) {
45971                dest[key] = value;
45972              }
45973
45974              read = true;
45975            }
45976          });
45977        }
45978
45979        return read;
45980      },
45981      getSource: function getSource(list) {
45982        var source = list.__source;
45983
45984        if (source === undefined) {
45985          var arg = list.length === 1 && list[0];
45986          source = list.__source = arg && Base.isPlainObject(arg) ? arg : null;
45987        }
45988
45989        return source;
45990      },
45991      getNamed: function getNamed(list, name) {
45992        var source = this.getSource(list);
45993
45994        if (source) {
45995          return name ? source[name] : list.__filtered || source;
45996        }
45997      },
45998      hasNamed: function hasNamed(list, name) {
45999        return !!this.getNamed(list, name);
46000      },
46001      filter: function filter(dest, source, exclude, prioritize) {
46002        var processed;
46003
46004        function handleKey(key) {
46005          if (!(exclude && key in exclude) && !(processed && key in processed)) {
46006            var value = source[key];
46007            if (value !== undefined) dest[key] = value;
46008          }
46009        }
46010
46011        if (prioritize) {
46012          var keys = {};
46013
46014          for (var i = 0, key, l = prioritize.length; i < l; i++) {
46015            if ((key = prioritize[i]) in source) {
46016              handleKey(key);
46017              keys[key] = true;
46018            }
46019          }
46020
46021          processed = keys;
46022        }
46023
46024        Object.keys(source.__unfiltered || source).forEach(handleKey);
46025        return dest;
46026      },
46027      isPlainValue: function isPlainValue(obj, asString) {
46028        return Base.isPlainObject(obj) || Array.isArray(obj) || asString && typeof obj === 'string';
46029      },
46030      serialize: function serialize(obj, options, compact, dictionary) {
46031        options = options || {};
46032        var isRoot = !dictionary,
46033            res;
46034
46035        if (isRoot) {
46036          options.formatter = new Formatter(options.precision);
46037          dictionary = {
46038            length: 0,
46039            definitions: {},
46040            references: {},
46041            add: function add(item, create) {
46042              var id = '#' + item._id,
46043                  ref = this.references[id];
46044
46045              if (!ref) {
46046                this.length++;
46047                var res = create.call(item),
46048                    name = item._class;
46049                if (name && res[0] !== name) res.unshift(name);
46050                this.definitions[id] = res;
46051                ref = this.references[id] = [id];
46052              }
46053
46054              return ref;
46055            }
46056          };
46057        }
46058
46059        if (obj && obj._serialize) {
46060          res = obj._serialize(options, dictionary);
46061          var name = obj._class;
46062
46063          if (name && !obj._compactSerialize && (isRoot || !compact) && res[0] !== name) {
46064            res.unshift(name);
46065          }
46066        } else if (Array.isArray(obj)) {
46067          res = [];
46068
46069          for (var i = 0, l = obj.length; i < l; i++) {
46070            res[i] = Base.serialize(obj[i], options, compact, dictionary);
46071          }
46072        } else if (Base.isPlainObject(obj)) {
46073          res = {};
46074          var keys = Object.keys(obj);
46075
46076          for (var i = 0, l = keys.length; i < l; i++) {
46077            var key = keys[i];
46078            res[key] = Base.serialize(obj[key], options, compact, dictionary);
46079          }
46080        } else if (typeof obj === 'number') {
46081          res = options.formatter.number(obj, options.precision);
46082        } else {
46083          res = obj;
46084        }
46085
46086        return isRoot && dictionary.length > 0 ? [['dictionary', dictionary.definitions], res] : res;
46087      },
46088      deserialize: function deserialize(json, create, _data, _setDictionary, _isRoot) {
46089        var res = json,
46090            isFirst = !_data,
46091            hasDictionary = isFirst && json && json.length && json[0][0] === 'dictionary';
46092        _data = _data || {};
46093
46094        if (Array.isArray(json)) {
46095          var type = json[0],
46096              isDictionary = type === 'dictionary';
46097
46098          if (json.length == 1 && /^#/.test(type)) {
46099            return _data.dictionary[type];
46100          }
46101
46102          type = Base.exports[type];
46103          res = [];
46104
46105          for (var i = type ? 1 : 0, l = json.length; i < l; i++) {
46106            res.push(Base.deserialize(json[i], create, _data, isDictionary, hasDictionary));
46107          }
46108
46109          if (type) {
46110            var args = res;
46111
46112            if (create) {
46113              res = create(type, args, isFirst || _isRoot);
46114            } else {
46115              res = new type(args);
46116            }
46117          }
46118        } else if (Base.isPlainObject(json)) {
46119          res = {};
46120          if (_setDictionary) _data.dictionary = res;
46121
46122          for (var key in json) {
46123            res[key] = Base.deserialize(json[key], create, _data);
46124          }
46125        }
46126
46127        return hasDictionary ? res[1] : res;
46128      },
46129      exportJSON: function exportJSON(obj, options) {
46130        var json = Base.serialize(obj, options);
46131        return options && options.asString == false ? json : JSON.stringify(json);
46132      },
46133      importJSON: function importJSON(json, target) {
46134        return Base.deserialize(typeof json === 'string' ? JSON.parse(json) : json, function (ctor, args, isRoot) {
46135          var useTarget = isRoot && target && target.constructor === ctor,
46136              obj = useTarget ? target : Base.create(ctor.prototype);
46137
46138          if (args.length === 1 && obj instanceof Item && (useTarget || !(obj instanceof Layer))) {
46139            var arg = args[0];
46140
46141            if (Base.isPlainObject(arg)) {
46142              arg.insert = false;
46143
46144              if (useTarget) {
46145                args = args.concat([{
46146                  insert: true
46147                }]);
46148              }
46149            }
46150          }
46151
46152          (useTarget ? obj.set : ctor).apply(obj, args);
46153          if (useTarget) target = null;
46154          return obj;
46155        });
46156      },
46157      push: function push(list, items) {
46158        var itemsLength = items.length;
46159
46160        if (itemsLength < 4096) {
46161          list.push.apply(list, items);
46162        } else {
46163          var startLength = list.length;
46164          list.length += itemsLength;
46165
46166          for (var i = 0; i < itemsLength; i++) {
46167            list[startLength + i] = items[i];
46168          }
46169        }
46170
46171        return list;
46172      },
46173      splice: function splice(list, items, index, remove) {
46174        var amount = items && items.length,
46175            append = index === undefined;
46176        index = append ? list.length : index;
46177        if (index > list.length) index = list.length;
46178
46179        for (var i = 0; i < amount; i++) {
46180          items[i]._index = index + i;
46181        }
46182
46183        if (append) {
46184          Base.push(list, items);
46185          return [];
46186        } else {
46187          var args = [index, remove];
46188          if (items) Base.push(args, items);
vendor: 6,753 bytes, lines 46189-46407
46189          var removed = list.splice.apply(list, args);
46190
46191          for (var i = 0, l = removed.length; i < l; i++) {
46192            removed[i]._index = undefined;
46193          }
46194
46195          for (var i = index + amount, l = list.length; i < l; i++) {
46196            list[i]._index = i;
46197          }
46198
46199          return removed;
46200        }
46201      },
46202      capitalize: function capitalize(str) {
46203        return str.replace(/\b[a-z]/g, function (match) {
46204          return match.toUpperCase();
46205        });
46206      },
46207      camelize: function camelize(str) {
46208        return str.replace(/-(.)/g, function (match, chr) {
46209          return chr.toUpperCase();
46210        });
46211      },
46212      hyphenate: function hyphenate(str) {
46213        return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
46214      }
46215    }
46216  });
46217  var Emitter = {
46218    on: function on(type, func) {
46219      if (typeof type !== 'string') {
46220        Base.each(type, function (value, key) {
46221          this.on(key, value);
46222        }, this);
46223      } else {
46224        var types = this._eventTypes,
46225            entry = types && types[type],
46226            handlers = this._callbacks = this._callbacks || {};
46227        handlers = handlers[type] = handlers[type] || [];
46228
46229        if (handlers.indexOf(func) === -1) {
46230          handlers.push(func);
46231          if (entry && entry.install && handlers.length === 1) entry.install.call(this, type);
46232        }
46233      }
46234
46235      return this;
46236    },
46237    off: function off(type, func) {
46238      if (typeof type !== 'string') {
46239        Base.each(type, function (value, key) {
46240          this.off(key, value);
46241        }, this);
46242        return;
46243      }
46244
46245      var types = this._eventTypes,
46246          entry = types && types[type],
46247          handlers = this._callbacks && this._callbacks[type],
46248          index;
46249
46250      if (handlers) {
46251        if (!func || (index = handlers.indexOf(func)) !== -1 && handlers.length === 1) {
46252          if (entry && entry.uninstall) entry.uninstall.call(this, type);
46253          delete this._callbacks[type];
46254        } else if (index !== -1) {
46255          handlers.splice(index, 1);
46256        }
46257      }
46258
46259      return this;
46260    },
46261    once: function once(type, func) {
46262      return this.on(type, function handler() {
46263        func.apply(this, arguments);
46264        this.off(type, handler);
46265      });
46266    },
46267    emit: function emit(type, event) {
46268      var handlers = this._callbacks && this._callbacks[type];
46269      if (!handlers) return false;
46270      var args = Base.slice(arguments, 1),
46271          setTarget = event && event.target && !event.currentTarget;
46272      handlers = handlers.slice();
46273      if (setTarget) event.currentTarget = this;
46274
46275      for (var i = 0, l = handlers.length; i < l; i++) {
46276        if (handlers[i].apply(this, args) == false) {
46277          if (event && event.stop) event.stop();
46278          break;
46279        }
46280      }
46281
46282      if (setTarget) delete event.currentTarget;
46283      return true;
46284    },
46285    responds: function responds(type) {
46286      return !!(this._callbacks && this._callbacks[type]);
46287    },
46288    attach: '#on',
46289    detach: '#off',
46290    fire: '#emit',
46291    _installEvents: function _installEvents(install) {
46292      var types = this._eventTypes,
46293          handlers = this._callbacks,
46294          key = install ? 'install' : 'uninstall';
46295
46296      if (types) {
46297        for (var type in handlers) {
46298          if (handlers[type].length > 0) {
46299            var entry = types[type],
46300                func = entry && entry[key];
46301            if (func) func.call(this, type);
46302          }
46303        }
46304      }
46305    },
46306    statics: {
46307      inject: function inject(src) {
46308        var events = src._events;
46309
46310        if (events) {
46311          var types = {};
46312          Base.each(events, function (entry, key) {
46313            var isString = typeof entry === 'string',
46314                name = isString ? entry : key,
46315                part = Base.capitalize(name),
46316                type = name.substring(2).toLowerCase();
46317            types[type] = isString ? {} : entry;
46318            name = '_' + name;
46319
46320            src['get' + part] = function () {
46321              return this[name];
46322            };
46323
46324            src['set' + part] = function (func) {
46325              var prev = this[name];
46326              if (prev) this.off(type, prev);
46327              if (func) this.on(type, func);
46328              this[name] = func;
46329            };
46330          });
46331          src._eventTypes = types;
46332        }
46333
46334        return inject.base.apply(this, arguments);
46335      }
46336    }
46337  };
46338  var PaperScope = Base.extend({
46339    _class: 'PaperScope',
46340    initialize: function PaperScope() {
46341      paper = this;
46342      this.settings = new Base({
46343        applyMatrix: true,
46344        insertItems: true,
46345        handleSize: 4,
46346        hitTolerance: 0
46347      });
46348      this.project = null;
46349      this.projects = [];
46350      this.tools = [];
46351      this._id = PaperScope._id++;
46352      PaperScope._scopes[this._id] = this;
46353      var proto = PaperScope.prototype;
46354
46355      if (!this.support) {
46356        var ctx = CanvasProvider.getContext(1, 1) || {};
46357        proto.support = {
46358          nativeDash: 'setLineDash' in ctx || 'mozDash' in ctx,
46359          nativeBlendModes: BlendMode.nativeModes
46360        };
46361        CanvasProvider.release(ctx);
46362      }
46363
46364      if (!this.agent) {
46365        var user = self.navigator.userAgent.toLowerCase(),
46366            os = (/(darwin|win|mac|linux|freebsd|sunos)/.exec(user) || [])[0],
46367            platform = os === 'darwin' ? 'mac' : os,
46368            agent = proto.agent = proto.browser = {
46369          platform: platform
46370        };
46371        if (platform) agent[platform] = true;
46372        user.replace(/(opera|chrome|safari|webkit|firefox|msie|trident|atom|node|jsdom)\/?\s*([.\d]+)(?:.*version\/([.\d]+))?(?:.*rv\:v?([.\d]+))?/g, function (match, n, v1, v2, rv) {
46373          if (!agent.chrome) {
46374            var v = n === 'opera' ? v2 : /^(node|trident)$/.test(n) ? rv : v1;
46375            agent.version = v;
46376            agent.versionNumber = parseFloat(v);
46377            n = {
46378              trident: 'msie',
46379              jsdom: 'node'
46380            }[n] || n;
46381            agent.name = n;
46382            agent[n] = true;
46383          }
46384        });
46385        if (agent.chrome) delete agent.webkit;
46386        if (agent.atom) delete agent.chrome;
46387      }
46388    },
46389    version: "0.12.4",
46390    getView: function getView() {
46391      var project = this.project;
46392      return project && project._view;
46393    },
46394    getPaper: function getPaper() {
46395      return this;
46396    },
46397    execute: function execute(code, options) {
46398      var exports = paper.PaperScript.execute(code, this, options);
46399      View.updateFocus();
46400      return exports;
46401    },
46402    install: function install(scope) {
46403      var that = this;
46404      Base.each(['project', 'view', 'tool'], function (key) {
46405        Base.define(scope, key, {
46406          configurable: true,
46407          get: function get() {
46408            return that[key];
46409          }
46410        });
46411      });
46412
46413      for (var key in this) {
46414        if (!/^_/.test(key) && this[key]) scope[key] = this[key];
46415      }
46416    },
46417    setup: function setup(element) {
46418      paper = this;
46419      this.project = new Project(element);
46420      return this;
46421    },
46422    createCanvas: function createCanvas(width, height) {
46423      return CanvasProvider.getCanvas(width, height);
46424    },
46425    activate: function activate() {
46426      paper = this;
46427    },
46428    clear: function clear() {
46429      var projects = this.projects,
46430          tools = this.tools;
46431
46432      for (var i = projects.length - 1; i >= 0; i--) {
46433        projects[i].remove();
46434      }
46435
46436      for (var i = tools.length - 1; i >= 0; i--) {
46437        tools[i].remove();
46438      }
46439    },
46440    remove: function remove() {
46441      this.clear();
46442      delete PaperScope._scopes[this._id];
46443    },
46444    statics: new function () {
46445      function handleAttribute(name) {
46446        name += 'Attribute';
46447        return function (el, attr) {
46448          return el[name](attr) || el[name]('data-paper-' + attr);
46449        };
46450      }
46451
46452      return {
46453        _scopes: {},
46454        _id: 0,
46455        get: function get(id) {
46456          return this._scopes[id] || null;
46457        },
46458        getAttribute: handleAttribute('get'),
46459        hasAttribute: handleAttribute('has')
46460      };
46461    }()
46462  });
46463  var PaperScopeItem = Base.extend(Emitter, {
46464    initialize: function initialize(activate) {
46465      this._scope = paper;
46466      this._index = this._scope[this._list].push(this) - 1;
46467      if (activate || !this._scope[this._reference]) this.activate();
46468    },
46469    activate: function activate() {
46470      if (!this._scope) return false;
46471      var prev = this._scope[this._reference];
46472      if (prev && prev !== this) prev.emit('deactivate');
46473      this._scope[this._reference] = this;
46474      this.emit('activate', prev);
46475      return true;
46476    },
46477    isActive: function isActive() {
46478      return this._scope[this._reference] === this;
46479    },
46480    remove: function remove() {
46481      if (this._index == null) return false;
46482      Base.splice(this._scope[this._list], null, this._index, 1);
46483      if (this._scope[this._reference] == this) this._scope[this._reference] = null;
46484      this._scope = null;
46485      return true;
46486    },
46487    getView: function getView() {
46488      return this._scope.getView();
46489    }
46490  });
46491  var CollisionDetection = {
46492    findItemBoundsCollisions: function findItemBoundsCollisions(items1, items2, tolerance) {
46493      function getBounds(items) {
46494        var bounds = new Array(items.length);
46495
46496        for (var i = 0; i < items.length; i++) {
46497          var rect = items[i].getBounds();
46498          bounds[i] = [rect.left, rect.top, rect.right, rect.bottom];
46499        }
46500
46501        return bounds;
46502      }
46503
46504      var bounds1 = getBounds(items1),
46505          bounds2 = !items2 || items2 === items1 ? bounds1 : getBounds(items2);
46506      return this.findBoundsCollisions(bounds1, bounds2, tolerance || 0);
46507    },
46508    findCurveBoundsCollisions: function findCurveBoundsCollisions(curves1, curves2, tolerance, bothAxis) {
46509      function getBounds(curves) {
46510        var min = Math.min,
46511            max = Math.max,
46512            bounds = new Array(curves.length);
46513
46514        for (var i = 0; i < curves.length; i++) {
46515          var v = curves[i];
46516          bounds[i] = [min(v[0], v[2], v[4], v[6]), min(v[1], v[3], v[5], v[7]), max(v[0], v[2], v[4], v[6]), max(v[1], v[3], v[5], v[7])];
46517        }
46518
46519        return bounds;
46520      }
46521
46522      var bounds1 = getBounds(curves1),
46523          bounds2 = !curves2 || curves2 === curves1 ? bounds1 : getBounds(curves2);
46524
46525      if (bothAxis) {
46526        var hor = this.findBoundsCollisions(bounds1, bounds2, tolerance || 0, false, true),
46527            ver = this.findBoundsCollisions(bounds1, bounds2, tolerance || 0, true, true),
46528            list = [];
46529
46530        for (var i = 0, l = hor.length; i < l; i++) {
46531          list[i] = {
46532            hor: hor[i],
46533            ver: ver[i]
46534          };
46535        }
46536
46537        return list;
46538      }
46539
46540      return this.findBoundsCollisions(bounds1, bounds2, tolerance || 0);
46541    },
46542    findBoundsCollisions: function findBoundsCollisions(boundsA, boundsB, tolerance, sweepVertical, onlySweepAxisCollisions) {
vendor: 6,764 bytes, lines 46543-46677
46543      var self = !boundsB || boundsA === boundsB,
46544          allBounds = self ? boundsA : boundsA.concat(boundsB),
46545          lengthA = boundsA.length,
46546          lengthAll = allBounds.length;
46547
46548      function binarySearch(indices, coord, value) {
46549        var lo = 0,
46550            hi = indices.length;
46551
46552        while (lo < hi) {
46553          var mid = hi + lo >>> 1;
46554
46555          if (allBounds[indices[mid]][coord] < value) {
46556            lo = mid + 1;
46557          } else {
46558            hi = mid;
46559          }
46560        }
46561
46562        return lo - 1;
46563      }
46564
46565      var pri0 = sweepVertical ? 1 : 0,
46566          pri1 = pri0 + 2,
46567          sec0 = sweepVertical ? 0 : 1,
46568          sec1 = sec0 + 2;
46569      var allIndicesByPri0 = new Array(lengthAll);
46570
46571      for (var i = 0; i < lengthAll; i++) {
46572        allIndicesByPri0[i] = i;
46573      }
46574
46575      allIndicesByPri0.sort(function (i1, i2) {
46576        return allBounds[i1][pri0] - allBounds[i2][pri0];
46577      });
46578      var activeIndicesByPri1 = [],
46579          allCollisions = new Array(lengthA);
46580
46581      for (var i = 0; i < lengthAll; i++) {
46582        var curIndex = allIndicesByPri0[i],
46583            curBounds = allBounds[curIndex],
46584            origIndex = self ? curIndex : curIndex - lengthA,
46585            isCurrentA = curIndex < lengthA,
46586            isCurrentB = self || !isCurrentA,
46587            curCollisions = isCurrentA ? [] : null;
46588
46589        if (activeIndicesByPri1.length) {
46590          var pruneCount = binarySearch(activeIndicesByPri1, pri1, curBounds[pri0] - tolerance) + 1;
46591          activeIndicesByPri1.splice(0, pruneCount);
46592
46593          if (self && onlySweepAxisCollisions) {
46594            curCollisions = curCollisions.concat(activeIndicesByPri1);
46595
46596            for (var j = 0; j < activeIndicesByPri1.length; j++) {
46597              var activeIndex = activeIndicesByPri1[j];
46598              allCollisions[activeIndex].push(origIndex);
46599            }
46600          } else {
46601            var curSec1 = curBounds[sec1],
46602                curSec0 = curBounds[sec0];
46603
46604            for (var j = 0; j < activeIndicesByPri1.length; j++) {
46605              var activeIndex = activeIndicesByPri1[j],
46606                  activeBounds = allBounds[activeIndex],
46607                  isActiveA = activeIndex < lengthA,
46608                  isActiveB = self || activeIndex >= lengthA;
46609
46610              if (onlySweepAxisCollisions || (isCurrentA && isActiveB || isCurrentB && isActiveA) && curSec1 >= activeBounds[sec0] - tolerance && curSec0 <= activeBounds[sec1] + tolerance) {
46611                if (isCurrentA && isActiveB) {
46612                  curCollisions.push(self ? activeIndex : activeIndex - lengthA);
46613                }
46614
46615                if (isCurrentB && isActiveA) {
46616                  allCollisions[activeIndex].push(origIndex);
46617                }
46618              }
46619            }
46620          }
46621        }
46622
46623        if (isCurrentA) {
46624          if (boundsA === boundsB) {
46625            curCollisions.push(curIndex);
46626          }
46627
46628          allCollisions[curIndex] = curCollisions;
46629        }
46630
46631        if (activeIndicesByPri1.length) {
46632          var curPri1 = curBounds[pri1],
46633              index = binarySearch(activeIndicesByPri1, pri1, curPri1);
46634          activeIndicesByPri1.splice(index + 1, 0, curIndex);
46635        } else {
46636          activeIndicesByPri1.push(curIndex);
46637        }
46638      }
46639
46640      for (var i = 0; i < allCollisions.length; i++) {
46641        var collisions = allCollisions[i];
46642
46643        if (collisions) {
46644          collisions.sort(function (i1, i2) {
46645            return i1 - i2;
46646          });
46647        }
46648      }
46649
46650      return allCollisions;
46651    }
46652  };
46653  var Formatter = Base.extend({
46654    initialize: function initialize(precision) {
46655      this.precision = Base.pick(precision, 5);
46656      this.multiplier = Math.pow(10, this.precision);
46657    },
46658    number: function number(val) {
46659      return this.precision < 16 ? Math.round(val * this.multiplier) / this.multiplier : val;
46660    },
46661    pair: function pair(val1, val2, separator) {
46662      return this.number(val1) + (separator || ',') + this.number(val2);
46663    },
46664    point: function point(val, separator) {
46665      return this.number(val.x) + (separator || ',') + this.number(val.y);
46666    },
46667    size: function size(val, separator) {
46668      return this.number(val.width) + (separator || ',') + this.number(val.height);
46669    },
46670    rectangle: function rectangle(val, separator) {
46671      return this.point(val, separator) + (separator || ',') + this.size(val, separator);
46672    }
46673  });
46674  Formatter.instance = new Formatter();
46675  var Numerical = new function () {
46676    var abscissas = [[0.5773502691896257645091488], [0, 0.7745966692414833770358531], [0.3399810435848562648026658, 0.8611363115940525752239465], [0, 0.5384693101056830910363144, 0.9061798459386639927976269], [0.2386191860831969086305017, 0.6612093864662645136613996, 0.9324695142031520278123016], [0, 0.4058451513773971669066064, 0.7415311855993944398638648, 0.9491079123427585245261897], [0.1834346424956498049394761, 0.5255324099163289858177390, 0.7966664774136267395915539, 0.9602898564975362316835609], [0, 0.3242534234038089290385380, 0.6133714327005903973087020, 0.8360311073266357942994298, 0.9681602395076260898355762], [0.1488743389816312108848260, 0.4333953941292471907992659, 0.6794095682990244062343274, 0.8650633666889845107320967, 0.9739065285171717200779640], [0, 0.2695431559523449723315320, 0.5190961292068118159257257, 0.7301520055740493240934163, 0.8870625997680952990751578, 0.9782286581460569928039380], [0.1252334085114689154724414, 0.3678314989981801937526915, 0.5873179542866174472967024, 0.7699026741943046870368938, 0.9041172563704748566784659, 0.9815606342467192506905491], [0, 0.2304583159551347940655281, 0.4484927510364468528779129, 0.6423493394403402206439846, 0.8015780907333099127942065, 0.9175983992229779652065478, 0.9841830547185881494728294], [0.1080549487073436620662447, 0.3191123689278897604356718, 0.5152486363581540919652907, 0.6872929048116854701480198, 0.8272013150697649931897947, 0.9284348836635735173363911, 0.9862838086968123388415973], [0, 0.2011940939974345223006283, 0.3941513470775633698972074, 0.5709721726085388475372267, 0.7244177313601700474161861, 0.8482065834104272162006483, 0.9372733924007059043077589, 0.9879925180204854284895657], [0.0950125098376374401853193, 0.2816035507792589132304605, 0.4580167776572273863424194, 0.6178762444026437484466718, 0.7554044083550030338951012, 0.8656312023878317438804679, 0.9445750230732325760779884, 0.9894009349916499325961542]];
46677    var weights = [[1], [0.8888888888888888888888889, 0.5555555555555555555555556], [0.6521451548625461426269361, 0.3478548451374538573730639], [0.5688888888888888888888889, 0.4786286704993664680412915, 0.2369268850561890875142640], [0.4679139345726910473898703, 0.3607615730481386075698335, 0.1713244923791703450402961], [0.4179591836734693877551020, 0.38183
4667700505051189449503698, 0.2797053914892766679014678, 0.1294849661688696932706114], [0.3626837833783619829651504, 0.3137066458778872873379622, 0.2223810344533744705443560, 0.1012285362903762591525314], [0.3302393550012597631645251, 0.3123470770400028400686304, 0.2606106964029354623187429, 0.1806481606948574040584720, 0.0812743883615744119718922], [0.2955242247147528701738930, 0.2692667193099963550912269, 0.2190863625159820439955349, 0.1494513491505805931457763, 0.0666713443086881375935688], [0.2729250867779006307144835, 0.2628045445102466621806889, 0.2331937645919904799185237, 0.1862902109277342514260976, 0.1255803694649046246346943, 0.0556685671161736664827537], [0.2491470458134027850005624, 0.2334925365383548087608499, 0.2031674267230659217490645, 0.1600783285433462263346525, 0.1069393259953184309602547, 0.0471753363865118271946160], [0.2325515532308739101945895, 0.2262831802628972384120902, 0.2078160475368885023125232, 0.1781459807619457382800467, 0.1388735102197872384636018, 0.0921214998377284479144218, 0.0404840047653158795200216], [0.2152638534631577901958764, 0.2051984637212956039659241, 0.1855383974779378137417166, 0.1572031671581935345696019, 0.1215185706879031846894148, 0.0801580871597602098056333, 0.0351194603317518630318329], [0.2025782419255612728806202, 0.1984314853271115764561183, 0.1861610000155622110268006, 0.1662692058169939335532009, 0.1395706779261543144478048, 0.1071592204671719350118695, 0.0703660474881081247092674, 0.0307532419961172683546284], [0.1894506104550684962853967, 0.1826034150449235888667637, 0.1691565193950025381893121, 0.1495959888165767320815017, 0.1246289712555338720524763, 0.0951585116824927848099251, 0.0622535239386478928628438, 0.0271524594117540948517806]];
46678
46679    var abs = Math.abs,
46680        sqrt = Math.sqrt,
46681        pow = Math.pow,
46682        log2 = Math.log2 || function (x) {
46683      return Math.log(x) * Math.LOG2E;
46684    },
46685        EPSILON = 1e-12,
46686        MACHINE_EPSILON = 1.12e-16;
46687
46688    function clamp(value, min, max) {
46689      return value < min ? min : value > max ? max : value;
46690    }
46691
46692    function getDiscriminant(a, b, c) {
46693      function split(v) {
46694        var x = v * 134217729,
46695            y = v - x,
46696            hi = y + x,
46697            lo = v - hi;
46698        return [hi, lo];
46699      }
46700
46701      var D = b * b - a * c,
46702          E = b * b + a * c;
46703
46704      if (abs(D) * 3 < E) {
46705        var ad = split(a),
46706            bd = split(b),
46707            cd = split(c),
46708            p = b * b,
46709            dp = bd[0] * bd[0] - p + 2 * bd[0] * bd[1] + bd[1] * bd[1],
46710            q = a * c,
46711            dq = ad[0] * cd[0] - q + ad[0] * cd[1] + ad[1] * cd[0] + ad[1] * cd[1];
46712        D = p - q + (dp - dq);
46713      }
46714
46715      return D;
46716    }
46717
46718    function getNormalizationFactor() {
46719      var norm = Math.max.apply(Math, arguments);
46720      return norm && (norm < 1e-8 || norm > 1e8) ? pow(2, -Math.round(log2(norm))) : 0;
46721    }
46722
46723    return {
46724      EPSILON: EPSILON,
46725      MACHINE_EPSILON: MACHINE_EPSILON,
46726      CURVETIME_EPSILON: 1e-8,
46727      GEOMETRIC_EPSILON: 1e-7,
46728      TRIGONOMETRIC_EPSILON: 1e-8,
46729      KAPPA: 4 * (sqrt(2) - 1) / 3,
46730      isZero: function isZero(val) {
46731        return val >= -EPSILON && val <= EPSILON;
46732      },
46733      isMachineZero: function isMachineZero(val) {
46734        return val >= -MACHINE_EPSILON && val <= MACHINE_EPSILON;
46735      },
46736      clamp: clamp,
46737      integrate: function integrate(f, a, b, n) {
46738        var x = abscissas[n - 2],
46739            w = weights[n - 2],
46740            A = (b - a) * 0.5,
46741            B = A + a,
46742            i = 0,
46743            m = n + 1 >> 1,
46744            sum = n & 1 ? w[i++] * f(B) : 0;
46745
46746        while (i < m) {
46747          var Ax = A * x[i];
46748          sum += w[i++] * (f(B + Ax) + f(B - Ax));
46749        }
46750
46751        return A * sum;
46752      },
46753      findRoot: function findRoot(f, df, x, a, b, n, tolerance) {
46754        for (var i = 0; i < n; i++) {
46755          var fx = f(x),
46756              dx = fx / df(x),
46757              nx = x - dx;
46758
46759          if (abs(dx) < tolerance) {
46760            x = nx;
46761            break;
46762          }
46763
46764          if (fx > 0) {
46765            b = x;
46766            x = nx <= a ? (a + b) * 0.5 : nx;
46767          } else {
46768            a = x;
46769            x = nx >= b ? (a + b) * 0.5 : nx;
46770          }
46771        }
46772
46773        return clamp(x, a, b);
46774      },
46775      solveQuadratic: function solveQuadratic(a, b, c, roots, min, max) {
46776        var x1,
46777            x2 = Infinity;
46778
46779        if (abs(a) < EPSILON) {
46780          if (abs(b) < EPSILON) return abs(c) < EPSILON ? -1 : 0;
46781          x1 = -c / b;
46782        } else {
46783          b *= -0.5;
46784          var D = getDiscriminant(a, b, c);
46785
46786          if (D && abs(D) < MACHINE_EPSILON) {
46787            var f = getNormalizationFactor(abs(a), abs(b), abs(c));
46788
46789            if (f) {
46790              a *= f;
46791              b *= f;
46792              c *= f;
46793              D = getDiscriminant(a, b, c);
46794            }
46795          }
46796
46797          if (D >= -MACHINE_EPSILON) {
46798            var Q = D < 0 ? 0 : sqrt(D),
46799                R = b + (b < 0 ? -Q : Q);
46800
46801            if (R === 0) {
46802              x1 = c / a;
46803              x2 = -x1;
46804            } else {
46805              x1 = R / a;
46806              x2 = c / R;
46807            }
46808          }
46809        }
46810
46811        var count = 0,
46812            boundless = min == null,
46813            minB = min - EPSILON,
46814            maxB = max + EPSILON;
46815        if (isFinite(x1) && (boundless || x1 >
vendor: 4,165 bytes, lines 46815-46960
46815 minB && x1 < maxB)) roots[count++] = boundless ? x1 : clamp(x1, min, max);
46816        if (x2 !== x1 && isFinite(x2) && (boundless || x2 > minB && x2 < maxB)) roots[count++] = boundless ? x2 : clamp(x2, min, max);
46817        return count;
46818      },
46819      solveCubic: function solveCubic(a, b, c, d, roots, min, max) {
46820        var f = getNormalizationFactor(abs(a), abs(b), abs(c), abs(d)),
46821            x,
46822            b1,
46823            c2,
46824            qd,
46825            q;
46826
46827        if (f) {
46828          a *= f;
46829          b *= f;
46830          c *= f;
46831          d *= f;
46832        }
46833
46834        function evaluate(x0) {
46835          x = x0;
46836          var tmp = a * x;
46837          b1 = tmp + b;
46838          c2 = b1 * x + c;
46839          qd = (tmp + b1) * x + c2;
46840          q = c2 * x + d;
46841        }
46842
46843        if (abs(a) < EPSILON) {
46844          a = b;
46845          b1 = c;
46846          c2 = d;
46847          x = Infinity;
46848        } else if (abs(d) < EPSILON) {
46849          b1 = b;
46850          c2 = c;
46851          x = 0;
46852        } else {
46853          evaluate(-(b / a) / 3);
46854          var t = q / a,
46855              r = pow(abs(t), 1 / 3),
46856              s = t < 0 ? -1 : 1,
46857              td = -qd / a,
46858              rd = td > 0 ? 1.324717957244746 * Math.max(r, sqrt(td)) : r,
46859              x0 = x - s * rd;
46860
46861          if (x0 !== x) {
46862            do {
46863              evaluate(x0);
46864              x0 = qd === 0 ? x : x - q / qd / (1 + MACHINE_EPSILON);
46865            } while (s * x0 > s * x);
46866
46867            if (abs(a) * x * x > abs(d / x)) {
46868              c2 = -d / x;
46869              b1 = (c2 - c) / x;
46870            }
46871          }
46872        }
46873
46874        var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max),
46875            boundless = min == null;
46876        if (isFinite(x) && (count === 0 || count > 0 && x !== roots[0] && x !== roots[1]) && (boundless || x > min - EPSILON && x < max + EPSILON)) roots[count++] = boundless ? x : clamp(x, min, max);
46877        return count;
46878      }
46879    };
46880  }();
46881  var UID = {
46882    _id: 1,
46883    _pools: {},
46884    get: function get(name) {
46885      if (name) {
46886        var pool = this._pools[name];
46887        if (!pool) pool = this._pools[name] = {
46888          _id: 1
46889        };
46890        return pool._id++;
46891      } else {
46892        return this._id++;
46893      }
46894    }
46895  };
46896  var Point = Base.extend({
46897    _class: 'Point',
46898    _readIndex: true,
46899    initialize: function Point(arg0, arg1) {
46900      var type = _typeof(arg0),
46901          reading = this.__read,
46902          read = 0;
46903
46904      if (type === 'number') {
46905        var hasY = typeof arg1 === 'number';
46906
46907        this._set(arg0, hasY ? arg1 : arg0);
46908
46909        if (reading) read = hasY ? 2 : 1;
46910      } else if (type === 'undefined' || arg0 === null) {
46911        this._set(0, 0);
46912
46913        if (reading) read = arg0 === null ? 1 : 0;
46914      } else {
46915        var obj = type === 'string' ? arg0.split(/[\s,]+/) || [] : arg0;
46916        read = 1;
46917
46918        if (Array.isArray(obj)) {
46919          this._set(+obj[0], +(obj.length > 1 ? obj[1] : obj[0]));
46920        } else if ('x' in obj) {
46921          this._set(obj.x || 0, obj.y || 0);
46922        } else if ('width' in obj) {
46923          this._set(obj.width || 0, obj.height || 0);
46924        } else if ('angle' in obj) {
46925          this._set(obj.length || 0, 0);
46926
46927          this.setAngle(obj.angle || 0);
46928        } else {
46929          this._set(0, 0);
46930
46931          read = 0;
46932        }
46933      }
46934
46935      if (reading) this.__read = read;
46936      return this;
46937    },
46938    set: '#initialize',
46939    _set: function _set(x, y) {
46940      this.x = x;
46941      this.y = y;
46942      return this;
46943    },
46944    equals: function equals(point) {
46945      return this === point || point && (this.x === point.x && this.y === point.y || Array.isArray(point) && this.x === point[0] && this.y === point[1]) || false;
46946    },
46947    clone: function clone() {
46948      return new Point(this.x, this.y);
46949    },
46950    toString: function toString() {
46951      var f = Formatter.instance;
46952      return '{ x: ' + f.number(this.x) + ', y: ' + f.number(this.y) + ' }';
46953    },
46954    _serialize: function _serialize(options) {
46955      var f = options.formatter;
46956      return [f.number(this.x), f.number(this.y)];
46957    },
46958    getLength: function getLength() {
46959      return Math.sqrt(this.x * this.x + this.y * this.y);
46960    },
46961    setLength: function setLength(length) {
46962      if (this.isZero()) {
46963        var angle = this._angle || 0;
46964
46965        this._set(Math.cos(angle) * length, Math.sin(angle) * length);
46966      } else {
46967        var scale = length / this.getLength();
46968        if (Numerical.isZero(scale)) this.getAngle();
46969
46970        this._set(this.x * scale, this.y * scale);
46971      }
46972    },
46973    getAngle: function getAngle() {
46974      return this.getAngleInRadians.apply(this, arguments) * 180 / Math.PI;
46975    },
46976    setAngle: function setAngle(angle) {
46977      this.setAngleInRadians.call(this, angle * Math.PI / 180);
46978    },
46979    getAngleInDegrees: '#getAngle',
46980    setAngleInDegrees: '#setAngle',
46981    getAngleInRadians: function getAngleInRadians() {
46982      if (!arguments.length) {
46983        return this.isZero() ? this._angle || 0 : this._angle = Math.atan2(this.y, this.x);
46984      } else {
46985        var point = Point.read(arguments),
46986            div = this.getLength() * point.getLength();
46987
46988        if (Numerical.isZero(div)) {
46989          return NaN;
46990        } else {
46991          var a = this.dot(point) / div;
46992          return Math.acos(a < -1 ? -1 : a > 1 ? 1 : a);
46993        }
46994      }
46995    },
46996    setAngleInRadians: function setAngleInRadians(angle) {
46997      this._angle = angle;
46998
46999      if (!this.isZero()) {
47000        var length = this.getLength();
47001
47002        this._set(Math.cos(angle) * length, Math.sin(angle) * length);
47003      }
47004    },
47005    getQuadrant: function getQuadrant() {
47006      return this.x >= 0 ? this.y >= 0 ? 1 : 4 : this.y >= 0 ? 2 : 3;
47007    }
47008  }, {
47009    beans: false,
47010    getDirectedAngle: function getDirectedAngle() {
47011      var point = Point.read(arguments);
47012      return Math.atan2(this.cross(point), this.dot(point)) * 180 / Math.PI;
47013    },
47014    getDistance: function getDistance() {
47015      var args = arguments,
47016          point = Point.read(args),
47017          x = point.x - this.x,
47018          y = point.y - this.y,
47019          d = x * x + y * y,
47020          squared = Base.read(args);
47021      return squared ? d : Math.sqrt(d);
47022    },
47023    normalize: function normalize(length) {
47024      if (length === undefined) length = 1;
47025      var current = this.getLength(),
47026          scale = current !== 0 ? length / current : 0,
47027          point = new Point(this.x * scale, this.y * scale);
47028      if (scale >= 0) point._angle = this._angle;
47029      return point;
47030    },
47031    rotate: function rotate(angle, center) {
47032      if (angle === 0) return this.clone();
47033      angle = angle * Math.PI / 180;
47034      var point = center ? this.subtract(center) : this,
47035          sin = Math.sin(angle),
47036          cos = Math.cos(angle);
47037      point = new Point(point.x * cos - point.y * sin, point.x * sin + point.y * cos);
47038      return center ? point.add(center) : point;
47039    },
47040    transform: function transform(matrix) {
47041      return matrix ? matrix._transformPoint(this) : this;
47042    },
47043    add: function add() {
47044      var point = Point.read(arguments);
47045      return new Point(this.x + point.x, this.y + point.y);
47046    },
47047    subtract: function subtract() {
47048      var point = Point.read(arguments);
47049      return new Point(this.x - point.x, this.y - point.y);
47050    },
47051    multiply: function multiply() {
47052      var point = Point.read(arguments);
47053      return new Point(this.x * point.x, this.y * point.y);
47054    },
47055    divide: function divide() {
47056      var point = Point.read(arguments);
47057      return new Point(this.x / point.x, this.y / point.y);
47058    },
47059    modulo: function modulo() {
47060      var point = Point.read(arguments);
47061      return new Point(this.x % point.x, this.y % point.y);
47062    },
47063    negate: function negate() {
47064      return new Point(-this.x, -this.y);
47065    },
47066    isInside: function isInside() {
47067      return _Rectangle.read(arguments).contains(this);
47068    },
47069    isClose: function isClose() {
47070      var args = arguments,
47071          point = Point.read(args),
47072          tolerance = Base.read(args);
47073      return this.getDistance(point) <= tolerance;
47074    },
47075    isCollinear: function isCollinear() {
47076      var point = Point.read(arguments);
47077      return Point.isCollinear(this.x, this.y, point.x, point.y);
47078    },
47079    isColinear: '#isCollinear',
47080    isOrthogonal: function isOrthogonal() {
47081      var point = Point.read(arguments);
47082      return Point.isOrthogonal(this.x, this.y, point.x, point.y);
47083    },
47084    isZero: function isZero() {
47085      var isZero = Numerical.isZero;
47086      return isZero(this.x) && isZero(this.y);
47087    },
47088    isNaN: function (_isNaN) {
47089      function isNaN() {
47090        return _isNaN.apply(this, arguments);
47091      }
47092
47093      isNaN.toString = function () {
47094        return _isNaN.toString();
47095      };
47096
47097      return isNaN;
47098    }(function () {
47099      return isNaN(this.x) || isNaN(this.y);
47100    }),
47101    isInQuadrant: function isInQuadrant(q) {
47102      return this.x * (q > 1 && q < 4 ? -1 : 1) >= 0 && this.y * (q > 2 ? -1 : 1) >= 0;
47103    },
47104    dot: function dot() {
47105      var point = Point.read(arguments);
47106      return this.x * point.x + this.y * point.y;
47107    },
47108    cross: function cross() {
47109      var point = Point.read(arguments);
47110      return this.x * point.y - this.y * point.x;
47111    },
47112    project: function project() {
47113      var point = Point.read(arguments),
47114          scale = point.isZero() ? 0 : this.dot(point) / point.dot(point);
47115      return new Point(point.x * scale, point.y * scale);
47116    },
47117    statics: {
47118      min: function min() {
47119        var args = arguments,
47120            point1 = Point.read(args),
47121            point2 = Point.read(args);
47122        return new Point(Math.min(point1.x, point2.x), Math.min(point1.y, point2.y));
47123      },
47124      max: function max() {
47125        var args = arguments,
47126            point1 = Point.read(args),
47127            point2 = Point.read(args);
47128        return new Point(Math.max(point1.x, point2.x), Math.max(point1.y, point2.y));
47129      },
47130      random: function random() {
47131        return new Point(Math.random(), Math.random());
47132      },
47133      isCollinear: function isCollinear(x1, y1, x2, y2) {
47134        return Math.abs(x1 * y2 - y1 * x2) <= Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2)) * 1e-8;
47135      },
47136      isOrthogonal: function isOrthogonal(x1, y1, x2, y2) {
47137        return Math.abs(x1 * x2 + y1 * y2) <= Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2)) * 1e-8;
47138      }
47139    }
47140  }, Base.each(['round', 'ceil', 'floor', 'abs'], function (key) {
47141    var op = Math[key];
47142
47143    this[key] = function () {
47144      return new Point(op(this.x), op(this.y));
47145    };
47146  }, {}));
47147  var LinkedPoint = Point.extend({
47148    initialize: function Point(x, y, owner, setter) {
47149      this._x = x;
47150      this._y = y;
47151      this._owner = owner;
47152      this._setter = setter;
47153    },
47154    _set: function _set(x, y, _dontNotify) {
47155      this._x = x;
47156      this._y = y;
47157      if (!_dontNotify) this._owner[this._setter](this);
47158      return this;
47159    },
47160    getX: function getX() {
47161      return this._x;
47162    },
47163    setX: function setX(x) {
47164      this._x = x;
47165
47166      this._owner[this._setter](this);
47167    },
47168    getY: function getY() {
47169      return this._y;
47170    },
47171    setY: function setY(y) {
47172      this._y = y;
47173
47174      this._owner[this._setter](this);
47175    },
47176    isSelected: function isSelected() {
47177      return !!(this._owner._selection & this._getSelection());
47178    },
47179    setSelected: function setSelected(selected) {
47180      this._owner._changeSelection(this._getSelection(), selected);
47181    },
47182    _getSelection: function _getSelection() {
47183      return this._setter === 'setPosition' ? 4 : 0;
47184    }
47185  });
47186  var Size = Base.extend({
47187    _class: 'Size',
47188    _readIndex: true,
47189    initialize: function Size(arg0, arg1) {
47190      var type = _typeof(arg0),
47191          reading = this.__read,
47192          read = 0;
47193
47194      if (type === 'number') {
47195        var hasHeight = typeof arg1 === 'number';
47196
47197        this._set(arg0, hasHeight ? arg1 : arg0);
47198
47199        if (reading) read = hasHeight ? 2 : 1;
47200      } else if (type === 'undefined' || arg0 === null) {
47201        this._set(0, 0);
47202
47203        if (reading) read = arg0 === null ? 1 : 0;
47204      } else {
47205        var obj = type === 'string' ? arg0.split(/[\s,]+/) || [] : arg0;
47206        read = 1;
47207
47208        if (Array.isArray(obj)) {
47209          this._set(+obj[0], +(obj.length > 1 ? obj[1] : obj[0]));
47210        } else if ('width' in obj) {
47211          this._set(obj.width || 0, obj.height || 0);
47212        } else if ('x' in obj) {
47213          this._set(obj.x || 0, obj.y || 0);
47214        } else {
47215          this._set(0, 0);
47216
47217          read = 0;
47218        }
47219      }
47220
47221      if (reading) this.__read = read;
47222      return this;
47223    },
47224    set: '#initialize',
47225    _set: function _set(width, height) {
47226      this.width = width;
47227      this.height = height;
47228      return this;
47229    },
47230    equals: function equals(size) {
47231      return size === this || size && (this.width === size.width && this.height === size.height || Array.isArray(size) && this.width === size[0] && this.height === size[1]) || false;
47232    },
47233    clone: function clone() {
47234      return new Size(this.width, this.height);
47235    },
47236    toString: function toString() {
47237      var f = Formatter.instance;
47238      return '{ width: ' + f.number(this.width) + ', height: ' + f.number(this.height) + ' }';
47239    },
47240    _serialize: function _serialize(options) {
47241      var f = options.formatter;
47242      return [f.number(this.width), f.number(this.height)];
47243    },
47244    add: function add() {
47245      var size = Size.read(arguments);
47246      return new Size(this.width + size.width, this.height + size.height);
47247    },
47248    subtract: function subtract() {
47249      var size = Size.read(arguments);
47250      return new Size(this.width - size.width, this.height - size.height);
47251    },
47252    multiply: function multiply() {
47253      var size = Size.read(arguments);
47254      return new Size(this.width * size.width, this.height * size.height);
47255    },
47256    divide: function divide() {
47257      var size = Size.read(arguments);
47258      return new Size(this.width / size.width, this.height / size.height);
47259    },
47260    modulo: function modulo() {
47261      var size = Size.read(arguments);
47262      return new Size(this.width % size.width, this.height % size.height);
47263    },
47264    negate: function negate() {
47265      return new Size(-this.width, -this.height);
47266    },
47267    isZero: function isZero() {
47268      var isZero = Numerical.isZero;
47269      return isZero(this.width) && isZero(this.height);
47270    },
47271    isNaN: function (_isNaN2) {
47272      function isNaN() {
47273        return _isNaN2.apply(this, arguments);
47274      }
47275
47276      isNaN.toString = function () {
47277        return _isNaN2.toString();
47278      };
47279
47280      return isNaN;
47281    }(function () {
47282      return isNaN(this.width) || isNaN(this.height);
47283    }),
47284    statics: {
47285      min: function min(size1, size2) {
47286        return new Size(Math.min(size1.width, size2.width), Math.min(size1.height, size2.height));
47287      },
47288      max: function max(size1, size2) {
47289        return new Size(Math.max(size1.width, size2.width), Math.max(size1.height, size2.height));
47290      },
47291      random: function random() {
47292        return new Size(Math.random(), Math.random());
47293      }
47294    }
47295  }, Base.each(['round', 'ceil', 'floor', 'abs'], function (key) {
47296    var op = Math[key];
47297
47298    this[key] = function () {
47299      return new Size(op(this.width), op(this.height));
47300    };
47301  }, {}));
47302  var LinkedSize = Size.extend({
47303    initialize: function Size(width, height, owner, setter) {
47304      this._width = width;
47305      this._height = height;
47306      this._owner = owner;
47307      this._setter = setter;
47308    },
47309    _set: function _set(width, height, _dontNotify) {
47310      this._width = width;
47311      this._height = height;
47312      if (!_dontNotify) this._owner[this._setter](this);
47313      return this;
47314    },
47315    getWidth: function getWidth() {
47316      return this._width;
47317    },
47318    setWidth: function setWidth(width) {
47319      this._width = width;
47320
47321      this._owner[this._setter](this);
47322    },
47323    getHeight: function getHeight() {
47324      return this._height;
47325    },
47326    setHeight: function setHeight(height) {
47327      this._height = height;
47328
47329      this._owner[this._setter](this);
47330    }
47331  });
47332
47333  var _Rectangle = Base.extend({
47334    _class: 'Rectangle',
47335    _readIndex: true,
47336    beans: true,
47337    initialize: function Rectangle(arg0, arg1, arg2, arg3) {
47338      var args = arguments,
47339          type = _typeof(arg0),
47340          read;
47341
47342      if (type === 'number') {
47343        this._set(arg0, arg1, arg2, arg3);
47344
47345        read = 4;
47346      } else if (type === 'undefined' || arg0 === null) {
47347        this._set(0, 0, 0, 0);
47348
47349        read = arg0 === null ? 1 : 0;
47350      } else if (args.length === 1) {
47351        if (Array.isArray(arg0)) {
47352          this._set.apply(this, arg0);
47353
47354          read = 1;
47355        } else if (arg0.x !== undefined || arg0.width !== undefined) {
47356          this._set(arg0.x || 0, arg0.y || 0, arg0.width || 0, arg0.height || 0
vendor: 8,575 bytes, lines 47356-47628
47356);
47357
47358          read = 1;
47359        } else if (arg0.from === undefined && arg0.to === undefined) {
47360          this._set(0, 0, 0, 0);
47361
47362          if (Base.readSupported(args, this)) {
47363            read = 1;
47364          }
47365        }
47366      }
47367
47368      if (read === undefined) {
47369        var frm = Point.readNamed(args, 'from'),
47370            next = Base.peek(args),
47371            x = frm.x,
47372            y = frm.y,
47373            width,
47374            height;
47375
47376        if (next && next.x !== undefined || Base.hasNamed(args, 'to')) {
47377          var to = Point.readNamed(args, 'to');
47378          width = to.x - x;
47379          height = to.y - y;
47380
47381          if (width < 0) {
47382            x = to.x;
47383            width = -width;
47384          }
47385
47386          if (height < 0) {
47387            y = to.y;
47388            height = -height;
47389          }
47390        } else {
47391          var size = Size.read(args);
47392          width = size.width;
47393          height = size.height;
47394        }
47395
47396        this._set(x, y, width, height);
47397
47398        read = args.__index;
47399      }
47400
47401      var filtered = args.__filtered;
47402      if (filtered) this.__filtered = filtered;
47403      if (this.__read) this.__read = read;
47404      return this;
47405    },
47406    set: '#initialize',
47407    _set: function _set(x, y, width, height) {
47408      this.x = x;
47409      this.y = y;
47410      this.width = width;
47411      this.height = height;
47412      return this;
47413    },
47414    clone: function clone() {
47415      return new _Rectangle(this.x, this.y, this.width, this.height);
47416    },
47417    equals: function equals(rect) {
47418      var rt = Base.isPlainValue(rect) ? _Rectangle.read(arguments) : rect;
47419      return rt === this || rt && this.x === rt.x && this.y === rt.y && this.width === rt.width && this.height === rt.height || false;
47420    },
47421    toString: function toString() {
47422      var f = Formatter.instance;
47423      return '{ x: ' + f.number(this.x) + ', y: ' + f.number(this.y) + ', width: ' + f.number(this.width) + ', height: ' + f.number(this.height) + ' }';
47424    },
47425    _serialize: function _serialize(options) {
47426      var f = options.formatter;
47427      return [f.number(this.x), f.number(this.y), f.number(this.width), f.number(this.height)];
47428    },
47429    getPoint: function getPoint(_dontLink) {
47430      var ctor = _dontLink ? Point : LinkedPoint;
47431      return new ctor(this.x, this.y, this, 'setPoint');
47432    },
47433    setPoint: function setPoint() {
47434      var point = Point.read(arguments);
47435      this.x = point.x;
47436      this.y = point.y;
47437    },
47438    getSize: function getSize(_dontLink) {
47439      var ctor = _dontLink ? Size : LinkedSize;
47440      return new ctor(this.width, this.height, this, 'setSize');
47441    },
47442    _fw: 1,
47443    _fh: 1,
47444    setSize: function setSize() {
47445      var size = Size.read(arguments),
47446          sx = this._sx,
47447          sy = this._sy,
47448          w = size.width,
47449          h = size.height;
47450
47451      if (sx) {
47452        this.x += (this.width - w) * sx;
47453      }
47454
47455      if (sy) {
47456        this.y += (this.height - h) * sy;
47457      }
47458
47459      this.width = w;
47460      this.height = h;
47461      this._fw = this._fh = 1;
47462    },
47463    getLeft: function getLeft() {
47464      return this.x;
47465    },
47466    setLeft: function setLeft(left) {
47467      if (!this._fw) {
47468        var amount = left - this.x;
47469        this.width -= this._sx === 0.5 ? amount * 2 : amount;
47470      }
47471
47472      this.x = left;
47473      this._sx = this._fw = 0;
47474    },
47475    getTop: function getTop() {
47476      return this.y;
47477    },
47478    setTop: function setTop(top) {
47479      if (!this._fh) {
47480        var amount = top - this.y;
47481        this.height -= this._sy === 0.5 ? amount * 2 : amount;
47482      }
47483
47484      this.y = top;
47485      this._sy = this._fh = 0;
47486    },
47487    getRight: function getRight() {
47488      return this.x + this.width;
47489    },
47490    setRight: function setRight(right) {
47491      if (!this._fw) {
47492        var amount = right - this.x;
47493        this.width = this._sx === 0.5 ? amount * 2 : amount;
47494      }
47495
47496      this.x = right - this.width;
47497      this._sx = 1;
47498      this._fw = 0;
47499    },
47500    getBottom: function getBottom() {
47501      return this.y + this.height;
47502    },
47503    setBottom: function setBottom(bottom) {
47504      if (!this._fh) {
47505        var amount = bottom - this.y;
47506        this.height = this._sy === 0.5 ? amount * 2 : amount;
47507      }
47508
47509      this.y = bottom - this.height;
47510      this._sy = 1;
47511      this._fh = 0;
47512    },
47513    getCenterX: function getCenterX() {
47514      return this.x + this.width / 2;
47515    },
47516    setCenterX: function setCenterX(x) {
47517      if (this._fw || this._sx === 0.5) {
47518        this.x = x - this.width / 2;
47519      } else {
47520        if (this._sx) {
47521          this.x += (x - this.x) * 2 * this._sx;
47522        }
47523
47524        this.width = (x - this.x) * 2;
47525      }
47526
47527      this._sx = 0.5;
47528      this._fw = 0;
47529    },
47530    getCenterY: function getCenterY() {
47531      return this.y + this.height / 2;
47532    },
47533    setCenterY: function setCenterY(y) {
47534      if (this._fh || this._sy === 0.5) {
47535        this.y = y - this.height / 2;
47536      } else {
47537        if (this._sy) {
47538          this.y += (y - this.y) * 2 * this._sy;
47539        }
47540
47541        this.height = (y - this.y) * 2;
47542      }
47543
47544      this._sy = 0.5;
47545      this._fh = 0;
47546    },
47547    getCenter: function getCenter(_dontLink) {
47548      var ctor = _dontLink ? Point : LinkedPoint;
47549      return new ctor(this.getCenterX(), this.getCenterY(), this, 'setCenter');
47550    },
47551    setCenter: function setCenter() {
47552      var point = Point.read(arguments);
47553      this.setCenterX(point.x);
47554      this.setCenterY(point.y);
47555      return this;
47556    },
47557    getArea: function getArea() {
47558      return this.width * this.height;
47559    },
47560    isEmpty: function isEmpty() {
47561      return this.width === 0 || this.height === 0;
47562    },
47563    contains: function contains(arg) {
47564      return arg && arg.width !== undefined || (Array.isArray(arg) ? arg : arguments).length === 4 ? this._containsRectangle(_Rectangle.read(arguments)) : this._containsPoint(Point.read(arguments));
47565    },
47566    _containsPoint: function _containsPoint(point) {
47567      var x = point.x,
47568          y = point.y;
47569      return x >= this.x && y >= this.y && x <= this.x + this.width && y <= this.y + this.height;
47570    },
47571    _containsRectangle: function _containsRectangle(rect) {
47572      var x = rect.x,
47573          y = rect.y;
47574      return x >= this.x && y >= this.y && x + rect.width <= this.x + this.width && y + rect.height <= this.y + this.height;
47575    },
47576    intersects: function intersects() {
47577      var rect = _Rectangle.read(arguments),
47578          epsilon = Base.read(arguments) || 0;
47579
47580      return rect.x + rect.width > this.x - epsilon && rect.y + rect.height > this.y - epsilon && rect.x < this.x + this.width + epsilon && rect.y < this.y + this.height + epsilon;
47581    },
47582    intersect: function intersect() {
47583      var rect = _Rectangle.read(arguments),
47584          x1 = Math.max(this.x, rect.x),
47585          y1 = Math.max(this.y, rect.y),
47586          x2 = Math.min(this.x + this.width, rect.x + rect.width),
47587          y2 = Math.min(this.y + this.height, rect.y + rect.height);
47588
47589      return new _Rectangle(x1, y1, x2 - x1, y2 - y1);
47590    },
47591    unite: function unite() {
47592      var rect = _Rectangle.read(arguments),
47593          x1 = Math.min(this.x, rect.x),
47594          y1 = Math.min(this.y, rect.y),
47595          x2 = Math.max(this.x + this.width, rect.x + rect.width),
47596          y2 = Math.max(this.y + this.height, rect.y + rect.height);
47597
47598      return new _Rectangle(x1, y1, x2 - x1, y2 - y1);
47599    },
47600    include: function include() {
47601      var point = Point.read(arguments);
47602      var x1 = Math.min(this.x, point.x),
47603          y1 = Math.min(this.y, point.y),
47604          x2 = Math.max(this.x + this.width, point.x),
47605          y2 = Math.max(this.y + this.height, point.y);
47606      return new _Rectangle(x1, y1, x2 - x1, y2 - y1);
47607    },
47608    expand: function expand() {
47609      var amount = Size.read(arguments),
47610          hor = amount.width,
47611          ver = amount.height;
47612      return new _Rectangle(this.x - hor / 2, this.y - ver / 2, this.width + hor, this.height + ver);
47613    },
47614    scale: function scale(hor, ver) {
47615      return this.expand(this.width * hor - this.width, this.height * (ver === undefined ? hor : ver) - this.height);
47616    }
47617  }, Base.each([['Top', 'Left'], ['Top', 'Right'], ['Bottom', 'Left'], ['Bottom', 'Right'], ['Left', 'Center'], ['Top', 'Center'], ['Right', 'Center'], ['Bottom', 'Center']], function (parts, index) {
47618    var part = parts.join(''),
47619        xFirst = /^[RL]/.test(part);
47620    if (index >= 4) parts[1] += xFirst ? 'Y' : 'X';
47621    var x = parts[xFirst ? 0 : 1],
47622        y = parts[xFirst ? 1 : 0],
47623        getX = 'get' + x,
47624        getY = 'get' + y,
47625        setX = 'set' + x,
47626        setY = 'set' + y,
47627        get = 'get' + part,
47628        set = 'set' + part;
47629
47630    this[get] = function (_dontLink) {
47631      var ctor = _dontLink ? Point : LinkedPoint;
47632      return new ctor(this[getX](), this[getY](), this, set);
47633    };
47634
47635    this[set] = function () {
47636      var point = Point.read(arguments);
47637      this[setX](point.x);
47638      this[setY](point.y);
47639    };
47640  }, {
47641    beans: true
47642  }));
47643
47644  var LinkedRectangle = _Rectangle.extend({
47645    initialize: function Rectangle(x, y, width, height, owner, setter) {
47646      this._set(x, y, width, height, true);
47647
47648      this._owner = owner;
47649      this._setter = setter;
47650    },
47651    _set: function _set(x, y, width, height, _dontNotify) {
47652      this._x = x;
47653      this._y = y;
47654      this._width = width;
47655      this._height = height;
47656      if (!_dontNotify) this._owner[this._setter](this);
47657      return this;
47658    }
47659  }, new function () {
47660    var proto = _Rectangle.prototype;
47661    return Base.each(['x', 'y', 'width', 'height'], function (key) {
47662      var part = Base.capitalize(key),
47663          internal = '_' + key;
47664
47665      this['get' + part] = function () {
47666        return this[internal];
47667      };
47668
47669      this['set' + part] = function (value) {
47670        this[internal] = value;
47671        if (!this._dontNotify) this._owner[this._setter](this);
47672      };
47673    }, Base.each(['Point', 'Size', 'Center', 'Left', 'Top', 'Right', 'Bottom', 'CenterX', 'CenterY', 'TopLeft', 'TopRight', 'BottomLeft', 'BottomRight', 'LeftCenter', 'TopCenter', 'RightCenter', 'BottomCenter'], function (key) {
47674      var name = 'set' + key;
47675
47676      this[name] = function () {
47677        this._dontNotify = true;
47678        proto[name].apply(this, arguments);
47679        this._dontNotify = false;
47680
47681        this._owner[this._setter](this);
47682      };
47683    }, {
47684      isSelected: function isSelected() {
47685        return !!(this._owner._selection & 2);
47686      },
47687      setSelected: function setSelected(selected) {
47688        var owner = this._owner;
47689
47690        if (owner._changeSelection) {
47691          owner._changeSelection(2, selected);
47692        }
47693      }
47694    }));
47695  }());
47696
47697  var Matrix = Base.extend({
47698    _class: 'Matrix',
47699    initialize: function Matrix(arg, _dontNotify) {
47700      var args = arguments,
47701          count = args.length,
47702          ok = true;
47703
47704      if (count >= 6) {
47705        this._set.apply(this, args);
47706      } else if (count === 1 || count === 2) {
47707        if (arg instanceof Matrix) {
47708          this._set(arg._a, arg._b, arg._c, arg._d, arg._tx, arg._ty, _dontNotify);
47709        } else if (Array.isArray(arg)) {
47710          this._set.apply(this, _dontNotify ? arg.concat([_dontNotify]) : arg);
47711        } else {
47712          ok = false;
47713        }
47714      } else if (!count) {
47715        this.reset();
47716      } else {
47717        ok = false;
47718      }
47719
47720      if (!ok) {
47721        throw new Error('Unsupported matrix parameters');
47722      }
47723
47724      return this;
47725    },
47726    set: '#initialize',
47727    _set: function _set(a, b, c, d, tx, ty, _dontNotify) {
47728      this._a = a;
47729      this._b = b;
47730      this._c = c;
47731      this._d = d;
47732      this._tx = tx;
47733      this._ty = ty;
47734      if (!_dontNotify) this._changed();
47735      return this;
47736    },
47737    _serialize: function _serialize(options, dictionary) {
47738      return Base.serialize(this.getValues(), options, true, dictionary);
47739    },
47740    _changed: function _changed() {
47741      var owner = this._owner;
47742
47743      if (owner) {
47744        if (owner._applyMatrix) {
47745          owner.transform(null, true);
47746        } else {
47747          owner._changed(25);
47748        }
47749      }
47750    },
47751    clone: function clone() {
47752      return new Matrix(this._a, this._b, this._c, this._d, this._tx, this._ty);
47753    },
47754    equals: function equals(mx) {
47755      return mx === this || mx && this._a === mx._a && this._b === mx._b && this._c === mx._c && this._d === mx._d && this._tx === mx._tx && this._ty === mx._ty;
47756    },
47757    toString: function toString() {
47758      var f = Formatter.instance;
47759      return '[[' + [f.number(this._a), f.number(this._c), f.number(this._tx)].join(', ') + '], [' + [f.number(this._b), f.number(this._d), f.number(this._ty)].join(', ') + ']]';
47760    },
47761    reset: function reset(_dontNotify) {
47762      this._a = this._d = 1;
47763      this._b = this._c = this._tx = this._ty = 0;
47764      if (!_dontNotify) this._changed();
47765      return this;
47766    },
47767    apply: function apply(recursively, _setApplyMatrix) {
47768      var owner = this._owner;
47769
47770      if (owner) {
47771        owner.transform(null, Base.pick(recursively, true), _setApplyMatrix);
47772        return this.isIdentity();
47773      }
47774
47775      return false;
vendor: 9,355 bytes, lines 47776-48093
47776    },
47777    translate: function translate() {
47778      var point = Point.read(arguments),
47779          x = point.x,
47780          y = point.y;
47781      this._tx += x * this._a + y * this._c;
47782      this._ty += x * this._b + y * this._d;
47783
47784      this._changed();
47785
47786      return this;
47787    },
47788    scale: function scale() {
47789      var args = arguments,
47790          scale = Point.read(args),
47791          center = Point.read(args, 0, {
47792        readNull: true
47793      });
47794      if (center) this.translate(center);
47795      this._a *= scale.x;
47796      this._b *= scale.x;
47797      this._c *= scale.y;
47798      this._d *= scale.y;
47799      if (center) this.translate(center.negate());
47800
47801      this._changed();
47802
47803      return this;
47804    },
47805    rotate: function rotate(angle) {
47806      angle *= Math.PI / 180;
47807      var center = Point.read(arguments, 1),
47808          x = center.x,
47809          y = center.y,
47810          cos = Math.cos(angle),
47811          sin = Math.sin(angle),
47812          tx = x - x * cos + y * sin,
47813          ty = y - x * sin - y * cos,
47814          a = this._a,
47815          b = this._b,
47816          c = this._c,
47817          d = this._d;
47818      this._a = cos * a + sin * c;
47819      this._b = cos * b + sin * d;
47820      this._c = -sin * a + cos * c;
47821      this._d = -sin * b + cos * d;
47822      this._tx += tx * a + ty * c;
47823      this._ty += tx * b + ty * d;
47824
47825      this._changed();
47826
47827      return this;
47828    },
47829    shear: function shear() {
47830      var args = arguments,
47831          shear = Point.read(args),
47832          center = Point.read(args, 0, {
47833        readNull: true
47834      });
47835      if (center) this.translate(center);
47836      var a = this._a,
47837          b = this._b;
47838      this._a += shear.y * this._c;
47839      this._b += shear.y * this._d;
47840      this._c += shear.x * a;
47841      this._d += shear.x * b;
47842      if (center) this.translate(center.negate());
47843
47844      this._changed();
47845
47846      return this;
47847    },
47848    skew: function skew() {
47849      var args = arguments,
47850          skew = Point.read(args),
47851          center = Point.read(args, 0, {
47852        readNull: true
47853      }),
47854          toRadians = Math.PI / 180,
47855          shear = new Point(Math.tan(skew.x * toRadians), Math.tan(skew.y * toRadians));
47856      return this.shear(shear, center);
47857    },
47858    append: function append(mx, _dontNotify) {
47859      if (mx) {
47860        var a1 = this._a,
47861            b1 = this._b,
47862            c1 = this._c,
47863            d1 = this._d,
47864            a2 = mx._a,
47865            b2 = mx._c,
47866            c2 = mx._b,
47867            d2 = mx._d,
47868            tx2 = mx._tx,
47869            ty2 = mx._ty;
47870        this._a = a2 * a1 + c2 * c1;
47871        this._c = b2 * a1 + d2 * c1;
47872        this._b = a2 * b1 + c2 * d1;
47873        this._d = b2 * b1 + d2 * d1;
47874        this._tx += tx2 * a1 + ty2 * c1;
47875        this._ty += tx2 * b1 + ty2 * d1;
47876        if (!_dontNotify) this._changed();
47877      }
47878
47879      return this;
47880    },
47881    prepend: function prepend(mx, _dontNotify) {
47882      if (mx) {
47883        var a1 = this._a,
47884            b1 = this._b,
47885            c1 = this._c,
47886            d1 = this._d,
47887            tx1 = this._tx,
47888            ty1 = this._ty,
47889            a2 = mx._a,
47890            b2 = mx._c,
47891            c2 = mx._b,
47892            d2 = mx._d,
47893            tx2 = mx._tx,
47894            ty2 = mx._ty;
47895        this._a = a2 * a1 + b2 * b1;
47896        this._c = a2 * c1 + b2 * d1;
47897        this._b = c2 * a1 + d2 * b1;
47898        this._d = c2 * c1 + d2 * d1;
47899        this._tx = a2 * tx1 + b2 * ty1 + tx2;
47900        this._ty = c2 * tx1 + d2 * ty1 + ty2;
47901        if (!_dontNotify) this._changed();
47902      }
47903
47904      return this;
47905    },
47906    appended: function appended(mx) {
47907      return this.clone().append(mx);
47908    },
47909    prepended: function prepended(mx) {
47910      return this.clone().prepend(mx);
47911    },
47912    invert: function invert() {
47913      var a = this._a,
47914          b = this._b,
47915          c = this._c,
47916          d = this._d,
47917          tx = this._tx,
47918          ty = this._ty,
47919          det = a * d - b * c,
47920          res = null;
47921
47922      if (det && !isNaN(det) && isFinite(tx) && isFinite(ty)) {
47923        this._a = d / det;
47924        this._b = -b / det;
47925        this._c = -c / det;
47926        this._d = a / det;
47927        this._tx = (c * ty - d * tx) / det;
47928        this._ty = (b * tx - a * ty) / det;
47929        res = this;
47930      }
47931
47932      return res;
47933    },
47934    inverted: function inverted() {
47935      return this.clone().invert();
47936    },
47937    concatenate: '#append',
47938    preConcatenate: '#prepend',
47939    chain: '#appended',
47940    _shiftless: function _shiftless() {
47941      return new Matrix(this._a, this._b, this._c, this._d, 0, 0);
47942    },
47943    _orNullIfIdentity: function _orNullIfIdentity() {
47944      return this.isIdentity() ? null : this;
47945    },
47946    isIdentity: function isIdentity() {
47947      return this._a === 1 && this._b === 0 && this._c === 0 && this._d === 1 && this._tx === 0 && this._ty === 0;
47948    },
47949    isInvertible: function isInvertible() {
47950      var det = this._a * this._d - this._c * this._b;
47951      return det && !isNaN(det) && isFinite(this._tx) && isFinite(this._ty);
47952    },
47953    isSingular: function isSingular() {
47954      return !this.isInvertible();
47955    },
47956    transform: function transform(src, dst, count) {
47957      return arguments.length < 3 ? this._transformPoint(Point.read(arguments)) : this._transformCoordinates(src, dst, count);
47958    },
47959    _transformPoint: function _transformPoint(point, dest, _dontNotify) {
47960      var x = point.x,
47961          y = point.y;
47962      if (!dest) dest = new Point();
47963      return dest._set(x * this._a + y * this._c + this._tx, x * this._b + y * this._d + this._ty, _dontNotify);
47964    },
47965    _transformCoordinates: function _transformCoordinates(src, dst, count) {
47966      for (var i = 0, max = 2 * count; i < max; i += 2) {
47967        var x = src[i],
47968            y = src[i + 1];
47969        dst[i] = x * this._a + y * this._c + this._tx;
47970        dst[i + 1] = x * this._b + y * this._d + this._ty;
47971      }
47972
47973      return dst;
47974    },
47975    _transformCorners: function _transformCorners(rect) {
47976      var x1 = rect.x,
47977          y1 = rect.y,
47978          x2 = x1 + rect.width,
47979          y2 = y1 + rect.height,
47980          coords = [x1, y1, x2, y1, x2, y2, x1, y2];
47981      return this._transformCoordinates(coords, coords, 4);
47982    },
47983    _transformBounds: function _transformBounds(bounds, dest, _dontNotify) {
47984      var coords = this._transformCorners(bounds),
47985          min = coords.slice(0, 2),
47986          max = min.slice();
47987
47988      for (var i = 2; i < 8; i++) {
47989        var val = coords[i],
47990            j = i & 1;
47991
47992        if (val < min[j]) {
47993          min[j] = val;
47994        } else if (val > max[j]) {
47995          max[j] = val;
47996        }
47997      }
47998
47999      if (!dest) dest = new _Rectangle();
48000      return dest._set(min[0], min[1], max[0] - min[0], max[1] - min[1], _dontNotify);
48001    },
48002    inverseTransform: function inverseTransform() {
48003      return this._inverseTransform(Point.read(arguments));
48004    },
48005    _inverseTransform: function _inverseTransform(point, dest, _dontNotify) {
48006      var a = this._a,
48007          b = this._b,
48008          c = this._c,
48009          d = this._d,
48010          tx = this._tx,
48011          ty = this._ty,
48012          det = a * d - b * c,
48013          res = null;
48014
48015      if (det && !isNaN(det) && isFinite(tx) && isFinite(ty)) {
48016        var x = point.x - this._tx,
48017            y = point.y - this._ty;
48018        if (!dest) dest = new Point();
48019        res = dest._set((x * d - y * c) / det, (y * a - x * b) / det, _dontNotify);
48020      }
48021
48022      return res;
48023    },
48024    decompose: function decompose() {
48025      var a = this._a,
48026          b = this._b,
48027          c = this._c,
48028          d = this._d,
48029          det = a * d - b * c,
48030          sqrt = Math.sqrt,
48031          atan2 = Math.atan2,
48032          degrees = 180 / Math.PI,
48033          rotate,
48034          scale,
48035          skew;
48036
48037      if (a !== 0 || b !== 0) {
48038        var r = sqrt(a * a + b * b);
48039        rotate = Math.acos(a / r) * (b > 0 ? 1 : -1);
48040        scale = [r, det / r];
48041        skew = [atan2(a * c + b * d, r * r), 0];
48042      } else if (c !== 0 || d !== 0) {
48043        var s = sqrt(c * c + d * d);
48044        rotate = Math.asin(c / s) * (d > 0 ? 1 : -1);
48045        scale = [det / s, s];
48046        skew = [0, atan2(a * c + b * d, s * s)];
48047      } else {
48048        rotate = 0;
48049        skew = scale = [0, 0];
48050      }
48051
48052      return {
48053        translation: this.getTranslation(),
48054        rotation: rotate * degrees,
48055        scaling: new Point(scale),
48056        skewing: new Point(skew[0] * degrees, skew[1] * degrees)
48057      };
48058    },
48059    getValues: function getValues() {
48060      return [this._a, this._b, this._c, this._d, this._tx, this._ty];
48061    },
48062    getTranslation: function getTranslation() {
48063      return new Point(this._tx, this._ty);
48064    },
48065    getScaling: function getScaling() {
48066      return this.decompose().scaling;
48067    },
48068    getRotation: function getRotation() {
48069      return this.decompose().rotation;
48070    },
48071    applyToContext: function applyToContext(ctx) {
48072      if (!this.isIdentity()) {
48073        ctx.transform(this._a, this._b, this._c, this._d, this._tx, this._ty);
48074      }
48075    }
48076  }, Base.each(['a', 'b', 'c', 'd', 'tx', 'ty'], function (key) {
48077    var part = Base.capitalize(key),
48078        prop = '_' + key;
48079
48080    this['get' + part] = function () {
48081      return this[prop];
48082    };
48083
48084    this['set' + part] = function (value) {
48085      this[prop] = value;
48086
48087      this._changed();
48088    };
48089  }, {}));
48090  var Line = Base.extend({
48091    _class: 'Line',
48092    initialize: function Line(arg0, arg1, arg2, arg3, arg4) {
48093      var asVector = false;
48094
48095      if (arguments.length >= 4) {
48096        this._px = arg0;
48097        this._py = arg1;
48098        this._vx = arg2;
48099        this._vy = arg3;
48100        asVector = arg4;
48101      } else {
48102        this._px = arg0.x;
48103        this._py = arg0.y;
48104        this._vx = arg1.x;
48105        this._vy = arg1.y;
48106        asVector = arg2;
48107      }
48108
48109      if (!asVector) {
48110        this._vx -= this._px;
48111        this._vy -= this._py;
48112      }
48113    },
48114    getPoint: function getPoint() {
48115      return new Point(this._px, this._py);
48116    },
48117    getVector: function getVector() {
48118      return new Point(this._vx, this._vy);
48119    },
48120    getLength: function getLength() {
48121      return this.getVector().getLength();
48122    },
48123    intersect: function intersect(line, isInfinite) {
48124      return Line.intersect(this._px, this._py, this._vx, this._vy, line._px, line._py, line._vx, line._vy, true, isInfinite);
48125    },
48126    getSide: function getSide(point, isInfinite) {
48127      return Line.getSide(this._px, this._py, this._vx, this._vy, point.x, point.y, true, isInfinite);
48128    },
48129    getDistance: function getDistance(point) {
48130      return Math.abs(this.getSignedDistance(point));
48131    },
48132    getSignedDistance: function getSignedDistance(point) {
48133      return Line.getSignedDistance(this._px, this._py, this._vx, this._vy, point.x, point.y, true);
48134    },
48135    isCollinear: function isCollinear(line) {
48136      return Point.isCollinear(this._vx, this._vy, line._vx, line._vy);
48137    },
48138    isOrthogonal: function isOrthogonal(line) {
48139      return Point.isOrthogonal(this._vx, this._vy, line._vx, line._vy);
48140    },
48141    statics: {
48142      intersect: function intersect(p1x, p1y, v1x, v1y, p2x, p2y, v2x, v2y, asVector, isInfinite) {
48143        if (!asVector) {
48144          v1x -= p1x;
48145          v1y -= p1y;
48146          v2x -= p2x;
48147          v2y -= p2y;
48148        }
48149
48150        var cross = v1x * v2y - v1y * v2x;
48151
48152        if (!Numerical.isMachineZero(cross)) {
48153          var dx = p1x - p2x,
48154              dy = p1y - p2y,
48155              u1 = (v2x * dy - v2y * dx) / cross,
48156              u2 = (v1x * dy - v1y * dx) / cross,
48157              epsilon = 1e-12,
48158              uMin = -epsilon,
48159              uMax = 1 + epsilon;
48160
48161          if (isInfinite || uMin < u1 && u1 < uMax && uMin < u2 && u2 < uMax) {
48162            if (!isInfinite) {
48163              u1 = u1 <= 0 ? 0 : u1 >= 1 ? 1 : u1;
48164            }
48165
48166            return new Point(p1x + u1 * v1x, p1y + u1 * v1y);
48167          }
48168        }
48169      },
48170      getSide: function getSide(px, py, vx, vy, x, y, asVector, isInfinite) {
48171        if (!asVector) {
48172          vx -= px;
48173          vy -= py;
48174        }
48175
48176        var v2x = x - px,
48177            v2y = y - py,
48178            ccw = v2x * vy - v2y * vx;
48179
48180        if (!isInfinite && Numerical.isMachineZero(ccw)) {
48181          ccw = (v2x * vx + v2x * vx) / (vx * vx + vy * vy);
48182          if (ccw >= 0 && ccw <= 1) ccw = 0;
48183        }
48184
48185        return ccw < 0 ? -1 : ccw > 0 ? 1 : 0;
48186      },
48187      getSignedDistance: function getSignedDistance(px, py, vx, vy, x, y, asVector) {
48188        if (!asVector) {
48189          vx -= px;
48190          vy -= py;
48191        }
48192
48193        return vx === 0 ? vy > 0 ? x - px : px - x : vy === 0 ? vx < 0 ? y - py : py - y : ((x - px) * vy - (y - py) * vx) / (vy > vx ? vy * Math.sqrt(1 + vx * vx / (vy * vy)) : vx * Math.sqrt(1 + vy * vy / (vx * vx)));
48194      },
48195      getDistance: function getDistance(px, py, vx, vy, x, y, asVector) {
48196        return Math.abs(Line.getSignedDistance(px, py, vx, vy, x, y, asVector));
48197      }
48198    }
48199  });
48200  var Project = PaperScopeItem.extend({
48201    _class: 'Project',
48202    _list: 'projects',
48203    _reference: 'project',
48204    _compactSerialize: true,
48205    initialize: function Project(element) {
48206      PaperScopeItem.call(this, true);
48207      this._children = [];
48208      this._namedChildren = {};
48209      this._activeLayer = null;
48210      this._currentStyle = new Style(null, null, this);
48211      this._view = View.create(this, element || CanvasProvider.getCanvas(1, 1));
48212      this._selectionItems = {};
48213      this._selectionCount = 0;
48214      this._updateVersion = 0;
48215    },
48216    _serialize: function _serialize(options, dictionary) {
48217      return Base.serialize(this._children, options, true, dictionary);
48218    },
48219    _changed: function _changed(flags, item) {
48220      if (flags & 1) {
48221        var view = this._view;
48222
48223        if (view) {
48224          view._needsUpdate = true;
48225          if (!view._requested && view._autoUpdate) view.requestUpdate();
48226        }
48227      }
48228
48229      var changes = this._changes;
48230
48231      if (changes && item) {
48232        var changesById = this._changesById,
48233            id = item._id,
48234            entry = changesById[id];
48235
48236        if (entry) {
48237          entry.flags |= flags;
48238        } else {
48239          changes.push(changesById[id] = {
48240            item: item,
48241            flags: flags
48242          });
48243        }
48244      }
48245    },
48246    clear: function clear() {
48247      var children = this._children;
48248
48249      for (var i = children.length - 1; i >= 0; i--) {
48250        children[i].remove();
48251      }
48252    },
48253    isEmpty: function isEmpty() {
48254      return !this._children.length;
48255    },
48256    remove: function remove() {
48257      if (!remove.base.call(this)) return false;
48258      if (this._view) this._view.remove();
48259      return true;
48260    },
48261    getView: function getView() {
48262      return this._view;
48263    },
48264    getCurrentStyle: function getCurrentStyle() {
48265      return this._currentStyle;
48266    },
48267    setCurrentStyle: function setCurrentStyle(style) {
48268      this._currentStyle.set(style);
48269    },
48270    getIndex: function getIndex() {
48271      return this._index;
48272    },
48273    getOptions: function getOptions() {
48274      return this._scope.settings;
48275    },
48276    getLayers: function getLayers() {
48277      return this._children;
48278    },
48279    getActiveLayer: function getActiveLayer() {
48280      return this._activeLayer || new Layer({
48281        project: this,
48282        insert: true
48283      });
48284    },
48285    getSymbolDefinitions: function getSymbolDefinitions() {
48286      var definitions = [],
48287          ids = {};
48288      this.getItems({
48289        class: SymbolItem,
48290        match: function match(item) {
48291          var definition = item._definition,
48292              id = definition._id;
48293
48294          if (!ids[id]) {
48295            ids[id] = true;
48296            definitions.push(definition);
48297          }
48298
48299          return false;
48300        }
48301      });
48302      return definitions;
48303    },
48304    getSymbols: 'getSymbolDefinitions',
48305    getSelectedItems: function getSelectedItems() {
48306      var selectionItems = this._selectionItems,
48307          items = [];
48308
48309      for (var id in selectionItems) {
48310        var item = selectionItems[id],
48311            selection = item._selection;
48312
48313        if (selection & 1 && item.isInserted()) {
48314          items.push(item);
48315        } else if (!selection) {
48316          this._updateSelection(item);
48317        }
48318      }
48319
48320      return items;
48321    },
48322    _updateSelection: function _updateSelection(item) {
48323      var id = item._id,
48324          selectionItems = this._selectionItems;
48325
48326      if (item._selection) {
48327        if (selectionItems[id] !== item) {
48328          this._selectionCount++;
48329          selectionItems[id] = item;
48330        }
48331      } else if (selectionItems[id] === item) {
48332        this._selectionCount--;
48333        delete selectionItems[id];
48334      }
48335    },
48336    selectAll: function selectAll() {
48337      var children = this._children;
48338
48339      for (var i = 0, l = children.length; i < l; i++) {
48340        children[i].setFullySelected(true);
48341      }
48342    },
48343    deselectAll: function deselectAll() {
48344      var selectionItems = this._selectionItems;
48345
48346      for (var i in selectionItems) {
48347        selectionItems[i].setFullySelected(false);
48348      }
48349    },
48350    addLayer: function addLayer(layer) {
48351      return this.insertLayer(undefined, layer);
48352    },
48353    insertLayer: function insertLayer(index, layer) {
48354      if (layer instanceof Layer) {
48355        layer._remove(false, true);
48356
48357        Base.splice(this._children, [layer], index, 0);
48358
48359        layer._setProject(this, true);
48360
48361        var name = layer._name;
48362        if (name) layer.setName(name);
48363        if (this._changes) layer._changed(5);
48364        if (!this._activeLayer) this._activeLayer = layer;
48365      } else {
48366        layer = null;
48367      }
48368
48369      return layer;
48370    },
48371    _insertItem: function _insertItem(index, item, _created) {
48372      item = this.insertLayer(index, item) || (this._activeLayer || this._insertItem(undefined, new Layer(Item.NO_INSERT), true)).insertChild(index, item);
48373      if (_created && item.activate) item.activate();
48374      return item;
48375    },
48376    getItems: function getItems(options) {
48377      return Item._getItems(this, options);
48378    },
48379    getItem: function getItem(options) {
48380      return Item._getItems(this, options, null, null, true)[0] || null;
48381    },
48382    importJSON: function importJSON(json) {
48383      this.activate();
48384      var layer = this._activeLayer;
48385      return Base.importJSON(json, layer && layer.isEmpty() && layer);
48386    },
48387    removeOn: function removeOn(type) {
48388      var sets = this._removeSets;
48389
48390      if (sets) {
48391        if (type === 'mouseup') sets.mousedrag = null;
48392        var set = sets[type];
48393
48394        if (set) {
48395          for (var id in set) {
48396            var item = set[id];
48397
48398            for (var key in sets) {
48399              var other = sets[key];
48400              if (other && other != set) delete other[item._id];
48401            }
48402
48403            item.remove();
48404          }
48405
48406          sets[type] = null;
48407        }
48408      }
48409    },
48410    draw: function draw(ctx, matrix, pixelRatio) {
48411      this._updateVersion++;
48412      ctx.save();
48413      matrix.applyToContext(ctx);
48414      var children = this._children,
48415          param = new Base({
48416        offset: new Point(0, 0),
48417        pixelRatio: pixelRatio,
48418        viewMatrix: matrix.isIdentity() ? null : matrix,
48419        matrices: [new Matrix()],
48420        updateMatrix: true
48421      });
48422
48423      for (var i = 0, l = children.length; i < l; i++) {
48424        children[i].draw(ctx, param);
48425      }
48426
48427      ctx.restore();
48428
48429      if (this._selectionCount > 0) {
48430        ctx.save();
48431        ctx.strokeWidth = 1;
48432        var items = this._selectionItems,
48433            size = this._scope.settings.handleSize,
48434            version = this._updateVersion;
48435
48436        for (var id in items) {
48437          items[id]._drawSelection(ctx, matrix, size, items, version);
48438        }
48439
48440        ctx.restore();
48441      }
48442    }
48443  });
48444  var Item = Base.extend(Emitter, {
48445    statics: {
48446      extend: function extend(src) {
48447        if (src._serializeFields) src._serializeFields = Base.set({}, this.prototype._serializeFields, src._serializeFields);
48448        return extend.base.apply(this, arguments);
48449      },
48450      NO_INSERT: {
48451        insert: false
48452      }
48453    },
48454    _class: 'Item',
48455    _name: null,
48456    _applyMatrix: true,
48457    _canApplyMatrix: true,
48458    _canScaleStroke: false,
48459    _pivot: null,
48460    _visible: true,
48461    _blendMode: 'normal',
48462    _opacity: 1,
48463    _locked: false,
48464    _guide: false,
48465    _clipMask: false,
48466    _selection: 0,
48467    _selectBounds: true,
48468    _selectChildren: false,
48469    _serializeFields: {
48470      name: null,
48471      applyMatrix: null,
48472      matrix: new Matrix(),
48473      pivot: null,
48474      visible: true,
48475      blendMode: 'normal',
48476      opacity: 1,
48477      locked: false,
48478      guide: false,
48479      clipMask: false,
48480      selected: false,
48481      data: {}
48482    },
48483    _prioritize: ['applyMatrix']
48484  }, new function () {
48485    var handlers = ['onMouseDown', 'onMouseUp', 'onMouseDrag', 'onClick', 'onDoubleClick', 'onMouseMove', 'onMouseEnter', 'onMouseLeave'];
48486    return Base.each(handlers, function (name) {
48487      this._events[name] = {
48488        install: function install(type) {
48489          this.getView()._countItemEvent(type, 1);
48490        },
48491        uninstall: function uninstall(type) {
48492          this.getView()._countItemEvent(type, -1);
48493        }
48494      };
48495    }, {
48496      _events: {
48497        onFrame: {
48498          install: function install() {
48499            this.getView()._animateItem(this, true);
48500          },
48501          uninstall: function uninstall() {
48502            this.getView()._animateItem(this, false);
48503          }
48504        },
48505        onLoad: {},
48506        onError: {}
48507      },
48508      statics: {
48509        _itemHandlers: handlers
48510      }
48511    });
48512  }(), {
48513    initialize: function Item() {},
48514    _initialize: function _initialize(props, point) {
48515      var hasProps = props && Base.isPlainObject(props),
48516          internal = hasProps && props.internal === true,
48517          matrix = this._matrix = new Matrix(),
48518          project = hasProps && props.project || paper.project,
48519          settings = paper.settings;
48520      this._id = internal ? null : UID.get();
48521      this._parent = this._index = null;
48522      this._applyMatrix = this._canApplyMatrix && settings.applyMatrix;
48523      if (point) matrix.translate(point);
48524      matrix._owner = this;
48525      this._style = new Style(project._currentStyle, this, project);
48526
48527      if (internal || hasProps && props.insert == false || !sett
48527ings.insertItems && !(hasProps && props.insert === true)) {
48528        this._setProject(project);
48529      } else {
48530        (hasProps && props.parent || project)._insertItem(undefined, this, true);
48531      }
48532
48533      if (hasProps && props !== Item.NO_INSERT) {
48534        this.set(props, {
48535          internal: true,
48536          insert: true,
48537          project: true,
48538          parent: true
48539        });
48540      }
48541
48542      return hasProps;
48543    },
48544    _serialize: function _serialize(options, dictionary) {
48545      var props = {},
48546          that = this;
48547
48548      function serialize(fields) {
48549        for (var key in fields) {
48550          var value = that[key];
48551
48552          if (!Base.equals(value, key === 'leading' ? fields.fontSize * 1.2 : fields[key])) {
48553            props[key] = Base.serialize(value, options, key !== 'data', dictionary);
48554          }
48555        }
48556      }
48557
48558      serialize(this._serializeFields);
48559      if (!(this instanceof Group)) serialize(this._style._defaults);
48560      return [this._class, props];
48561    },
48562    _changed: function _changed(flags) {
48563      var symbol = this._symbol,
48564          cacheParent = this._parent || symbol,
48565          project = this._project;
48566
48567      if (flags & 8) {
48568        this._bounds = this._position = this._decomposed = undefined;
48569      }
48570
48571      if (flags & 16) {
48572        this._globalMatrix = undefined;
48573      }
48574
48575      if (cacheParent && flags & 72) {
48576        Item._clearBoundsCache(cacheParent);
48577      }
48578
48579      if (flags & 2) {
48580        Item._clearBoundsCache(this);
48581      }
48582
48583      if (project) project._changed(flags, this);
48584      if (symbol) symbol._changed(flags);
48585    },
48586    getId: function getId() {
48587      return this._id;
48588    },
48589    getName: function getName() {
48590      return this._name;
48591    },
48592    setName: function setName(name) {
48593      if (this._name) this._removeNamed();
48594      if (name === +name + '') throw new Error('Names consisting only of numbers are not supported.');
48595
48596      var owner = this._getOwner();
48597
48598      if (name && owner) {
48599        var children = owner._children,
48600            namedChildren = owner._namedChildren;
48601        (namedChildren[name] = namedChildren[name] || []).push(this);
48602        if (!(name in children)) children[name] = this;
48603      }
48604
48605      this._name = name || undefined;
48606
48607      this._changed(256);
48608    },
48609    getStyle: function getStyle() {
48610      return this._style;
48611    },
48612    setStyle: function setStyle(style) {
48613      this.getStyle().set(style);
48614    }
48615  }, Base.each(['locked', 'visible', 'blendMode', 'opacity', 'guide'], function (name) {
48616    var part = Base.capitalize(name),
48617        key = '_' + name,
48618        flags = {
48619      locked: 256,
48620      visible: 265
48621    };
48622
48623    this['get' + part] = function () {
48624      return this[key];
48625    };
48626
48627    this['set' + part] = function (value) {
48628      if (value != this[key]) {
48629        this[key] = value;
48630
48631        this._changed(flags[name] || 257);
48632      }
48633    };
48634  }, {}), {
48635    beans: true,
48636    getSelection: function getSelection() {
48637      return this._selection;
48638    },
48639    setSelection: function setSelection(selection) {
48640      if (selection !== this._selection) {
48641        this._selection = selection;
48642        var project = this._project;
48643
48644        if (project) {
48645          project._updateSelection(this);
48646
48647          this._changed(257);
48648        }
48649      }
48650    },
48651    _changeSelection: function _changeSelection(flag, selected) {
48652      var selection = this._selection;
48653      this.setSelection(selected ? selection | flag : selection & ~flag);
48654    },
48655    isSelected: function isSelected() {
48656      if (this._selectChildren) {
48657        var children = this._children;
48658
48659        for (var i = 0, l = children.length; i < l; i++) {
48660          if (children[i].isSelected()) return true;
48661        }
48662      }
48663
48664      return !!(this._selection & 1);
48665    },
48666    setSelected: function setSelected(selected) {
48667      if (this._selectChildren) {
48668        var children = this._children;
48669
48670        for (var i = 0, l = children.length; i < l; i++) {
48671          children[i].setSelected(selected);
48672        }
48673      }
48674
48675      this._changeSelection(1, selected);
48676    },
48677    isFullySelected: function isFullySelected() {
48678      var children = this._children,
48679          selected = !!(this._selection & 1);
48680
48681      if (children && selected) {
48682        for (var i = 0, l = children.length; i < l; i++) {
48683          if (!children[i].isFullySelected()) return false;
48684        }
48685
48686        return true;
48687      }
48688
48689      return selected;
48690    },
48691    setFullySelected: function setFullySelected(selected) {
48692      var children = this._children;
48693
48694      if (children) {
48695        for (var i = 0, l = children.length; i < l; i++) {
48696          children[i].setFullySelected(selected);
48697        }
48698      }
48699
48700      this._changeSelection(1, selected);
48701    },
48702    isClipMask: function isClipMask() {
48703      return this._clipMask;
48704    },
48705    setClipMask: function setClipMask(clipMask) {
48706      if (this._clipMask != (clipMask = !!clipMask)) {
48707        this._clipMask = clipMask;
48708
48709        if (clipMask) {
48710          this.setFillColor(null);
48711          this.setStrokeColor(null);
48712        }
48713
48714        this._changed(257);
48715
48716        if (this._parent) this._parent._changed(2048);
48717      }
48718    },
48719    getData: function getData() {
48720      if (!this._data) this._data = {};
48721      return this._data;
48722    },
48723    setData: function setData(data) {
48724      this._data = data;
48725    },
48726    getPosition: function getPosition(_dontLink) {
48727      var ctor = _dontLink ? Point : LinkedPoint;
48728
48729      var position = this._position || (this._position = this._getPositionFromBounds());
48730
48731      return new ctor(position.x, position.y, this, 'setPosition');
48732    },
48733    setPosition: function setPosition() {
48734      this.translate(Point.read(arguments).subtract(this.getPosition(true)));
48735    },
48736    _getPositionFromBounds: function _getPositionFromBounds(bounds) {
48737      return this._pivot ? this._matrix._transformPoint(this._pivot) : (bounds || this.getBounds()).getCenter(true);
48738    },
48739    getPivot: function getPivot() {
48740      var pivot = this._pivot;
48741      return pivot ? new LinkedPoint(pivot.x, pivot.y, this, 'setPivot') : null;
48742    },
48743    setPivot: function setPivot() {
48744      this._pivot = Point.read(arguments, 0, {
48745        clone: true,
48746        readNull: true
48747      });
48748      this._position = undefined;
48749    }
48750  }, Base.each({
48751    getStrokeBounds: {
48752      stroke: true
48753    },
48754    getHandleBounds: {
48755      handle: true
48756    },
48757    getInternalBounds: {
48758      internal: true
48759    }
48760  }, function (options, key) {
48761    this[key] = function (matrix) {
48762      return this.getBounds(matrix, options);
48763    };
48764  }, {
48765    beans: true,
48766    getBounds: function getBounds(matrix, options) {
48767      var hasMatrix = options || matrix instanceof Matrix,
48768          opts = Base.set({}, hasMatrix ? options : matrix, this._boundsOptions);
vendor: 4,179 bytes, lines 48769-48891
48769      if (!opts.stroke || this.getStrokeScaling()) opts.cacheItem = this;
48770
48771      var rect = this._getCachedBounds(hasMatrix && matrix, opts).rect;
48772
48773      return !arguments.length ? new LinkedRectangle(rect.x, rect.y, rect.width, rect.height, this, 'setBounds') : rect;
48774    },
48775    setBounds: function setBounds() {
48776      var rect = _Rectangle.read(arguments),
48777          bounds = this.getBounds(),
48778          _matrix = this._matrix,
48779          matrix = new Matrix(),
48780          center = rect.getCenter();
48781
48782      matrix.translate(center);
48783
48784      if (rect.width != bounds.width || rect.height != bounds.height) {
48785        if (!_matrix.isInvertible()) {
48786          _matrix.set(_matrix._backup || new Matrix().translate(_matrix.getTranslation()));
48787
48788          bounds = this.getBounds();
48789        }
48790
48791        matrix.scale(bounds.width !== 0 ? rect.width / bounds.width : 0, bounds.height !== 0 ? rect.height / bounds.height : 0);
48792      }
48793
48794      center = bounds.getCenter();
48795      matrix.translate(-center.x, -center.y);
48796      this.transform(matrix);
48797    },
48798    _getBounds: function _getBounds(matrix, options) {
48799      var children = this._children;
48800      if (!children || !children.length) return new _Rectangle();
48801
48802      Item._updateBoundsCache(this, options.cacheItem);
48803
48804      return Item._getBounds(children, matrix, options);
48805    },
48806    _getBoundsCacheKey: function _getBoundsCacheKey(options, internal) {
48807      return [options.stroke ? 1 : 0, options.handle ? 1 : 0, internal ? 1 : 0].join('');
48808    },
48809    _getCachedBounds: function _getCachedBounds(matrix, options, noInternal) {
48810      matrix = matrix && matrix._orNullIfIdentity();
48811
48812      var internal = options.internal && !noInternal,
48813          cacheItem = options.cacheItem,
48814          _matrix = internal ? null : this._matrix._orNullIfIdentity(),
48815          cacheKey = cacheItem && (!matrix || matrix.equals(_matrix)) && this._getBoundsCacheKey(options, internal),
48816          bounds = this._bounds;
48817
48818      Item._updateBoundsCache(this._parent || this._symbol, cacheItem);
48819
48820      if (cacheKey && bounds && cacheKey in bounds) {
48821        var cached = bounds[cacheKey];
48822        return {
48823          rect: cached.rect.clone(),
48824          nonscaling: cached.nonscaling
48825        };
48826      }
48827
48828      var res = this._getBounds(matrix || _matrix, options),
48829          rect = res.rect || res,
48830          style = this._style,
48831          nonscaling = res.nonscaling || style.hasStroke() && !style.getStrokeScaling();
48832
48833      if (cacheKey) {
48834        if (!bounds) {
48835          this._bounds = bounds = {};
48836        }
48837
48838        var cached = bounds[cacheKey] = {
48839          rect: rect.clone(),
48840          nonscaling: nonscaling,
48841          internal: internal
48842        };
48843      }
48844
48845      return {
48846        rect: rect,
48847        nonscaling: nonscaling
48848      };
48849    },
48850    _getStrokeMatrix: function _getStrokeMatrix(matrix, options) {
48851      var parent = this.getStrokeScaling() ? null : options && options.internal ? this : this._parent || this._symbol && this._symbol._item,
48852          mx = parent ? parent.getViewMatrix().invert() : matrix;
48853      return mx && mx._shiftless();
48854    },
48855    statics: {
48856      _updateBoundsCache: function _updateBoundsCache(parent, item) {
48857        if (parent && item) {
48858          var id = item._id,
48859              ref = parent._boundsCache = parent._boundsCache || {
48860            ids: {},
48861            list: []
48862          };
48863
48864          if (!ref.ids[id]) {
48865            ref.list.push(item);
48866            ref.ids[id] = item;
48867          }
48868        }
48869      },
48870      _clearBoundsCache: function _clearBoundsCache(item) {
48871        var cache = item._boundsCache;
48872
48873        if (cache) {
48874          item._bounds = item._position = item._boundsCache = undefined;
48875
48876          for (var i = 0, list = cache.list, l = list.length; i < l; i++) {
48877            var other = list[i];
48878
48879            if (other !== item) {
48880              other._bounds = other._position = undefined;
48881              if (other._boundsCache) Item._clearBoundsCache(other);
48882            }
48883          }
48884        }
48885      },
48886      _getBounds: function _getBounds(items, matrix, options) {
48887        var x1 = Infinity,
48888            x2 = -x1,
48889            y1 = x1,
48890            y2 = x2,
48891            nonscaling = false;
48892        options = options || {};
48893
48894        for (var i = 0, l = items.length; i < l; i++) {
48895          var item = items[i];
48896
48897          if (item._visible && !item.isEmpty(true)) {
48898            var bounds = item._getCachedBounds(matrix && matrix.appended(item._matrix), options, true),
48899                rect = bounds.rect;
48900
48901            x1 = Math.min(rect.x, x1);
48902            y1 = Math.min(rect.y, y1);
48903            x2 = Math.max(rect.x + rect.width, x2);
48904            y2 = Math.max(rect.y + rect.height, y2);
48905            if (bounds.nonscaling) nonscaling = true;
48906          }
48907        }
48908
48909        return {
48910          rect: isFinite(x1) ? new _Rectangle(x1, y1, x2 - x1, y2 - y1) : new _Rectangle(),
48911          nonscaling: nonscaling
48912        };
48913      }
48914    }
48915  }), {
48916    beans: true,
48917    _decompose: function _decompose() {
48918      return this._applyMatrix ? null : this._decomposed || (this._decomposed = this._matrix.decompose());
48919    },
48920    getRotation: function getRotation() {
48921      var decomposed = this._decompose();
48922
48923      return decomposed ? decomposed.rotation : 0;
48924    },
48925    setRotation: function setRotation(rotation) {
48926      var current = this.getRotation();
48927
48928      if (current != null && rotation != null) {
48929        var decomposed = this._decomposed;
48930        this.rotate(rotation - current);
48931
48932        if (decomposed) {
48933          decomposed.rotation = rotation;
48934          this._decomposed = decomposed;
48935        }
48936      }
48937    },
48938    getScaling: function getScaling() {
48939      var decomposed = this._decompose(),
48940          s = decomposed && decomposed.scaling;
48941
48942      return new LinkedPoint(s ? s.x : 1, s ? s.y : 1, this, 'setScaling');
48943    },
48944    setScaling: function setScaling() {
48945      var current = this.getScaling(),
48946          scaling = Point.read(arguments, 0, {
48947        clone: true,
48948        readNull: true
48949      });
48950
48951      if (current && scaling && !current.equals(scaling)) {
48952        var rotation = this.getRotation(),
48953            decomposed = this._decomposed,
48954            matrix = new Matrix(),
48955            center = this.getPosition(true);
48956        matrix.translate(center);
48957        if (rotation) matrix.rotate(rotation);
48958        matrix.scale(scaling.x / current.x, scaling.y / current.y);
48959        if (rotation) matrix.rotate(-rotation);
48960        matrix.translate(center.negate());
48961        this.transform(matrix);
48962
48963        if (decomposed) {
48964          decomposed.scaling = scaling;
48965          this._decomposed = decomposed;
48966        }
48967      }
48968    },
48969    getMatrix: function getMatrix() {
48970      return this._matrix;
48971    },
48972    setMatrix: function setMatrix() {
48973      var matrix = this._matrix;
48974      matrix.initialize.apply(matrix, arguments);
48975    },
48976    getGlobalMatrix: function getGlobalMatrix(_dontClone) {
48977      var matrix = this._globalMatrix;
48978
48979      if (matrix) {
48980        var parent = this._parent;
48981        var parents = [];
48982
48983        while (parent) {
48984          if (!parent._globalMatrix) {
48985            matrix = null;
48986
48987            for (var i = 0, l = parents.length; i < l; i++) {
48988              parents[i]._globalMatrix = null;
48989            }
48990
48991            break;
48992          }
48993
48994          parents.push(parent);
48995          parent = parent._parent;
48996        }
48997      }
48998
48999      if (!matrix) {
49000        matrix = this._globalMatrix = this._matrix.clone();
49001        var parent = this._parent;
49002        if (parent) matrix.prepend(parent.getGlobalMatrix(true));
49003      }
49004
49005      return _dontClone ? matrix : matrix.clone();
49006    },
49007    getViewMatrix: function getViewMatrix() {
49008      return this.getGlobalMatrix().prepend(this.getView()._matrix);
49009    },
49010    getApplyMatrix: function getApplyMatrix() {
49011      return this._applyMatrix;
49012    },
49013    setApplyMatrix: function setApplyMatrix(apply) {
49014      if (this._applyMatrix = this._canApplyMatrix && !!apply) this.transform(null, true);
49015    },
49016    getTransformContent: '#getApplyMatrix',
49017    setTransformContent: '#setApplyMatrix'
49018  }, {
49019    getProject: function getProject() {
49020      return this._project;
49021    },
49022    _setProject: function _setProject(project, installEvents) {
49023      if (this._project !== project) {
49024        if (this._project) this._installEvents(false);
49025        this._project = project;
49026        var children = this._children;
49027
49028        for (var i = 0, l = children && children.length; i < l; i++) {
49029          children[i]._setProject(project);
49030        }
49031
49032        installEvents = true;
49033      }
49034
49035      if (installEvents) this._installEvents(true);
49036    },
49037    getView: function getView() {
49038      return this._project._view;
49039    },
49040    _installEvents: function _installEvents(install) {
49041      _installEvents.base.call(this, install);
49042
49043      var children = this._children;
49044
49045      for (var i = 0, l = children && children.length; i < l; i++) {
49046        children[i]._installEvents(install);
49047      }
49048    },
49049    getLayer: function getLayer() {
49050      var parent = this;
49051
49052      while (parent = parent._parent) {
49053        if (parent instanceof Layer) return parent;
49054      }
49055
49056      return null;
49057    },
49058    getParent: function getParent() {
49059      return this._parent;
49060    },
49061    setParent: function setParent(item) {
49062      return item.addChild(this);
49063    },
49064    _getOwner: '#getParent',
49065    getChildren: function getChildren() {
49066      return this._children;
49067    },
49068    setChildren: function setChildren(items) {
49069      this.removeChildren();
49070      this.addChildren(items);
49071    },
49072    getFirstChild: function getFirstChild() {
49073      return this._children && this._children[0] || null;
49074    },
49075    getLastChild: function getLastChild() {
49076      return this._children && this._children[this._children.length - 1] || null;
49077    },
49078    getNextSibling: function getNextSibling() {
49079      var owner = this._getOwner();
49080
49081      return owner && owner._children[this._index + 1] || null;
49082    },
49083    getPreviousSibling: function getPreviousSibling() {
49084      var owner = this._getOwner();
49085
49086      return owner && owner._children[this._index - 1] || null;
49087    },
49088    getIndex: function getIndex() {
49089      return this._index;
49090    },
49091    equals: function equals(item) {
49092      return item === this || item && this._class === item._class && this._style.equals(item._style) && this._matrix.equals(item._matrix
49092) && this._locked === item._locked && this._visible === item._visible && this._blendMode === item._blendMode && this._opacity === item._opacity && this._clipMask === item._clipMask && this._guide === item._guide && this._equals(item) || false;
49093    },
49094    _equals: function _equals(item) {
49095      return Base.equals(this._children, item._children);
49096    },
49097    clone: function clone(options) {
49098      var copy = new this.constructor(Item.NO_INSERT),
49099          children = this._children,
49100          insert = Base.pick(options ? options.insert : undefined, options === undefined || options === true),
49101          deep = Base.pick(options ? options.deep : undefined, true);
49102      if (children) copy.copyAttributes(this);
49103      if (!children || deep) copy.copyContent(this);
49104      if (!children) copy.copyAttributes(this);
49105      if (insert) copy.insertAbove(this);
49106      var name = this._name,
49107          parent = this._parent;
49108
49109      if (name && parent) {
49110        var children = parent._children,
49111            orig = name,
49112            i = 1;
49113
49114        while (children[name]) {
49115          name = orig + ' ' + i++;
49116        }
49117
49118        if (name !== orig) copy.setName(name);
49119      }
49120
49121      return copy;
49122    },
49123    copyContent: function copyContent(source) {
49124      var children = source._children;
49125
49126      for (var i = 0, l = children && children.length; i < l; i++) {
49127        this.addChild(children[i].clone(false), true);
49128      }
49129    },
49130    copyAttributes: function copyAttributes(source, excludeMatrix) {
49131      this.setStyle(source._style);
49132      var keys = ['_locked', '_visible', '_blendMode', '_opacity', '_clipMask', '_guide'];
49133
49134      for (var i = 0, l = keys.length; i < l; i++) {
49135        var key = keys[i];
49136        if (source.hasOwnProperty(key)) this[key] = source[key];
49137      }
49138
49139      if (!excludeMatrix) this._matrix.set(source._matrix, true);
49140      this.setApplyMatrix(source._applyMatrix);
49141      this.setPivot(source._pivot);
49142      this.setSelection(source._selection);
49143      var data = source._data,
49144          name = source._name;
49145      this._data = data ? Base.clone(data) : null;
49146      if (name) this.setName(name);
49147    },
49148    rasterize: function rasterize(resolution, insert) {
49149      var bounds = this.getStrokeBounds(),
49150          scale = (resolution || this.getView().getResolution()) / 72,
49151          topLeft = bounds.getTopLeft().floor(),
49152          bottomRight = bounds.getBottomRight().ceil(),
49153          size = new Size(bottomRight.subtract(topLeft)),
49154          raster = new Raster(Item.NO_INSERT);
49155
49156      if (!size.isZero()) {
49157        var canvas = CanvasProvider.getCanvas(size.multiply(scale)),
49158            ctx = canvas.getContext('2d'),
49159            matrix = new Matrix().scale(scale).translate(topLeft.negate());
49160        ctx.save();
49161        matrix.applyToContext(ctx);
49162        this.draw(ctx, new Base({
49163          matrices: [matrix]
49164        }));
49165        ctx.restore();
49166        raster.setCanvas(canvas);
49167      }
49168
49169      raster.transform(new Matrix().translate(topLeft.add(size.divide(2))).scale(1 / scale));
49170      if (insert === undefined || insert) raster.insertAbove(this);
49171      return raster;
49172    },
49173    contains: function contains() {
49174      var matrix = this._matrix;
49175      return matrix.isInvertible() && !!this._contains(matrix._inverseTransform(Point.read(arguments)));
49176    },
49177    _contains: function _contains(point) {
49178      var children = this._children;
49179
49180      if (children) {
49181        for (var i = children.length - 1; i >= 0; i--) {
49182          if (children[i].contains(point)) return true;
49183        }
49184
49185        return false;
49186      }
49187
49188      return point.isInside(this.getInternalBounds());
49189    },
49190    isInside: function isInside() {
49191      return _Rectangle.read(arguments).contains(this.getBounds());
49192    },
49193    _asPathItem: function _asPathItem() {
49194      return new Path.Rectangle({
49195        rectangle: this.getInternalBounds(),
49196        matrix: this._matrix,
49197        insert: false
49198      });
49199    },
49200    intersects: function intersects(item, _matrix) {
49201      if (!(item instanceof Item)) return false;
49202      return this._asPathItem().getIntersections(item._asPathItem(), null, _matrix, true).length > 0;
49203    }
49204  }, new function () {
49205    function hitTest() {
49206      var args = arguments;
49207      return this._hitTest(Point.read(args), HitResult.getOptions(args));
49208    }
49209
49210    function hitTestAll() {
49211      var args = arguments,
49212          point = Point.read(args),
49213          options = HitResult.getOptions(args),
49214          all = [];
49215
49216      this._hitTest(point, new Base({
49217        all: all
49218      }, options));
49219
49220      return all;
49221    }
49222
49223    function hitTestChildren(point, options, viewMatrix, _exclude) {
49224      var children = this._children;
49225
49226      if (children) {
49227        for (var i = children.length - 1; i >= 0; i--) {
49228          var child = children[i];
49229
49230          var res = child !== _exclude && child._hitTest(point, options, viewMatrix);
49231
49232          if (res && !options.all) return res;
49233        }
49234      }
49235
49236      return null;
49237    }
49238
49239    Project.inject({
49240      hitTest: hitTest,
49241      hitTestAll: hitTestAll,
49242      _hitTest: hitTestChildren
49243    });
49244    return {
49245      hitTest: hitTest,
49246      hitTestAll: hitTestAll,
49247      _hitTestChildren: hitTestChildren
49248    };
49249  }(), {
49250    _hitTest: function _hitTest(point, options, parentViewMatrix) {
vendor: 6,139 bytes, lines 49251-49427
49251      if (this._locked || !this._visible || this._guide && !options.guides || this.isEmpty()) {
49252        return null;
49253      }
49254
49255      var matrix = this._matrix,
49256          viewMatrix = parentViewMatrix ? parentViewMatrix.appended(matrix) : this.getGlobalMatrix().prepend(this.getView()._matrix),
49257          tolerance = Math.max(options.tolerance, 1e-12),
49258          tolerancePadding = options._tolerancePadding = new Size(Path._getStrokePadding(tolerance, matrix._shiftless().invert()));
49259      point = matrix._inverseTransform(point);
49260
49261      if (!point || !this._children && !this.getBounds({
49262        internal: true,
49263        stroke: true,
49264        handle: true
49265      }).expand(tolerancePadding.multiply(2))._containsPoint(point)) {
49266        return null;
49267      }
49268
49269      var checkSelf = !(options.guides && !this._guide || options.selected && !this.isSelected() || options.type && options.type !== Base.hyphenate(this._class) || options.class && !(this instanceof options.class)),
49270          match = options.match,
49271          that = this,
49272          bounds,
49273          res;
49274
49275      function filter(hit) {
49276        if (hit && match && !match(hit)) hit = null;
49277        if (hit && options.all) options.all.push(hit);
49278        return hit;
49279      }
49280
49281      function checkPoint(type, part) {
49282        var pt = part ? bounds['get' + part]() : that.getPosition();
49283
49284        if (point.subtract(pt).divide(tolerancePadding).length <= 1) {
49285          return new HitResult(type, that, {
49286            name: part ? Base.hyphenate(part) : type,
49287            point: pt
49288          });
49289        }
49290      }
49291
49292      var checkPosition = options.position,
49293          checkCenter = options.center,
49294          checkBounds = options.bounds;
49295
49296      if (checkSelf && this._parent && (checkPosition || checkCenter || checkBounds)) {
49297        if (checkCenter || checkBounds) {
49298          bounds = this.getInternalBounds();
49299        }
49300
49301        res = checkPosition && checkPoint('position') || checkCenter && checkPoint('center', 'Center');
49302
49303        if (!res && checkBounds) {
49304          var points = ['TopLeft', 'TopRight', 'BottomLeft', 'BottomRight', 'LeftCenter', 'TopCenter', 'RightCenter', 'BottomCenter'];
49305
49306          for (var i = 0; i < 8 && !res; i++) {
49307            res = checkPoint('bounds', points[i]);
49308          }
49309        }
49310
49311        res = filter(res);
49312      }
49313
49314      if (!res) {
49315        res = this._hitTestChildren(point, options, viewMatrix) || checkSelf && filter(this._hitTestSelf(point, options, viewMatrix, this.getStrokeScaling() ? null : viewMatrix._shiftless().invert())) || null;
49316      }
49317
49318      if (res && res.point) {
49319        res.point = matrix.transform(res.point);
49320      }
49321
49322      return res;
49323    },
49324    _hitTestSelf: function _hitTestSelf(point, options) {
49325      if (options.fill && this.hasFill() && this._contains(point)) return new HitResult('fill', this);
49326    },
49327    matches: function matches(name, compare) {
49328      function matchObject(obj1, obj2) {
49329        for (var i in obj1) {
49330          if (obj1.hasOwnProperty(i)) {
49331            var val1 = obj1[i],
49332                val2 = obj2[i];
49333
49334            if (Base.isPlainObject(val1) && Base.isPlainObject(val2)) {
49335              if (!matchObject(val1, val2)) return false;
49336            } else if (!Base.equals(val1, val2)) {
49337              return false;
49338            }
49339          }
49340        }
49341
49342        return true;
49343      }
49344
49345      var type = _typeof(name);
49346
49347      if (type === 'object') {
49348        for (var key in name) {
49349          if (name.hasOwnProperty(key) && !this.matches(key, name[key])) return false;
49350        }
49351
49352        return true;
49353      } else if (type === 'function') {
49354        return name(this);
49355      } else if (name === 'match') {
49356        return compare(this);
49357      } else {
49358        var value = /^(empty|editable)$/.test(name) ? this['is' + Base.capitalize(name)]() : name === 'type' ? Base.hyphenate(this._class) : this[name];
49359
49360        if (name === 'class') {
49361          if (typeof compare === 'function') return this instanceof compare;
49362          value = this._class;
49363        }
49364
49365        if (typeof compare === 'function') {
49366          return !!compare(value);
49367        } else if (compare) {
49368          if (compare.test) {
49369            return compare.test(value);
49370          } else if (Base.isPlainObject(compare)) {
49371            return matchObject(compare, value);
49372          }
49373        }
49374
49375        return Base.equals(value, compare);
49376      }
49377    },
49378    getItems: function getItems(options) {
49379      return Item._getItems(this, options, this._matrix);
49380    },
49381    getItem: function getItem(options) {
49382      return Item._getItems(this, options, this._matrix, null, true)[0] || null;
49383    },
49384    statics: {
49385      _getItems: function _getItems(item, options, matrix, param, firstOnly) {
49386        if (!param) {
49387          var obj = _typeof(options) === 'object' && options,
49388              overlapping = obj && obj.overlapping,
49389              inside = obj && obj.inside,
49390              bounds = overlapping || inside,
49391              rect = bounds && _Rectangle.read([bounds]);
49392
49393          param = {
49394            items: [],
49395            recursive: obj && obj.recursive !== false,
49396            inside: !!inside,
49397            overlapping: !!overlapping,
49398            rect: rect,
49399            path: overlapping && new Path.Rectangle({
49400              rectangle: rect,
49401              insert: false
49402            })
49403          };
49404
49405          if (obj) {
49406            options = Base.filter({}, options, {
49407              recursive: true,
49408              inside: true,
49409              overlapping: true
49410            });
49411          }
49412        }
49413
49414        var children = item._children,
49415            items = param.items,
49416            rect = param.rect;
49417        matrix = rect && (matrix || new Matrix());
49418
49419        for (var i = 0, l = children && children.length; i < l; i++) {
49420          var child = children[i],
49421              childMatrix = matrix && matrix.appended(child._matrix),
49422              add = true;
49423
49424          if (rect) {
49425            var bounds = child.getBounds(childMatrix);
49426            if (!rect.intersects(bounds)) continue;
49427            if (!(rect.contains(bounds) || param.overlapping && (bounds.contains(rect) || param.path.intersects(child, childMatrix)))) add = false;
49428          }
49429
49430          if (add && child.matches(options)) {
49431            items.push(child);
49432            if (firstOnly) break;
49433          }
49434
49435          if (param.recursive !== false) {
49436            _getItems(child, options, childMatrix, param, firstOnly);
49437          }
49438
49439          if (firstOnly && items.length > 0) break;
49440        }
49441
49442        return items;
49443      }
49444    }
49445  }, {
49446    importJSON: function importJSON(json) {
49447      var res = Base.importJSON(json, this);
49448      return res !== this ? this.addChild(res) : res;
49449    },
49450    addChild: function addChild(item) {
49451      return this.insertChild(undefined, item);
49452    },
49453    insertChild: function insertChild(index, item) {
49454      var res = item ? this.insertChildren(index, [item]) : null;
49455      return res && res[0];
49456    },
49457    addChildren: function addChildren(items) {
49458      return this.insertChildren(this._children.length, items);
49459    },
49460    insertChildren: function insertChildren(index, items) {
49461      var children = this._children;
49462
49463      if (children && items && items.length > 0) {
49464        items = Base.slice(items);
49465        var inserted = {};
49466
49467        for (var i = items.length - 1; i >= 0; i--) {
49468          var item = items[i],
49469              id = item && item._id;
49470
49471          if (!item || inserted[id]) {
49472            items.splice(i, 1);
49473          } else {
49474            item._remove(false, true);
49475
49476            inserted[id] = true;
49477          }
49478        }
49479
49480        Base.splice(children, items, index, 0);
49481        var project = this._project,
49482            notifySelf = project._changes;
49483
49484        for (var i = 0, l = items.length; i < l; i++) {
49485          var item = items[i],
49486              name = item._name;
49487          item._parent = this;
49488
49489          item._setProject(project, true);
49490
49491          if (name) item.setName(name);
49492          if (notifySelf) item._changed(5);
49493        }
49494
49495        this._changed(11);
49496      } else {
49497        items = null;
49498      }
49499
49500      return items;
49501    },
49502    _insertItem: '#insertChild',
49503    _insertAt: function _insertAt(item, offset) {
49504      var owner = item && item._getOwner(),
49505          res = item !== this && owner ? this : null;
49506
49507      if (res) {
49508        res._remove(false, true);
49509
49510        owner._insertItem(item._index + offset, res);
49511      }
49512
49513      return res;
49514    },
49515    insertAbove: function insertAbove(item) {
49516      return this._insertAt(item, 1);
49517    },
49518    insertBelow: function insertBelow(item) {
49519      return this._insertAt(item, 0);
49520    },
49521    sendToBack: function sendToBack() {
49522      var owner = this._getOwner();
49523
49524      return owner ? owner._insertItem(0, this) : null;
49525    },
49526    bringToFront: function bringToFront() {
49527      var owner = this._getOwner();
49528
49529      return owner ? owner._insertItem(undefined, this) : null;
49530    },
49531    appendTop: '#addChild',
49532    appendBottom: function appendBottom(item) {
49533      return this.insertChild(0, item);
49534    },
49535    moveAbove: '#insertAbove',
49536    moveBelow: '#insertBelow',
49537    addTo: function addTo(owner) {
49538      return owner._insertItem(undefined, this);
49539    },
49540    copyTo: function copyTo(owner) {
49541      return this.clone(false).addTo(owner);
49542    },
49543    reduce: function reduce(options) {
49544      var children = this._children;
49545
49546      if (children && children.length === 1) {
49547        var child = children[0].reduce(options);
49548
49549        if (this._parent) {
49550          child.insertAbove(this);
49551          this.remove();
49552        } else {
49553          child.remove();
49554        }
49555
49556        return child;
49557      }
49558
49559      return this;
49560    },
49561    _removeNamed: function _removeNamed() {
49562      var owner = this._getOwner();
49563
49564      if (owner) {
49565        var children = owner._children,
49566            namedChildren = owner._namedChildren,
49567            name = this._name,
49568            namedArray = namedChildren[name],
49569            index = namedArray ? namedArray.indexOf(this) : -1;
49570
49571        if (index !== -1) {
49572          if (children[name] == this) delete children[name];
49573          namedArray.splice(index, 1);
49574
49575          if (namedArray.length) {
49576            children[name] = namedArray[0];
49577          } else {
49578            delete namedChildren[name];
49579          }
49580        }
49581      }
49582    },
49583    _remove: function _remove(notifySelf, notifyParent) {
49584      var owner = this._getOwner(),
49585          project = this._project,
49586          index = this._index;
49587
49588      if (this._style) this._style._dispose();
49589
49590      if (owner) {
49591        if (this._name) this._removeNamed();
49592
49593        if (index != null) {
49594          if (project._activeLayer === this) project._activeLayer = this.getNextSibling() || this.getPreviousSibling();
49595          Base.splice(owner._children, null, index, 1);
49596        }
49597
49598        this._installEvents(false);
49599
49600        if (notifySelf && project._changes) this._changed(5);
49601        if (notifyParent) owner._changed(11, this);
49602        this._parent = null;
49603        return true;
49604      }
49605
49606      return false;
49607    },
49608    remove: function remove() {
49609      return this._remove(true, true);
49610    },
49611    replaceWith: function replaceWith(item) {
49612      var ok = item && item.insertBelow(this);
49613      if (ok) this.remove();
49614      return ok;
49615    },
49616    removeChildren: function removeChildren(start, end) {
49617      if (!this._children) return null;
49618      start = start || 0;
49619      end = Base.pick(end, this._children.length);
49620      var removed = Base.splice(this._children, null, start, end - start);
49621
49622      for (var i = removed.length - 1; i >= 0; i--) {
49623        removed[i]._remove(true, false);
49624      }
49625
49626      if (removed.length > 0) this._changed(11);
49627      return removed;
49628    },
49629    clear: '#removeChildren',
49630    reverseChildren: function reverseChildren() {
49631      if (this._children) {
49632        this._children.reverse();
49633
49634        for (var i = 0, l = this._children.length; i < l; i++) {
49635          this._children[i]._index = i;
49636        }
49637
49638        this._changed(11);
49639      }
49640    },
49641    isEmpty: function isEmpty(recursively) {
49642      var children = this._children;
49643      var numChildren = children ? children.length : 0;
49644
49645      if (recursively) {
49646        for (var i = 0; i < numChildren; i++) {
49647          if (!children[i].isEmpty(recursively)) {
49648            return false;
49649          }
49650        }
49651
49652        return true;
49653      }
49654
49655      return !numChildren;
49656    },
49657    isEditable: function isEditable() {
49658      var item = this;
49659
49660      while (item) {
49661        if (!item._visible || item._locked) return false;
49662        item = item._parent;
49663      }
49664
49665      return true;
49666    },
49667    hasFill: function hasFill() {
49668      return this.getStyle().hasFill();
49669    },
49670    hasStroke: function hasStroke() {
49671      return this.getStyle().hasStroke();
49672    },
49673    hasShadow: function hasShadow() {
49674      return this.getStyle().hasShadow();
49675    },
49676    _getOrder: function _getOrder(item) {
49677      function getList(item) {
49678        var list = [];
49679
49680        do {
49681          list.unshift(item);
49682        } while (item = item._parent);
49683
49684        return list;
49685      }
49686
49687      var list1 = getList(this),
49688          list2 = getList(item);
49689
49690      for (var i = 0, l = Math.min(list1.length, list2.length); i < l; i++) {
49691        if (list1[i] != list2[i]) {
49692          return list1[i]._index < list2[i]._index ? 1 : -1;
49693        }
49694      }
49695
49696      return 0;
49697    },
49698    hasChildren: function hasChildren() {
49699      return this._children && this._children.length > 0;
49700    },
49701    isInserted: function isInserted() {
49702      return this._parent ? this._parent.isInserted() : false;
49703    },
49704    isAbove: function isAbove(item) {
49705      return this._getOrder(item) === -1;
49706    },
49707    isBelow: function isBelow(item) {
49708      return this._getOrder(item) === 1;
49709    },
49710    isParent: function isParent(item) {
49711      return this._parent === item;
49712    },
49713    isChild: function isChild(item) {
49714      return item && item._parent === this;
49715    },
49716    isDescendant: function isDescendant(item) {
49717      var parent = this;
49718
49719      while (parent = parent._parent) {
49720        if (parent === item) return true;
49721      }
49722
49723      return false;
49724    },
49725    isAncestor: function isAncestor(item) {
49726      return item ? item.isDescendant(this) : false;
49727    },
49728    isSibling: function isSibling(item) {
49729      return this._parent === item._parent;
49730    },
49731    isGroupedWith: function isGroupedWith(item) {
49732      var parent = this._parent;
49733
49734      while (parent) {
49735        if (parent._parent && /^(Group|Layer|CompoundPath)$/.test(parent._class) && item.isDescendant(parent)) return true;
49736        parent = parent._parent;
49737      }
49738
49739      return false;
49740    }
49741  }, Base.each(['rotate', 'scale', 'shear', 'skew'], function (key) {
49742    var rotate = key === 'rotate';
49743
49744    this[key] = function () {
49745      var args = arguments,
49746          value = (rotate ? Base : Point).read(args),
49747          center = Point.read(args, 0, {
49748        readNull: true
49749      });
49750      return this.transform(new Matrix()[key](value, center || this.getPosition(true)));
49751    };
49752  }, {
49753    translate: function translate() {
49754      var mx = new Matrix();
49755      return this.transform(mx.translate.apply(mx, arguments));
49756    },
49757    transform: function transform(matrix, _applyRecursively, _setApplyMatrix) {
49758      var _matrix = this._matrix,
49759          transformMatrix = matrix && !matrix.isIdentity(),
49760          applyMatrix = _setApplyMatrix && this._canApplyMatrix || this._applyMatrix && (transformMatrix || !_matrix.isIdentity() || _applyRecursively && this._children);
49761      if (!transformMatrix && !applyMatrix) return this;
49762
49763      if (transformMatrix) {
49764        if (!matrix.isInvertible() && _matrix.isInvertible()) _matrix._backup = _matrix.getValues();
49765
49766        _matrix.prepend(matrix, true);
49767
49768        var style = this._style,
49769            fillColor = style.getFillColor(true),
49770            strokeColor = style.getStrokeColor(true);
49771        if (fillColor) fillColor.transform(matrix);
49772        if (strokeColor) strokeColor.transform(matrix);
49773      }
49774
49775      if (applyMatrix && (applyMatrix = this._transformContent(_matrix, _applyRecursively, _setApplyMatrix))) {
49776        var pivot = this._pivot;
49777        if (pivot) _matrix._transformPoint(pivot, pivot, true);
49778
49779        _matrix.reset(true);
49780
49781        if (_setApplyMatrix && this._canApplyMatrix) this._applyMatrix = true;
49782      }
49783
49784      var bounds = this._bounds,
49785          position = this._position;
49786
49787      if (transformMatrix || applyMatrix) {
49788        this._changed(25);
49789      }
49790
49791      var decomp = transformMatrix && bounds && matrix.decompose();
49792
49793      if (decomp && decomp.skewing.isZero() && decomp.rotation % 90 === 0) {
49794        for (var key in bounds) {
49795          var cache = bounds[key];
49796
49797          if (cache.nonscaling) {
49798            delete bounds[key];
49799          } else if (applyMatrix || !cache.internal) {
49800            var rect = cache.rect;
49801
49802            matrix._transformBounds(rect, rect);
49803          }
49804        }
49805
49806        this._bounds = bounds;
49807
49808        var cached = bounds[this._getBoundsCacheKey(this._boundsOptions || {})];
49809
49810        if (cached) {
49811          this._position = this._getPositionFromBounds(cached.rect);
49812        }
49813      } else if (transformMatrix && position && this._pivot) {
49814        this._position = matrix._transformPoint(position, position);
49815      }
49816
49817      return this;
49818    },
49819    _transformContent: function _transformContent(matrix, applyRecursively, setApplyMatrix) {
49820      var children = this._children;
49821
49822      if (children) {
49823        for (var i = 0, l = children.length; i < l; i++) {
49824          children[i].transform(matrix, applyRecursively, setApplyMatrix);
49825        }
49826
49827        return true;
49828      }
49829    },
49830    globalToLocal: function globalToLocal() {
49831      return this.getGlobalMatrix(true)._inverseTransform(Point.read(arguments));
49832    },
49833    localToGlobal: function localToGlobal() {
49834      return this.getGlobalMatrix(true)._transformPoint(Point.read(arguments));
49835    },
49836    parentToLocal: function parentToLocal() {
49837      return this._matrix._inverseTransform(Point.read(arguments));
49838    },
49839    localToParent: function localToParent() {
49840      return this._matrix._transformPoint(Point.read(arguments));
49841    },
49842    fitBounds: function fitBounds(rectangle, fill) {
49843      rectangle = _Rectangle.read(arguments);
49844      var bounds = this.getBounds(),
49845          itemRatio = bounds.height / bounds.width,
49846          rectRatio = rectangle.height / rectangle.width,
49847          scale = (fill ? itemRatio > rectRatio : itemRatio < rectRatio) ? rectangle.width / bounds.width : rectangle.height / bounds.height,
49848          newBounds = new _Rectangle(new Point(), new Size(bounds.width * scale, bounds.height * scale));
49849      newBounds.setCenter(rectangle.getCenter());
49850      this.setBounds(newBounds);
49851    }
49852  }), {
49853    _setStyles: function _setStyles(ctx, param, viewMatrix) {
49854      var style = this._style,
49855          matrix = this._matrix;
49856
49857      if (style.hasFill()) {
49858        ctx.fillStyle = style.getFillColor().toCanvasStyle(ctx, matrix);
49859      }
49860
49861      if (style.hasStroke()) {
49862        ctx.strokeStyle = style.getStrokeColor().toCanvasStyle(ctx, matrix);
49863        ctx.lineWidth = style.getStrokeWidth();
49864        var strokeJoin = style.getStrokeJoin(),
49865            strokeCap = style.getStrokeCap(),
49866            miterLimit = style.getMiterLimit();
49867        if (strokeJoin) ctx.lineJoin = strokeJoin;
49868        if (strokeCap) ctx.lineCap = strokeCap;
vendor: 18,614 bytes, lines 49869-50436
49869        if (miterLimit) ctx.miterLimit = miterLimit;
49870
49871        if (paper.support.nativeDash) {
49872          var dashArray = style.getDashArray(),
49873              dashOffset = style.getDashOffset();
49874
49875          if (dashArray && dashArray.length) {
49876            if ('setLineDash' in ctx) {
49877              ctx.setLineDash(dashArray);
49878              ctx.lineDashOffset = dashOffset;
49879            } else {
49880              ctx.mozDash = dashArray;
49881              ctx.mozDashOffset = dashOffset;
49882            }
49883          }
49884        }
49885      }
49886
49887      if (style.hasShadow()) {
49888        var pixelRatio = param.pixelRatio || 1,
49889            mx = viewMatrix._shiftless().prepend(new Matrix().scale(pixelRatio, pixelRatio)),
49890            blur = mx.transform(new Point(style.getShadowBlur(), 0)),
49891            offset = mx.transform(this.getShadowOffset());
49892
49893        ctx.shadowColor = style.getShadowColor().toCanvasStyle(ctx);
49894        ctx.shadowBlur = blur.getLength();
49895        ctx.shadowOffsetX = offset.x;
49896        ctx.shadowOffsetY = offset.y;
49897      }
49898    },
49899    draw: function draw(ctx, param, parentStrokeMatrix) {
49900      var updateVersion = this._updateVersion = this._project._updateVersion;
49901      if (!this._visible || this._opacity === 0) return;
49902      var matrices = param.matrices,
49903          viewMatrix = param.viewMatrix,
49904          matrix = this._matrix,
49905          globalMatrix = matrices[matrices.length - 1].appended(matrix);
49906      if (!globalMatrix.isInvertible()) return;
49907      viewMatrix = viewMatrix ? viewMatrix.appended(globalMatrix) : globalMatrix;
49908      matrices.push(globalMatrix);
49909
49910      if (param.updateMatrix) {
49911        this._globalMatrix = globalMatrix;
49912      }
49913
49914      var blendMode = this._blendMode,
49915          opacity = this._opacity,
49916          normalBlend = blendMode === 'normal',
49917          nativeBlend = BlendMode.nativeModes[blendMode],
49918          direct = normalBlend && opacity === 1 || param.dontStart || param.clip || (nativeBlend || normalBlend && opacity < 1) && this._canComposite(),
49919          pixelRatio = param.pixelRatio || 1,
49920          mainCtx,
49921          itemOffset,
49922          prevOffset;
49923
49924      if (!direct) {
49925        var bounds = this.getStrokeBounds(viewMatrix);
49926
49927        if (!bounds.width || !bounds.height) {
49928          matrices.pop();
49929          return;
49930        }
49931
49932        prevOffset = param.offset;
49933        itemOffset = param.offset = bounds.getTopLeft().floor();
49934        mainCtx = ctx;
49935        ctx = CanvasProvider.getContext(bounds.getSize().ceil().add(1).multiply(pixelRatio));
49936        if (pixelRatio !== 1) ctx.scale(pixelRatio, pixelRatio);
49937      }
49938
49939      ctx.save();
49940      var strokeMatrix = parentStrokeMatrix ? parentStrokeMatrix.appended(matrix) : this._canScaleStroke && !this.getStrokeScaling(true) && viewMatrix,
49941          clip = !direct && param.clipItem,
49942          transform = !strokeMatrix || clip;
49943
49944      if (direct) {
49945        ctx.globalAlpha = opacity;
49946        if (nativeBlend) ctx.globalCompositeOperation = blendMode;
49947      } else if (transform) {
49948        ctx.translate(-itemOffset.x, -itemOffset.y);
49949      }
49950
49951      if (transform) {
49952        (direct ? matrix : viewMatrix).applyToContext(ctx);
49953      }
49954
49955      if (clip) {
49956        param.clipItem.draw(ctx, param.extend({
49957          clip: true
49958        }));
49959      }
49960
49961      if (strokeMatrix) {
49962        ctx.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
49963        var offset = param.offset;
49964        if (offset) ctx.translate(-offset.x, -offset.y);
49965      }
49966
49967      this._draw(ctx, param, viewMatrix, strokeMatrix);
49968
49969      ctx.restore();
49970      matrices.pop();
49971
49972      if (param.clip && !param.dontFinish) {
49973        ctx.clip(this.getFillRule());
49974      }
49975
49976      if (!direct) {
49977        BlendMode.process(blendMode, ctx, mainCtx, opacity, itemOffset.subtract(prevOffset).multiply(pixelRatio));
49978        CanvasProvider.release(ctx);
49979        param.offset = prevOffset;
49980      }
49981    },
49982    _isUpdated: function _isUpdated(updateVersion) {
49983      var parent = this._parent;
49984      if (parent instanceof CompoundPath) return parent._isUpdated(updateVersion);
49985      var updated = this._updateVersion === updateVersion;
49986
49987      if (!updated && parent && parent._visible && parent._isUpdated(updateVersion)) {
49988        this._updateVersion = updateVersion;
49989        updated = true;
49990      }
49991
49992      return updated;
49993    },
49994    _drawSelection: function _drawSelection(ctx, matrix, size, selectionItems, updateVersion) {
49995      var selection = this._selection,
49996          itemSelected = selection & 1,
49997          boundsSelected = selection & 2 || itemSelected && this._selectBounds,
49998          positionSelected = selection & 4;
49999      if (!this._drawSelected) itemSelected = false;
50000
50001      if ((itemSelected || boundsSelected || positionSelected) && this._isUpdated(updateVersion)) {
50002        var layer,
50003            color = this.getSelectedColor(true) || (layer = this.getLayer()) && layer.getSelectedColor(true),
50004            mx = matrix.appended(this.getGlobalMatrix(true)),
50005            half = size / 2;
50006        ctx.strokeStyle = ctx.fillStyle = color ? color.toCanvasStyle(ctx) : '#009dec';
50007        if (itemSelected) this._drawSelected(ctx, mx, selectionItems);
50008
50009        if (positionSelected) {
50010          var pos = this.getPosition(true),
50011              parent = this._parent,
50012              point = parent ? parent.localToGlobal(pos) : pos,
50013              x = point.x,
50014              y = point.y;
50015          ctx.beginPath();
50016          ctx.arc(x, y, half, 0, Math.PI * 2, true);
50017          ctx.stroke();
50018          var deltas = [[0, -1], [1, 0], [0, 1], [-1, 0]],
50019              start = half,
50020              end = size + 1;
50021
50022          for (var i = 0; i < 4; i++) {
50023            var delta = deltas[i],
50024                dx = delta[0],
50025                dy = delta[1];
50026            ctx.moveTo(x + dx * start, y + dy * start);
50027            ctx.lineTo(x + dx * end, y + dy * end);
50028            ctx.stroke();
50029          }
50030        }
50031
50032        if (boundsSelected) {
50033          var coords = mx._transformCorners(this.getInternalBounds());
50034
50035          ctx.beginPath();
50036
50037          for (var i = 0; i < 8; i++) {
50038            ctx[!i ? 'moveTo' : 'lineTo'](coords[i], coords[++i]);
50039          }
50040
50041          ctx.closePath();
50042          ctx.stroke();
50043
50044          for (var i = 0; i < 8; i++) {
50045            ctx.fillRect(coords[i] - half, coords[++i] - half, size, size);
50046          }
50047        }
50048      }
50049    },
50050    _canComposite: function _canComposite() {
50051      return false;
50052    }
50053  }, Base.each(['down', 'drag', 'up', 'move'], function (key) {
50054    this['removeOn' + Base.capitalize(key)] = function () {
50055      var hash = {};
50056      hash[key] = true;
50057      return this.removeOn(hash);
50058    };
50059  }, {
50060    removeOn: function removeOn(obj) {
50061      for (var name in obj) {
50062        if (obj[name]) {
50063          var key = 'mouse' + name,
50064              project = this._project,
50065              sets = project._removeSets = project._removeSets || {};
50066          sets[key] = sets[key] || {};
50067          sets[key][this._id] = this;
50068        }
50069      }
50070
50071      return this;
50072    }
50073  }), {
50074    tween: function tween(from, to, options) {
50075      if (!options) {
50076        options = to;
50077        to = from;
50078        from = null;
50079
50080        if (!options) {
50081          options = to;
50082          to = null;
50083        }
50084      }
50085
50086      var easing = options && options.easing,
50087          start = options && options.start,
50088          duration = options != null && (typeof options === 'number' ? options : options.duration),
50089          tween = new Tween(this, from, to, duration, easing, start);
50090
50091      function onFrame(event) {
50092        tween._handleFrame(event.time * 1000);
50093
50094        if (!tween.running) {
50095          this.off('frame', onFrame);
50096        }
50097      }
50098
50099      if (duration) {
50100        this.on('frame', onFrame);
50101      }
50102
50103      return tween;
50104    },
50105    tweenTo: function tweenTo(to, options) {
50106      return this.tween(null, to, options);
50107    },
50108    tweenFrom: function tweenFrom(from, options) {
50109      return this.tween(from, null, options);
50110    }
50111  });
50112  var Group = Item.extend({
50113    _class: 'Group',
50114    _selectBounds: false,
50115    _selectChildren: true,
50116    _serializeFields: {
50117      children: []
50118    },
50119    initialize: function Group(arg) {
50120      this._children = [];
50121      this._namedChildren = {};
50122      if (!this._initialize(arg)) this.addChildren(Array.isArray(arg) ? arg : arguments);
50123    },
50124    _changed: function _changed(flags) {
50125      _changed.base.call(this, flags);
50126
50127      if (flags & 2050) {
50128        this._clipItem = undefined;
50129      }
50130    },
50131    _getClipItem: function _getClipItem() {
50132      var clipItem = this._clipItem;
50133
50134      if (clipItem === undefined) {
50135        clipItem = null;
50136        var children = this._children;
50137
50138        for (var i = 0, l = children.length; i < l; i++) {
50139          if (children[i]._clipMask) {
50140            clipItem = children[i];
50141            break;
50142          }
50143        }
50144
50145        this._clipItem = clipItem;
50146      }
50147
50148      return clipItem;
50149    },
50150    isClipped: function isClipped() {
50151      return !!this._getClipItem();
50152    },
50153    setClipped: function setClipped(clipped) {
50154      var child = this.getFirstChild();
50155      if (child) child.setClipMask(clipped);
50156    },
50157    _getBounds: function _getBounds(matrix, options) {
50158      var clipItem = this._getClipItem();
50159
50160      return clipItem ? clipItem._getCachedBounds(clipItem._matrix.prepended(matrix), Base.set({}, options, {
50161        stroke: false
50162      })) : _getBounds.base.call(this, matrix, options);
50163    },
50164    _hitTestChildren: function _hitTestChildren(point, options, viewMatrix) {
50165      var clipItem = this._getClipItem();
50166
50167      return (!clipItem || clipItem.contains(point)) && _hitTestChildren.base.call(this, point, options, viewMatrix, clipItem);
50168    },
50169    _draw: function _draw(ctx, param) {
50170      var clip = param.clip,
50171          clipItem = !clip && this._getClipItem();
50172
50173      param = param.extend({
50174        clipItem: clipItem,
50175        clip: false
50176      });
50177
50178      if (clip) {
50179        ctx.beginPath();
50180        param.dontStart = param.dontFinish = true;
50181      } else if (clipItem) {
50182        clipItem.draw(ctx, param.extend({
50183          clip: true
50184        }));
50185      }
50186
50187      var children = this._children;
50188
50189      for (var i = 0, l = children.length; i < l; i++) {
50190        var item = children[i];
50191        if (item !== clipItem) item.draw(ctx, param);
50192      }
50193    }
50194  });
50195  var Layer = Group.extend({
50196    _class: 'Layer',
50197    initialize: function Layer() {
50198      Group.apply(this, arguments);
50199    },
50200    _getOwner: function _getOwner() {
50201      return this._parent || this._index != null && this._project;
50202    },
50203    isInserted: function isInserted() {
50204      return this._parent ? isInserted.base.call(this) : this._index != null;
50205    },
50206    activate: function activate() {
50207      this._project._activeLayer = this;
50208    },
50209    _hitTestSelf: function _hitTestSelf() {}
50210  });
50211  var Shape = Item.extend({
50212    _class: 'Shape',
50213    _applyMatrix: false,
50214    _canApplyMatrix: false,
50215    _canScaleStroke: true,
50216    _serializeFields: {
50217      type: null,
50218      size: null,
50219      radius: null
50220    },
50221    initialize: function Shape(props, point) {
50222      this._initialize(props, point);
50223    },
50224    _equals: function _equals(item) {
50225      return this._type === item._type && this._size.equals(item._size) && Base.equals(this._radius, item._radius);
50226    },
50227    copyContent: function copyContent(source) {
50228      this.setType(source._type);
50229      this.setSize(source._size);
50230      this.setRadius(source._radius);
50231    },
50232    getType: function getType() {
50233      return this._type;
50234    },
50235    setType: function setType(type) {
50236      this._type = type;
50237    },
50238    getShape: '#getType',
50239    setShape: '#setType',
50240    getSize: function getSize() {
50241      var size = this._size;
50242      return new LinkedSize(size.width, size.height, this, 'setSize');
50243    },
50244    setSize: function setSize() {
50245      var size = Size.read(arguments);
50246
50247      if (!this._size) {
50248        this._size = size.clone();
50249      } else if (!this._size.equals(size)) {
50250        var type = this._type,
50251            width = size.width,
50252            height = size.height;
50253
50254        if (type === 'rectangle') {
50255          this._radius.set(Size.min(this._radius, size.divide(2).abs()));
50256        } else if (type === 'circle') {
50257          width = height = (width + height) / 2;
50258          this._radius = width / 2;
50259        } else if (type === 'ellipse') {
50260          this._radius._set(width / 2, height / 2);
50261        }
50262
50263        this._size._set(width, height);
50264
50265        this._changed(9);
50266      }
50267    },
50268    getRadius: function getRadius() {
50269      var rad = this._radius;
50270      return this._type === 'circle' ? rad : new LinkedSize(rad.width, rad.height, this, 'setRadius');
50271    },
50272    setRadius: function setRadius(radius) {
50273      var type = this._type;
50274
50275      if (type === 'circle') {
50276        if (radius === this._radius) return;
50277        var size = radius * 2;
50278        this._radius = radius;
50279
50280        this._size._set(size, size);
50281      } else {
50282        radius = Size.read(arguments);
50283
50284        if (!this._radius) {
50285          this._radius = radius.clone();
50286        } else {
50287          if (this._radius.equals(radius)) return;
50288
50289          this._radius.set(radius);
50290
50291          if (type === 'rectangle') {
50292            var size = Size.max(this._size, radius.multiply(2));
50293
50294            this._size.set(size);
50295          } else if (type === 'ellipse') {
50296            this._size._set(radius.width * 2, radius.height * 2);
50297          }
50298        }
50299      }
50300
50301      this._changed(9);
50302    },
50303    isEmpty: function isEmpty() {
50304      return false;
50305    },
50306    toPath: function toPath(insert) {
50307      var path = new Path[Base.capitalize(this._type)]({
50308        center: new Point(),
50309        size: this._size,
50310        radius: this._radius,
50311        insert: false
50312      });
50313      path.copyAttributes(this);
50314      if (paper.settings.applyMatrix) path.setApplyMatrix(true);
50315      if (insert === undefined || insert) path.insertAbove(this);
50316      return path;
50317    },
50318    toShape: '#clone',
50319    _asPathItem: function _asPathItem() {
50320      return this.toPath(false);
50321    },
50322    _draw: function _draw(ctx, param, viewMatrix, strokeMatrix) {
50323      var style = this._style,
50324          hasFill = style.hasFill(),
50325          hasStroke = style.hasStroke(),
50326          dontPaint = param.dontFinish || param.clip,
50327          untransformed = !strokeMatrix;
50328
50329      if (hasFill || hasStroke || dontPaint) {
50330        var type = this._type,
50331            radius = this._radius,
50332            isCircle = type === 'circle';
50333        if (!param.dontStart) ctx.beginPath();
50334
50335        if (untransformed && isCircle) {
50336          ctx.arc(0, 0, radius, 0, Math.PI * 2, true);
50337        } else {
50338          var rx = isCircle ? radius : radius.width,
50339              ry = isCircle ? radius : radius.height,
50340              size = this._size,
50341              width = size.width,
50342              height = size.height;
50343
50344          if (untransformed && type === 'rectangle' && rx === 0 && ry === 0) {
50345            ctx.rect(-width / 2, -height / 2, width, height);
50346          } else {
50347            var x = width / 2,
50348                y = height / 2,
50349                kappa = 1 - 0.5522847498307936,
50350                cx = rx * kappa,
50351                cy = ry * kappa,
50352                c = [-x, -y + ry, -x, -y + cy, -x + cx, -y, -x + rx, -y, x - rx, -y, x - cx, -y, x, -y + cy, x, -y + ry, x, y - ry, x, y - cy, x - cx, y, x - rx, y, -x + rx, y, -x + cx, y, -x, y - cy, -x, y - ry];
50353            if (strokeMatrix) strokeMatrix.transform(c, c, 32);
50354            ctx.moveTo(c[0], c[1]);
50355            ctx.bezierCurveTo(c[2], c[3], c[4], c[5], c[6], c[7]);
50356            if (x !== rx) ctx.lineTo(c[8], c[9]);
50357            ctx.bezierCurveTo(c[10], c[11], c[12], c[13], c[14], c[15]);
50358            if (y !== ry) ctx.lineTo(c[16], c[17]);
50359            ctx.bezierCurveTo(c[18], c[19], c[20], c[21], c[22], c[23]);
50360            if (x !== rx) ctx.lineTo(c[24], c[25]);
50361            ctx.bezierCurveTo(c[26], c[27], c[28], c[29], c[30], c[31]);
50362          }
50363        }
50364
50365        ctx.closePath();
50366      }
50367
50368      if (!dontPaint && (hasFill || hasStroke)) {
50369        this._setStyles(ctx, param, viewMatrix);
50370
50371        if (hasFill) {
50372          ctx.fill(style.getFillRule());
50373          ctx.shadowColor = 'rgba(0,0,0,0)';
50374        }
50375
50376        if (hasStroke) ctx.stroke();
50377      }
50378    },
50379    _canComposite: function _canComposite() {
50380      return !(this.hasFill() && this.hasStroke());
50381    },
50382    _getBounds: function _getBounds(matrix, options) {
50383      var rect = new _Rectangle(this._size).setCenter(0, 0),
50384          style = this._style,
50385          strokeWidth = options.stroke && style.hasStroke() && style.getStrokeWidth();
50386      if (matrix) rect = matrix._transformBounds(rect);
50387      return strokeWidth ? rect.expand(Path._getStrokePadding(strokeWidth, this._getStrokeMatrix(matrix, options))) : rect;
50388    }
50389  }, new function () {
50390    function getCornerCenter(that, point, expand) {
50391      var radius = that._radius;
50392
50393      if (!radius.isZero()) {
50394        var halfSize = that._size.divide(2);
50395
50396        for (var q = 1; q <= 4; q++) {
50397          var dir = new Point(q > 1 && q < 4 ? -1 : 1, q > 2 ? -1 : 1),
50398              corner = dir.multiply(halfSize),
50399              center = corner.subtract(dir.multiply(radius)),
50400              rect = new _Rectangle(expand ? corner.add(dir.multiply(expand)) : corner, center);
50401          if (rect.contains(point)) return {
50402            point: center,
50403            quadrant: q
50404          };
50405        }
50406      }
50407    }
50408
50409    function isOnEllipseStroke(point, radius, padding, quadrant) {
50410      var vector = point.divide(radius);
50411      return (!quadrant || vector.isInQuadrant(quadrant)) && vector.subtract(vector.normalize()).multiply(radius).divide(padding).length <= 1;
50412    }
50413
50414    return {
50415      _contains: function _contains(point) {
50416        if (this._type === 'rectangle') {
50417          var center = getCornerCenter(this, point);
50418          return center ? point.subtract(center.point).divide(this._radius).getLength() <= 1 : _contains.base.call(this, point);
50419        } else {
50420          return point.divide(this.size).getLength() <= 0.5;
50421        }
50422      },
50423      _hitTestSelf: function _hitTestSelf(point, options, viewMatrix, strokeMatrix) {
50424        var hit = false,
50425            style = this._style,
50426            hitStroke = options.stroke && style.hasStroke(),
50427            hitFill = options.fill && style.hasFill();
50428
50429        if (hitStroke || hitFill) {
50430          var type = this._type,
50431              radius = this._radius,
50432              strokeRadius = hitStroke ? style.getStrokeWidth() / 2 : 0,
50433              strokePadding = options._tolerancePadding.add(Path._getStrokePadding(strokeRadius, !style.getStrokeScaling() && strokeMatrix));
50434
50435          if (type === 'rectangle') {
50436            var padding = strokePadding.multiply(2),
50437                center = getCornerCenter(this, point, padding);
50438
50439            if (center) {
50440              hit = isOnEllipseStroke(point.subtract(center.point), radius, strokePadding, center.quadrant);
50441            } else {
50442              var rect = new _Rectangle(this._size).setCenter(0, 0),
50443                  outer = rect.expand(padding),
50444                  inner = rect.expand(padding.negate());
50445              hit = outer._containsPoint(point) && !inner._containsPoint(point);
50446            }
50447          } else {
50448            hit = isOnEllipseStroke(point, radius, strokePadding);
50449          }
50450        }
50451
50452        return hit ? new HitResult(hitStroke ? 'stroke' : 'fill', this) : _hitTestSelf.base.apply(this, arguments);
50453      }
50454    };
50455  }(), {
50456    statics: new function () {
50457      function createShape(type, point, size, radius, args) {
50458        var item = Base.create(Shape.prototype);
50459        item._type = type;
50460        item._size = size;
50461        item._radius = radius;
50462
50463        item._initialize(Base.getNamed(args), point);
50464
50465        return item;
50466      }
50467
50468      return {
50469        Circle: function Circle() {
50470          var args = arguments,
50471              center = Point.readNamed(args, 'center'),
50472              radius = Base.readNamed(args, 'radius');
50473          return createShape('circle', center, new Size(radius * 2), radius, args);
50474        },
50475        Rectangle: function Rectangle() {
50476          var args = arguments,
50477              rect = _Rectangle.readNamed(args, 'rectangle'),
50478              radius = Size.min(Size.readNamed(args, 'radius'), rect.getSize(true).divide(2));
50479
50480          return createShape('rectangle', rect.getCenter(true), rect.getSize(true), radius, args);
50481        },
50482        Ellipse: function Ellipse() {
50483          var args = arguments,
50484              ellipse = Shape._readEllipse(args),
50485              radius = ellipse.radius;
50486
50487          return createShape('ellipse', ellipse.center, radius.multiply(2), radius, args);
50488        },
50489        _readEllipse: function _readEllipse(args) {
50490          var center, radius;
50491
50492          if (Base.hasNamed(args, 'radius')) {
50493            center = Point.readNamed(args, 'center');
50494            radius = Size.readNamed(args, 'radius');
50495          } else {
50496            var rect = _Rectangle.readNamed(args, 'rectangle');
50497
50498            center = rect.getCenter(true);
50499            radius = rect.getSize(true).divide(2);
50500          }
50501
50502          return {
50503            center: center,
50504            radius: radius
50505          };
50506        }
50507      };
50508    }()
50509  });
50510  var Raster = Item.extend({
50511    _class: 'Raster',
50512    _applyMatrix: false,
50513    _canApplyMatrix: false,
50514    _boundsOptions: {
50515      stroke: false,
50516      handle: false
50517    },
50518    _serializeFields: {
50519      crossOrigin: null,
50520      source: null
50521    },
50522    _prioritize: ['crossOrigin'],
50523    _smoothing: true,
50524    beans: true,
50525    initialize: function Raster(source, position) {
50526      if (!this._initialize(source, position !== undefined && Point.read(arguments))) {
50527        var image,
50528            type = _typeof(source),
50529            object = type === 'string' ? document.getElementById(source) : type === 'object' ? source : null;
50530
50531        if (object && object !== Item.NO_INSERT) {
50532          if (object.getContent || object.naturalHeight != null) {
50533            image = object;
50534          } else if (object) {
50535            var size = Size.read(arguments);
50536
50537            if (!size.isZero()) {
50538              image = CanvasProvider.getCanvas(size);
50539            }
50540          }
50541        }
50542
50543        if (image) {
50544          this.setImage(image);
50545        } else {
50546          this.setSource(source);
50547        }
50548      }
50549
50550      if (!this._size) {
50551        this._size = new Size();
50552        this._loaded = false;
50553      }
50554    },
50555    _equals: function _equals(item) {
50556      return this.getSource() === item.getSource();
50557    },
50558    copyContent: function copyContent(source) {
50559      var image = source._image,
50560          canvas = source._canvas;
50561
50562      if (image) {
50563        this._setImage(image);
50564      } else if (canvas) {
50565        var copyCanvas = CanvasProvider.getCanvas(source._size);
50566        copyCanvas.getContext('2d').drawImage(canvas, 0, 0);
50567
50568        this._setImage(copyCanvas);
50569      }
50570
50571      this._crossOrigin = source._crossOrigin;
50572    },
50573    getSize: function getSize() {
50574      var size = this._size;
50575      return new LinkedSize(size ? size.width : 0, size ? size.height : 0, this, 'setSize');
50576    },
50577    setSize: function setSize() {
50578      var size = Size.read(arguments);
50579
50580      if (!size.equals(this._size)) {
50581        if (size.width > 0 && size.height > 0) {
50582          var element = this.getElement();
50583
50584          this._setImage(CanvasProvider.getCanvas(size));
50585
50586          if (element) this.getContext(true).drawImage(element, 0, 0, size.width, size.height);
50587        } else {
50588          if (this._canvas) CanvasProvider.release(this._canvas);
50589          this._size = size.clone();
50590        }
50591      }
50592    },
50593    getWidth: function getWidth() {
50594      return this._size ? this._size.width : 0;
50595    },
50596    setWidth: function setWidth(width) {
50597      this.setSize(width, this.getHeight());
50598    },
50599    getHeight: function getHeight() {
50600      return this._size ? this._size.height : 0;
50601    },
50602    setHeight: function setHeight(height) {
50603      this.setSize(this.getWidth(), height);
50604    },
50605    getLoaded: function getLoaded() {
50606      return this._loaded;
50607    },
50608    isEmpty: function isEmpty() {
50609      var size = this._size;
50610      return !size || size.width === 0 && size.height === 0;
50611    },
50612    getResolution: function getResolution() {
50613      var matrix = this._matrix,
50614          orig = new Point(0, 0).transform(matrix),
50615          u = new Point(1, 0).transform(matrix).subtract(orig),
50616          v = new Point(0, 1).transform(matrix).subtract(orig);
50617      return new Size(72 / u.getLength(), 72 / v.getLength());
50618    },
50619    getPpi: '#getResolution',
50620    getImage: function getImage() {
50621      return this._image;
50622    },
50623    setImage: function setImage(image) {
50624      var that = this;
50625
50626      function emit(event) {
50627        var view = that.getView(),
50628            type = event && event.type || 'load';
50629
50630        if (view && that.responds(type)) {
50631          paper = view._scope;
50632          that.emit(type, new Event(event));
50633        }
50634      }
50635
50636      this._setImage(image);
50637
50638      if (this._loaded) {
50639        setTimeout(emit, 0);
50640      } else if (image) {
50641        DomEvent.add(image, {
50642          load: function load(event) {
50643            that._setImage(image);
50644
50645            emit(event);
50646          },
50647          error: emit
50648        });
50649      }
50650    },
50651    _setImage: function _setImage(image) {
50652      if (this._canvas) CanvasProvider.release(this._canvas);
50653
50654      if (image && image.getContext) {
50655        this._image = null;
50656        this._canvas = image;
50657        this._loaded = true;
50658      } else {
50659        this._image = image;
50660        this._canvas = null;
50661        this._loaded = !!(image && image.src && image.complete);
50662      }
50663
50664      this._size = new Size(image ? image.naturalWidth || image.width : 0, image ? image.naturalHeight || image.height : 0);
50665      this._context = null;
50666
50667      this._changed(1033);
50668    },
50669    getCanvas: function getCanvas() {
50670      if (!this._canvas) {
50671        var ctx = CanvasProvider.getContext(this._size);
50672
50673        try {
50674          if (this._image) ctx.drawImage(this._image, 0, 0);
50675          this._canvas = ctx.canvas;
50676        } catch (e) {
50677          CanvasProvider.release(ctx);
50678        }
50679      }
50680
50681      return this._canvas;
50682    },
50683    setCanvas: '#setImage',
50684    getContext: function getContext(_change) {
50685      if (!this._context) this._context = this.getCanvas().getContext('2d');
50686
50687      if (_change) {
50688        this._image = null;
50689
50690        this._changed(1025);
50691      }
50692
50693      return this._context;
50694    },
50695    setContext: function setContext(context) {
50696      this._context = context;
50697    },
50698    getSource: function getSource() {
50699      var image = this._image;
50700      return image && image.src || this.toDataURL();
50701    },
50702    setSource: function setSource(src) {
50703      var image = new self.Image(),
50704          crossOrigin = this._crossOrigin;
50705      if (crossOrigin) image.crossOrigin = crossOrigin;
50706      if (src) image.src = src;
50707      this.setImage(image);
50708    },
50709    getCrossOrigin: function getCrossOrigin() {
50710      var image = this._image;
50711      return image && image.crossOrigin || this._crossOrigin || '';
50712    },
50713    setCrossOrigin: function setCrossOrigin(crossOrigin) {
50714      this._crossOrigin = crossOrigin;
50715      var image = this._image;
50716      if (image) image.crossOrigin = crossOrigin;
50717    },
50718    getSmoothing: function getSmoothing() {
50719      return this._smoothing;
50720    },
50721    setSmoothing: function setSmoothing(smoothing) {
50722      this._smoothing = smoothing;
50723
50724      this._changed(257);
50725    },
50726    getElement: function getElement() {
50727      return this._canvas || this._loaded && this._image;
50728    }
50729  }, {
50730    beans: false,
50731    getSubCanvas: function getSubCanvas() {
50732      var rect = _Rectangle.read(arguments),
50733          ctx = CanvasProvider.getContext(rect.getSize());
50734
50735      ctx.drawImage(this.getCanvas(), rect.x, rect.y, rect.width, rect.height, 0, 0, rect.width, rect.height);
50736      return ctx.canvas;
50737    },
50738    getSubRaster: function getSubRaster() {
50739      var rect = _Rectangle.read(arguments),
50740          raster = new Raster(Item.NO_INSERT);
50741
50742      raster._setImage(this.getSubCanvas(rect));
50743
50744      raster.translate(rect.getCenter().subtract(this.getSize().divide(2)));
50745
50746      raster._matrix.prepend(this._matrix);
50747
50748      raster.insertAbove(this);
50749      return raster;
50750    },
50751    toDataURL: function toDataURL() {
50752      var image = this._image,
50753          src = image && image.src;
50754      if (/^data:/.test(src)) return src;
50755      var canvas = this.getCanvas();
50756      return canvas ? canvas.toDataURL.apply(canvas, arguments) : null;
50757    },
50758    drawImage: function drawImage(image) {
50759      var point = Point.read(arguments, 1);
50760      this.getContext(true).drawImage(image, point.x, point.y);
50761    },
50762    getAverageColor: function getAverageColor(object) {
50763      var bounds, path;
50764
50765      if (!object) {
50766        bounds = this.getBounds();
50767      } else if (object instanceof PathItem) {
50768        path = object;
50769        bounds = object.getBounds();
50770      } else if (_typeof(object) === 'object') {
50771        if ('width' in object) {
50772          bounds = new _Rectangle(object);
50773        } else if ('x' in object) {
50774          bounds = new _Rectangle(object.x - 0.5, object.y - 0.5, 1, 1);
50775        }
50776      }
50777
50778      if (!bounds) return null;
50779      var sampleSize = 32,
50780          width = Math.min(bounds.width, sampleSize),
50781          height = Math.min(bounds.height, sampleSize);
50782      var ctx = Raster._sampleContext;
50783
50784      if (!ctx) {
50785        ctx = Raster._sampleContext = CanvasProvider.getContext(new Size(sampleSize));
50786      } else {
50787        ctx.clearRect(0, 0, sampleSize + 1, sampleSize + 1);
50788      }
50789
50790      ctx.save();
50791      var matrix = new Matrix().scale(width / bounds.width, height / bounds.height).translate(-bounds.x, -bounds.y);
50792      matrix.applyToContext(ctx);
50793      if (path) path.draw(ctx, new Base({
50794        clip: true,
50795        matrices: [matrix]
50796      }));
50797
50798      this._matrix.applyToContext(ctx);
50799
50800      var element = this.getElement(),
50801          size = this._size;
50802      if (element) ctx.drawImage(element, -size.width / 2, -size.height / 2);
50803      ctx.restore();
50804      var pixels = ctx.getImageData(0.5, 0.5, Math.ceil(width), Math.ceil(height)).data,
50805          channels = [0, 0, 0],
50806          total = 0;
50807
50808      for (var i = 0, l = pixels.length; i < l; i += 4) {
50809        var alpha = pixels[i + 3];
50810        total += alpha;
50811        alpha /= 255;
50812        channels[0] += pixels[i] * alpha;
50813        channels[1] += pixels[i + 1] * alpha;
50814        channels[2] += pixels[i + 2] * alpha;
50815      }
50816
50817      for (var i = 0; i < 3; i++) {
50818        channels[i] /= total;
50819      }
50820
50821      return total ? Color.read(channels) : null;
50822    },
50823    getPixel: function getPixel() {
50824      var point = Point.read(arguments);
50825      var data = this.getContext().getImageData(point.x, point.y, 1, 1).data;
50826      return new Color('rgb', [data[0] / 255, data[1] / 255, data[2] / 255], data[3] / 255);
50827    },
50828    setPixel: function setPixel() {
50829      var args = arguments,
50830          point = Point.read(args),
50831          color = Color.read(args),
50832          components = color._convert('rgb'),
50833          alpha = color._alpha,
50834          ctx = this.getContext(true),
50835          imageData = ctx.createImageData(1, 1),
50836          data = imageData.data;
50837
50838      data[0] = components[0] * 255;
50839      data[1] = components[1] * 255;
50840      data[2] = components[2] * 255;
50841      data[3] = alpha != null ? alpha * 255 : 255;
50842      ctx.putImageData(imageData, point.x, point.y);
50843    },
50844    clear: function clear() {
50845      var size = this._size;
50846      this.getContext(true).clearRect(0, 0, size.width + 1, size.height + 1);
50847    },
50848    createImageData: function createImageData() {
50849      var size = Size.read(arguments);
50850      return this.getContext().createImageData(size.width, size.height);
50851    },
50852    getImageData: function getImageData() {
50853      var rect = _Rectangle.read(arguments);
50854
50855      if (rect.isEmpty()) rect = new _Rectangle(this._size);
50856      return this.getContext().getImageData(rect.x, rect.y, rect.width, rect.height);
50857    },
50858    setImageData: function setImageData(data) {
50859      var point = Point.read(arguments, 1);
50860      this.getContext(true).putImageData(data, point.x, point.y);
50861    },
50862    _getBounds: function _getBounds(matrix, options) {
50863      var rect = new _Rectangle(this._size).setCenter(0, 0);
50864      return matrix ? matrix._transformBounds(rect) : rect;
50865    },
50866    _hitTestSelf: function _hitTestSelf(point) {
50867      if (this._contains(point)) {
50868        var that = this;
50869        return new HitResult('pixel', that, {
50870          offset: point.add(that._size.divide(2)).round(),
50871          color: {
50872            get: function get() {
50873              return that.getPixel(this.offset);
50874            }
50875          }
50876        });
50877      }
50878    },
50879    _draw: function _draw(ctx, param, viewMatrix) {
50880      var element = this.getElement();
50881
50882      if (element && element.width > 0 && element.height > 0) {
50883        ctx.globalAlpha = this._opacity;
50884
50885        this._setStyles(ctx, param, viewMatrix);
50886
50887        DomElement.setPrefixed(ctx, 'imageSmoothingEnabled', this._smoothing);
50888        ctx.drawImage(element, -this._size.width / 2, -this._size.height / 2);
50889      }
50890    },
50891    _canComposite: function _canComposite() {
50892      return true;
50893    }
50894  });
50895  var SymbolItem = Item.extend({
50896    _class: 'SymbolItem',
50897    _applyMatrix: false,
50898    _canApplyMatrix: false,
50899    _boundsOptions: {
50900      stroke: true
50901    },
50902    _serializeFields: {
50903      symbol: null
50904    },
50905    initialize: function SymbolItem(arg0, arg1) {
50906      if (!this._initialize(arg0, arg1 !== undefined && Point.read(arguments, 1))) this.setDefinition(arg0 instanceof SymbolDefinition ? arg0 : new SymbolDefinition(arg0));
50907    },
50908    _equals: function _equals(item) {
50909      return this._definition === item._definition;
50910    },
50911    copyContent: function copyContent(source) {
50912      this.setDefinition(source._definition);
50913    },
50914    getDefinition: function getDefinition() {
50915      return this._definition;
50916    },
50917    setDefinition: function setDefinition(definition) {
50918      this._definition = definition;
50919
50920      this._changed(9);
50921    },
50922    getSymbol: '#getDefinition',
50923    setSymbol: '#setDefinition',
50924    isEmpty: function isEmpty() {
50925      return this._definition._item.isEmpty();
50926    },
50927    _getBounds: function _getBounds(matrix, options) {
50928      var item = this._definition._item;
50929      return item._getCachedBounds(item._matrix.prepended(matrix), options);
50930    },
50931    _hitTestSelf: function _hitTestSelf(point, options, viewMatrix) {
50932      var opts = options.extend({
50933        all: false
50934      });
50935
50936      var res = this._definition._item._hitTest(point, opts, viewMatrix);
50937
50938      if (res) res.item = this;
50939      return res;
50940    },
50941    _draw: function _draw(ctx, param) {
50942      this._definition._item.draw(ctx, param);
50943    }
50944  });
50945  var SymbolDefinition = Base.extend({
50946    _class: 'SymbolDefinition',
50947    initialize: function SymbolDefinition(item, dontCenter) {
50948      this._id = UID.get();
50949      this.project = paper.project;
50950      if (item) this.setItem(item, dontCenter);
50951    },
50952    _serialize: function _serialize(options, dictionary) {
50953      return dictionary.add(this, function () {
50954        return Base.serialize([this._class, this._item], options, false, dictionary);
50955      });
50956    },
50957    _changed: function _changed(flags) {
50958      if (flags & 8) Item._clearBoundsCache(this);
50959      if (flags & 1) this.project._changed(flags);
50960    },
50961    getItem: function getItem() {
50962      return this._item;
50963    },
50964    setItem: function setItem(item, _dontCenter) {
50965      if (item._symbol) item = item.clone();
50966      if (this._item) this._item._symbol = null;
50967      this._item = item;
50968      item.remove();
50969      item.setSelected(false);
50970      if (!_dontCenter) item.setPosition(new Point());
50971      item._symbol = this;
50972
50973      this._changed(9);
50974    },
50975    getDefinition: '#getItem',
50976    setDefinition: '#setItem',
50977    place: function place(position) {
50978      return new SymbolItem(this, position);
50979    },
50980    clone: function clone() {
50981      return new SymbolDefinition(this._item.clone(false));
50982    },
50983    equals: function equals(symbol) {
50984      return symbol === this || symbol && this._item.equals(symbol._item) || false;
50985    }
50986  });
50987  var HitResult = Base.extend({
50988    _class: 'HitResult',
50989    initialize: function HitResult(type, item, values) {
50990      this.type = type;
50991      this.item = item;
50992      if (values) this.inject(values);
50993    },
50994    statics: {
50995      getOptions: function getOptions(args) {
50996        var options = args && Base.read(args);
50997        return new Base({
50998          type: null,
50999          tolerance: paper.settings.hitTolerance,
51000          fill: !options,
51001          stroke: !options,
51002          segments: !options,
51003          handles: false,
51004          ends: false,
51005          position: false,
51006          center: false,
51007          bounds: false,
51008          guides: false,
51009          selected: false
51010        }, options);
51011      }
51012    }
51013  });
51014  var Segment = Base.extend({
51015    _class: 'Segment',
51016    beans: true,
51017    _selection: 0,
51018    initialize: function Segment(arg0, arg1, arg2, arg3, arg4, arg5) {
51019      var count = arguments.length,
51020          point,
51021          handleIn,
51022          handleOut,
51023          selection;
51024
51025      if (count > 0) {
51026        if (arg0 == null || _typeof(arg0) === 'object') {
51027          if (count === 1 && arg0 && 'point' in arg0) {
51028            point = arg0.point;
51029            handleIn = arg0.handleIn;
51030            handleOut = arg0.handleOut;
51031            selection = arg0.selection;
51032          } else {
51033            point = arg0;
51034            handleIn = arg1;
51035            handleOut = arg2;
51036            selection = arg3;
51037          }
51038        } else {
51039          point = [arg0, arg1];
51040          handleIn = arg2 !== undefined ? [arg2, arg3] : null;
51041          handleOut = arg4 !== undefined ? [arg4, arg5] : null;
51042        }
51043      }
51044
51045      new SegmentPoint(point, this, '_point');
51046      new SegmentPoint(handleIn, this, '_handleIn');
51047      new SegmentPoint(handleOut, this, '_handleOut');
51048      if (selection) this.setSelection(selection);
51049    },
51050    _serialize: function _serialize(options, dictionary) {
51051      var point = this._point,
51052          selection = this._selection,
51053          obj = selection || this.hasHandles() ? [point, this._handleIn, this._handleOut] : point;
51054      if (selection) obj.push(selection);
51055      return Base.serialize(obj, options, true, dictionary);
51056    },
51057    _changed: function _changed(point) {
51058      var path = this._path;
51059      if (!path) return;
51060      var curves = path._curves,
51061          index = this._index,
51062          curve;
51063
51064      if (curves) {
51065        if ((!point || point === this._point || point === this._handleIn) && (curve = index > 0 ? curves[index - 1] : path._closed ? curves[curves.length - 1] : null)) curve._changed();
51066        if ((!point || point === this._point || point === this._handleOut) && (curve = curves[index])) curve._changed();
51067      }
51068
51069      path._changed(41);
51070    },
51071    getPoint: function getPoint() {
51072      return this._point;
51073    },
51074    setPoint: function setPoint() {
51075      this._point.set(Point.read(arguments));
51076    },
51077    getHandleIn: function getHandleIn() {
51078      return this._handleIn;
51079    },
51080    setHandleIn: function setHandleIn() {
51081      this._handleIn.set(Point.read(arguments));
51082    },
51083    getHandleOut: function getHandleOut() {
51084      return this._handleOut;
51085    },
51086    setHandleOut: function setHandleOut() {
51087      this._handleOut.set(Point.read(arguments));
51088    },
51089    hasHandles: function hasHandles() {
51090      return !this._handleIn.isZero() || !this._handleOut.isZero();
51091    },
51092    isSmooth: function isSmooth() {
51093      var handleIn = this._handleIn,
51094          handleOut = this._handleOut;
51095      return !handleIn.isZero() && !handleOut.isZero() && handleIn.isCollinear(handleOut);
51096    },
51097    clearHandles: function clearHandles() {
51098      this._handleIn._set(0, 0);
51099
51100      this._handleOut._set(0, 0);
51101    },
51102    getSelection: function getSelection() {
51103      return this._selection;
51104    },
51105    setSelection: function setSelection(selection) {
51106      var oldSelection = this._selection,
51107          path = this._path;
51108      this._selection = selection = selection || 0;
51109
51110      if (path && selection !== oldSelection) {
51111        path._updateSelection(this, oldSelection, selection);
51112
51113        path._changed(257);
51114      }
51115    },
51116    _changeSelection: function _changeSelection(flag, selected) {
51117      var selection = this._selection;
51118      this.setSelection(selected ? selection | flag : selection & ~flag);
51119    },
51120    isSelected: function isSelected() {
51121      return !!(this._selection & 7);
51122    },
51123    setSelected: function setSelected(selected) {
51124      this._changeSelection(7, selected);
51125    },
51126    getIndex: function getIndex() {
51127      return this._index !== undefined ? this._index : null;
51128    },
51129    getPath: function getPath() {
51130      return this._path || null;
51131    },
51132    getCurve: function getCurve() {
51133      var path = this._path,
51134          index = this._index;
51135
51136      if (path) {
51137        if (index > 0 && !path._closed && index === path._segments.length - 1) index--;
51138        return path.getCurves()[index] || null;
51139      }
51140
51141      return null;
51142    },
51143    getLocation: function getLocation() {
51144      var curve = this.getCurve();
51145      return curve ? new CurveLocation(curve, this === curve._segment1 ? 0 : 1) : null;
51146    },
51147    getNext: function getNext() {
51148      var segments = this._path && this._path._segments;
51149      return segments && (segments[this._index + 1] || this._path._closed && segments[0]) || null;
51150    },
51151    smooth: function smooth(options, _first, _last) {
51152      var opts = options || {},
51153          type = opts.type,
51154          factor = opts.factor,
51155          prev = this.getPrevious(),
51156          next = this.getNext(),
51157          p0 = (prev || this)._point,
51158          p1 = this._point,
51159          p2 = (next || this)._point,
51160          d1 = p0.getDistance(p1),
51161          d2 = p1.getDistance(p2);
51162
51163      if (!type || type === 'catmull-rom') {
51164        var a = factor === undefined ? 0.5 : factor,
51165            d1_a = Math.pow(d1, a),
51166            d1_2a = d1_a * d1_a,
51167            d2_a = Math.pow(d2, a),
51168            d2_2a = d2_a * d2_a;
51169
51170        if (!_first && prev) {
51171          var A = 2 * d2_2a + 3 * d2_a * d1_a + d1_2a,
51172              N = 3 * d2_a * (d2_a + d1_a);
51173          this.setHandleIn(N !== 0 ? new Point((d2_2a * p0._x + A * p1._x - d1_2a * p2._x) / N - p1._x, (d2_2a * p0._y + A * p1._y - d1_2a * p2._y) / N - p1._y) : new Point());
51174        }
51175
51176        if (!_last && next) {
51177          var A = 2 * d1_2a + 3 * d1_a * d2_a + d2_2a,
51178              N = 3 * d1_a * (d1_a + d2_a);
51179          this.setHandleOut(N !== 0 ? new Point((d1_2a * p2._x + A * p1._x - d2_2a * p0._x) / N - p1._x, (d1_2a * p2._y + A * p1._y - d2_2a * p0._y) / N - p1._y) : new Point());
51180        }
51181      } else if (type === 'geometric') {
51182        if (prev && next) {
51183          var vector = p0.subtract(p2),
51184              t = factor === undefined ? 0.4 : factor,
51185              k = t * d1 / (d1 + d2);
51186          if (!_first) this.setHandleIn(vector.multiply(k));
51187          if (!_last) this.setHandleOut(vector.multiply(k - t));
51188        }
51189      } else {
51190        throw new Error('Smoothing method \'' + type + '\' not supported.');
51191      }
51192    },
51193    getPrevious: function getPrevious() {
51194      var segments = this._path && this._path._segments;
51195      return segments && (segments[this._index - 1] || this._path._closed && segments[segments.length - 1]) || null;
51196    },
51197    isFirst: function isFirst() {
51198      return !this._index;
51199    },
51200    isLast: function isLast() {
51201      var path = this._path;
51202      return path && this._index === path._segments.length - 1 || false;
51203    },
51204    reverse: function reverse() {
51205      var handleIn = this._handleIn,
51206          handleOut = this._handleOut,
51207          tmp = handleIn.clone();
51208      handleIn.set(handleOut);
51209      handleOut.set(tmp);
51210    },
51211    reversed: function reversed() {
51212      return new Segment(this._point, this._handleOut, this._handleIn);
51213    },
51214    remove: function remove() {
51215      return this._path ? !!this._path.removeSegment(this._index) : false;
51216    },
51217    clone: function clone() {
51218      return new Segment(this._point, this._handleIn, this._handleOut);
51219    },
51220    equals: function equals(segment) {
51221      return segment === this || segment && this._class === segment._class && this._point.equals(segment._point) && this._handleIn.equals(segment._handleIn) && this._handleOut.equals(segment._handleOut) || false;
51222    },
51223    toString: function toString() {
51224      var parts = ['point: ' + this._point];
51225      if (!this._handleIn.isZero()) parts.push('handleIn: ' + this._handleIn);
51226      if (!this._handleOut.isZero()) parts.push('handleOut: ' + this._handleOut);
51227      return '{ ' + parts.join(', ') + ' }';
51228    },
51229    transform: function transform(matrix) {
51230      this._transformCoordinates(matrix, new Array(6), true);
51231
51232      this._changed();
51233    },
51234    interpolate: function interpolate(from, to, factor) {
51235      var u = 1 - factor,
51236          v = factor,
51237          point1 = from._point,
51238          point2 = to._point,
51239          handleIn1 = from._handleIn,
51240          handleIn2 = to._handleIn,
51241          handleOut2 = to._handleOut,
51242          handleOut1 = from._handleOut;
51243
51244      this._point._set(u * point1._x + v * point2._x, u * point1._y + v * point2._y, true);
51245
51246      this._handleIn._set(u * handleIn1._x + v * handleIn2._x, u * handleIn1._y + v * handleIn2._y, true);
51247
51248      this._handleOut._set(u * handleOut1._x + v * handleOut2._x, u * handleOut1._y + v * handleOut2._y, true);
51249
51250      this._changed();
51251    },
51252    _transformCoordinates: function _transformCoordinates(matrix, coords, change) {
51253      var point = this._point,
51254          handleIn = !change || !this._handleIn.isZero() ? this._handleIn : null,
51255          handleOut = !change || !this._handleOut.isZero() ? this._handleOut : null,
51256          x = point._x,
51257          y = point._y,
51258          i = 2;
51259      coords[0] = x;
51260      coords[1] = y;
51261
51262      if (handleIn) {
51263        coords[i++] = handleIn._x + x;
51264        coords[i++] = handleIn._y + y;
51265      }
51266
51267      if (handleOut) {
51268        coords[i++] = handleOut._x + x;
51269        coords[i++] = handleOut._y + y;
51270      }
51271
51272      if (matrix) {
51273        matrix._transformCoordinates(coords, coords, i / 2);
51274
51275        x = coords[0];
51276        y = coords[1];
51277
51278        if (change) {
51279          point._x = x;
51280          point._y = y;
51281          i = 2;
51282
51283          if (handleIn) {
51284            handleIn._x = coords[i++] - x;
51285            handleIn._y = coords[i++] - y;
51286          }
51287
51288          if (handleOut) {
51289            handleOut._x = coords[i++] - x;
51290            handleOut._y = coords[i++] - y;
51291          }
51292        } else {
51293          if (!handleIn) {
51294            coords[i++] = x;
51295            coords[i++] = y;
51296          }
51297
51298          if (!handleOut) {
51299            coords[i++] = x;
51300            coords[i++] = y;
51301          }
51302        }
51303      }
51304
51305      return coords;
51306    }
51307  });
51308  var SegmentPoint = Point.extend({
51309    initialize: function SegmentPoint(point, owner, key) {
51310      var x, y, selected;
51311
51312      if (!point) {
51313        x = y = 0;
51314      } else if ((x = point[0]) !== undefined) {
51315        y = point[1];
51316      } else {
51317        var pt = point;
51318
51319        if ((x = pt.x) === undefined) {
51320          pt = Point.read(arguments);
51321          x = pt.x;
51322        }
51323
51324        y = pt.y;
51325        selected = pt.selected;
51326      }
51327
51328      this._x = x;
51329      this._y = y;
51330      this._owner = owner;
51331      owner[key] = this;
51332      if (selected) this.setSelected(true);
51333    },
51334    _set: function _set(x, y) {
51335      this._x = x;
51336      this._y = y;
51337
51338      this._owner._changed(this);
51339
51340      return this;
51341    },
51342    getX: function getX() {
51343      return this._x;
51344    },
51345    setX: function setX(x) {
51346      this._x = x;
51347
51348      this._owner._changed(this);
51349    },
51350    getY: function getY() {
51351      return this._y;
51352    },
51353    setY: function setY(y) {
51354      this._y = y;
51355
51356      this._owner._changed(this);
51357    },
51358    isZero: function isZero() {
51359      var isZero = Numerical.isZero;
51360      return isZero(this._x) && isZero(this._y);
51361    },
51362    isSelected: function isSelected() {
51363      return !!(this._owner._selection & this._getSelection());
51364    },
51365    setSelected: function setSelected(selected) {
51366      this._owner._changeSelection(this._getSelection(), selected);
51367    },
51368    _getSelection: function _getSelection() {
51369      var owner = this._owner;
51370      return this === owner._point ? 1 : this === owner._handleIn ? 2 : this === owner._handleOut ? 4 : 0;
51371    }
51372  });
51373  var Curve = Base.extend({
51374    _class: 'Curve',
51375    beans: true,
51376    initialize: function Curve(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) {
51377      var count = arguments.length,
51378          seg1,
51379          seg2,
51380          point1,
51381          point2,
51382          handle1,
51383          handle2;
51384
51385      if (count === 3) {
51386        this._path = arg0;
51387        seg1 = arg1;
51388        seg2 = arg2;
51389      } else if (!count) {
51390        seg1 = new Segment();
51391        seg2 = new Segment();
51392      } else if (count === 1) {
51393        if ('segment1' in arg0) {
51394          seg1 = new Segment(arg0.segment1);
51395          seg2 = new Segment(arg0.segment2);
51396        } else if ('point1' in arg0) {
51397          point1 = arg0.point1;
51398          handle1 = arg0.handle1;
51399          handle2 = arg0.handle2;
51400          point2 = arg0.point2;
51401        } else if (Array.isArray(arg0)) {
51402          point1 = [arg0[0], arg0[1]];
51403          point2 = [arg0[6], arg0[7]];
51404          handle1 = [arg0[2] - arg0[0], arg0[3] - arg0[1]];
51405          handle2 = [arg0[4] - arg0[6], arg0[5] - arg0[7]];
51406        }
51407      } else if (count === 2) {
51408        seg1 = new Segment(arg0);
51409        seg2 = new Segment(arg1);
51410      } else if (count === 4) {
51411        point1 = arg0;
51412        handle1 = arg1;
51413        handle2 = arg2;
51414        point2 = arg3;
51415      } else if (count === 8) {
51416        point1 = [arg0, arg1];
51417        point2 = [arg6, arg7];
51418        handle1 = [arg2 - arg0, arg3 - arg1];
51419        handle2 = [arg4 - arg6, arg5 - arg7];
51420      }
51421
51422      this._segment1 = seg1 || new Segment(point1, null, handle1);
51423      this._segment2 = seg2 || new Segment(point2, handle2, null);
51424    },
51425    _serialize: function _serialize(options, dictionary) {
51426      return Base.serialize(this.hasHandles() ? [this.getPoint1(), this.getHandle1(), this.getHandle2(), this.getPoint2()] : [this.getPoint1(), this.getPoint2()], options, true, dictionary);
51427    },
51428    _changed: function _changed() {
51429      this._length = this._bounds = undefined;
51430    },
51431    clone: function clone() {
51432      return new Curve(this._segment1, this._segment2);
51433    },
51434    toString: function toString() {
51435      var parts = ['point1: ' + this._segment1._point];
51436      if (!this._segment1._handleOut.isZero()) parts.push('handle1: ' + this._segment1._handleOut);
51437      if (!this._segment2._handleIn.isZero()) parts.push('handle2: ' + this._segment2._handleIn);
51438      parts.push('point2: ' + this._segment2._point);
51439      return '{ ' + parts.join(', ') + ' }';
51440    },
51441    classify: function classify() {
51442      return Curve.classify(this.getValues());
51443    },
51444    remove: function remove() {
51445      var removed = false;
51446
51447      if (this._path) {
51448        var segment2 = this._segment2,
51449            handleOut = segment2._handleOut;
51450        removed = segment2.remove();
51451        if (removed) this._segment1._handleOut.set(handleOut);
51452      }
51453
51454      return removed;
51455    },
51456    getPoint1: function getPoint1() {
51457      return this._segment1._point;
51458    },
51459    setPoint1: function setPoint1() {
51460      this._segment1._point.set(Point.read(arguments));
51461    },
51462    getPoint2: function getPoint2() {
51463      return this._segment2._point;
51464    },
51465    setPoint2: function setPoint2() {
51466      this._segment2._point.set(Point.read(arguments));
51467    },
51468    getHandle1: function getHandle1() {
51469      return this._segment1._handleOut;
51470    },
51471    setHandle1: function setHandle1() {
51472      this._segment1._handleOut.set(Point.read(arguments));
51473    },
51474    getHandle2: function getHandle2() {
51475      return this._segment2._handleIn;
51476    },
51477    setHandle2: function setHandle2() {
51478      this._segment2._handleIn.set(Point.read(arguments));
51479    },
51480    getSegment1: function getSegment1() {
51481      return this._segment1;
51482    },
51483    getSegment2: function getSegment2() {
51484      return this._segment2;
51485    },
51486    getPath: function getPath() {
51487      return this._path;
51488    },
51489    getIndex: function getIndex() {
51490      return this._segment1._index;
51491    },
51492    getNext: function getNext() {
51493      var curves = this._path && this._path._curves;
51494      return curves && (curves[this._segment1._index + 1] || this._path._closed && curves[0]) || null;
51495    },
51496    getPrevious: function getPrevious() {
51497      var curves = this._path && this._path._curves;
51498      return curves && (curves[this._segment1._index - 1] || this._path._closed && curves[curves.length - 1]) || null;
51499    },
51500    isFirst: function isFirst() {
51501      return !this._segment1._index;
51502    },
51503    isLast: function isLast() {
51504      var path = this._path;
51505      return path && this._segment1._index === path._curves.length - 1 || false;
51506    },
51507    isSelected: function isSelected() {
51508      return this.getPoint1().isSelected() && this.getHandle1().isSelected() && this.getHandle2().isSelected() && this.getPoint2().isSelected();
51509    },
51510    setSelected: function setSelected(selected) {
51511      this.getPoint1().setSelected(selected);
51512      this.getHandle1().setSelected(selected);
51513      this.getHandle2().setSelected(selected);
51514      this.getPoint2().setSelected(selected);
51515    },
51516    getValues: function getValues(matrix) {
51517      return Curve.getValues(this._segment1, this._segment2, matrix);
51518    },
51519    getPoints: function getPoints() {
51520      var coords = this.getValues(),
51521          points = [];
51522
51523      for (var i = 0; i < 8; i += 2) {
51524        points.push(new Point(coords[i], coords[i + 1]));
51525      }
51526
51527      return points;
51528    }
51529  }, {
51530    getLength: function getLength() {
51531      if (this._length == null) this._length = Curve.getLength(this.getValues(), 0, 1);
51532      return this._length;
51533    },
51534    getArea: function getArea() {
51535      return Curve.getArea(this.getValues());
51536    },
51537    getLine: function getLine() {
51538      return new Line(this._segment1._point, this._segment2._point);
51539    },
51540    getPart: function getPart(from, to) {
51541      return new Curve(Curve.getPart(this.getValues(), from, to));
51542    },
51543    getPartLength: function getPartLength(from, to) {
51544      return Curve.getLength(this.getValues(), from, to);
51545    },
51546    divideAt: function divideAt(location) {
51547      return this.divideAtTime(location && location.curve === this ? location.time : this.getTimeAt(location));
51548    },
51549    divideAtTime: function divideAtTime(time, _setHandles) {
51550      var tMin = 1e-8,
51551          tMax = 1 - tMin,
51552          res = null;
51553
51554      if (time >= tMin && time <= tMax) {
51555        var parts = Curve.subdivide(this.getValues(), time),
51556            left = parts[0],
51557            right = parts[1],
51558            setHandles = _setHandles || this.hasHandles(),
51559            seg1 = this._segment1,
51560            seg2 = this._segment2,
51561            path = this._path;
51562
51563        if (setHandles) {
51564          seg1._handleOut._set(left[2] - left[0], left[3] - left[1]);
51565
51566          seg2._handleIn._set(right[4] - right[6], right[5] - right[7]);
51567        }
51568
51569        var x = left[6],
51570            y = left[7],
51571            segment = new Segment(new Point(x, y), setHandles && new Point(left[4] - x, left[5] - y), setHandles && new Point(right[2] - x, right[3] - y));
51572
51573        if (path) {
51574          path.insert(seg1._index + 1, segment);
51575          res = this.getNext();
51576        } else {
51577          this._segment2 = segment;
51578
51579          this._changed();
51580
51581          res = new Curve(segment, seg2);
51582        }
51583      }
51584
51585      return res;
51586    },
51587    splitAt: function splitAt(location) {
51588      var path = this._path;
51589      return path ? path.splitAt(location) : null;
51590    },
51591    splitAtTime: function splitAtTime(time) {
51592      return this.splitAt(this.getLocationAtTime(time));
51593    },
51594    divide: function divide(offset, isTime) {
51595      return this.divideAtTime(offset === undefined ? 0.5 : isTime ? offset : this.getTimeAt(offset));
51596    },
51597    split: function split(offset, isTime) {
51598      return this.splitAtTime(offset === undefined ? 0.5 : isTime ? offset : this.getTimeAt(offset));
51599    },
51600    reversed: function reversed() {
51601      return new Curve(this._segment2.reversed(), this._segment1.reversed());
51602    },
51603    clearHandles: function clearHandles() {
51604      this._segment1._handleOut._set(0, 0);
51605
51606      this._segment2._handleIn._set(0, 0);
51607    },
51608    statics: {
51609      getValues: function getValues(segment1, segment2, matrix, straight) {
51610        var p1 = segment1._point,
51611            h1 = segment1._handleOut,
51612            h2 = segment2._handleIn,
51613            p2 = segment2._point,
51614            x1 = p1.x,
51615            y1 = p1.y,
51616            x2 = p2.x,
51617            y2 = p2.y,
51618            values = straight ? [x1, y1, x1, y1, x2, y2, x2, y2] : [x1, y1, x1 + h1._x, y1 + h1._y, x2 + h2._x, y2 + h2._y, x2, y2];
51619        if (matrix) matrix._transformCoordinates(values, values, 4);
51620        return values;
51621      },
51622      subdivide: function subdivide(v, t) {
51623        var x0 = v[0],
51624            y0 = v[1],
51625            x1 = v[2],
51626            y1 = v[3],
51627            x2 = v[4],
51628            y2 = v[5],
51629            x3 = v[6],
51630            y3 = v[7];
51631        if (t === undefined) t = 0.5;
51632        var u = 1 - t,
51633            x4 = u * x0 + t * x1,
51634            y4 = u * y0 + t * y1,
51635            x5 = u * x1 + t * x2,
51636            y5 = u * y1 + t * y2,
51637            x6 = u * x2 + t * x3,
51638            y6 = u * y2 + t * y3,
51639            x7 = u * x4 + t * x5,
51640            y7 = u * y4 + t * y5,
51641            x8 = u * x5 + t * x6,
51642            y8 = u * y5 + t * y6,
51643            x9 = u * x7 + t * x8,
51644            y9 = u * y7 + t * y8;
51645        return [[x0, y0, x4, y4, x7, y7, x9, y9], [x9, y9, x8, y8, x6, y6, x3, y3]];
51646      },
51647      getMonoCurves: function getMonoCurves(v, dir) {
51648        var curves = [],
51649            io = dir ? 0 : 1,
51650            o0 = v[io + 0],
51651            o1 = v[io + 2],
51652            o2 = v[io + 4],
vendor: 4,617 bytes, lines 51653-51804
51653            o3 = v[io + 6];
51654
51655        if (o0 >= o1 === o1 >= o2 && o1 >= o2 === o2 >= o3 || Curve.isStraight(v)) {
51656          curves.push(v);
51657        } else {
51658          var a = 3 * (o1 - o2) - o0 + o3,
51659              b = 2 * (o0 + o2) - 4 * o1,
51660              c = o1 - o0,
51661              tMin = 1e-8,
51662              tMax = 1 - tMin,
51663              roots = [],
51664              n = Numerical.solveQuadratic(a, b, c, roots, tMin, tMax);
51665
51666          if (!n) {
51667            curves.push(v);
51668          } else {
51669            roots.sort();
51670            var t = roots[0],
51671                parts = Curve.subdivide(v, t);
51672            curves.push(parts[0]);
51673
51674            if (n > 1) {
51675              t = (roots[1] - t) / (1 - t);
51676              parts = Curve.subdivide(parts[1], t);
51677              curves.push(parts[0]);
51678            }
51679
51680            curves.push(parts[1]);
51681          }
51682        }
51683
51684        return curves;
51685      },
51686      solveCubic: function solveCubic(v, coord, val, roots, min, max) {
51687        var v0 = v[coord],
51688            v1 = v[coord + 2],
51689            v2 = v[coord + 4],
51690            v3 = v[coord + 6],
51691            res = 0;
51692
51693        if (!(v0 < val && v3 < val && v1 < val && v2 < val || v0 > val && v3 > val && v1 > val && v2 > val)) {
51694          var c = 3 * (v1 - v0),
51695              b = 3 * (v2 - v1) - c,
51696              a = v3 - v0 - c - b;
51697          res = Numerical.solveCubic(a, b, c, v0 - val, roots, min, max);
51698        }
51699
51700        return res;
51701      },
51702      getTimeOf: function getTimeOf(v, point) {
51703        var p0 = new Point(v[0], v[1]),
51704            p3 = new Point(v[6], v[7]),
51705            epsilon = 1e-12,
51706            geomEpsilon = 1e-7,
51707            t = point.isClose(p0, epsilon) ? 0 : point.isClose(p3, epsilon) ? 1 : null;
51708
51709        if (t === null) {
51710          var coords = [point.x, point.y],
51711              roots = [];
51712
51713          for (var c = 0; c < 2; c++) {
51714            var count = Curve.solveCubic(v, c, coords[c], roots, 0, 1);
51715
51716            for (var i = 0; i < count; i++) {
51717              var u = roots[i];
51718              if (point.isClose(Curve.getPoint(v, u), geomEpsilon)) return u;
51719            }
51720          }
51721        }
51722
51723        return point.isClose(p0, geomEpsilon) ? 0 : point.isClose(p3, geomEpsilon) ? 1 : null;
51724      },
51725      getNearestTime: function getNearestTime(v, point) {
51726        if (Curve.isStraight(v)) {
51727          var x0 = v[0],
51728              y0 = v[1],
51729              x3 = v[6],
51730              y3 = v[7],
51731              vx = x3 - x0,
51732              vy = y3 - y0,
51733              det = vx * vx + vy * vy;
51734          if (det === 0) return 0;
51735          var u = ((point.x - x0) * vx + (point.y - y0) * vy) / det;
51736          return u < 1e-12 ? 0 : u > 0.999999999999 ? 1 : Curve.getTimeOf(v, new Point(x0 + u * vx, y0 + u * vy));
51737        }
51738
51739        var count = 100,
51740            minDist = Infinity,
51741            minT = 0;
51742
51743        function refine(t) {
51744          if (t >= 0 && t <= 1) {
51745            var dist = point.getDistance(Curve.getPoint(v, t), true);
51746
51747            if (dist < minDist) {
51748              minDist = dist;
51749              minT = t;
51750              return true;
51751            }
51752          }
51753        }
51754
51755        for (var i = 0; i <= count; i++) {
51756          refine(i / count);
51757        }
51758
51759        var step = 1 / (count * 2);
51760
51761        while (step > 1e-8) {
51762          if (!refine(minT - step) && !refine(minT + step)) step /= 2;
51763        }
51764
51765        return minT;
51766      },
51767      getPart: function getPart(v, from, to) {
51768        var flip = from > to;
51769
51770        if (flip) {
51771          var tmp = from;
51772          from = to;
51773          to = tmp;
51774        }
51775
51776        if (from > 0) v = Curve.subdivide(v, from)[1];
51777        if (to < 1) v = Curve.subdivide(v, (to - from) / (1 - from))[0];
51778        return flip ? [v[6], v[7], v[4], v[5], v[2], v[3], v[0], v[1]] : v;
51779      },
51780      isFlatEnough: function isFlatEnough(v, flatness) {
51781        var x0 = v[0],
51782            y0 = v[1],
51783            x1 = v[2],
51784            y1 = v[3],
51785            x2 = v[4],
51786            y2 = v[5],
51787            x3 = v[6],
51788            y3 = v[7],
51789            ux = 3 * x1 - 2 * x0 - x3,
51790            uy = 3 * y1 - 2 * y0 - y3,
51791            vx = 3 * x2 - 2 * x3 - x0,
51792            vy = 3 * y2 - 2 * y3 - y0;
51793        return Math.max(ux * ux, vx * vx) + Math.max(uy * uy, vy * vy) <= 16 * flatness * flatness;
51794      },
51795      getArea: function getArea(v) {
51796        var x0 = v[0],
51797            y0 = v[1],
51798            x1 = v[2],
51799            y1 = v[3],
51800            x2 = v[4],
51801            y2 = v[5],
51802            x3 = v[6],
51803            y3 = v[7];
51804        return 3 * ((y3 - y0) * (x1 + x2) - (x3 - x0) * (y1 + y2) + y1 * (x0 - x2) - x1 * (y0 - y2) + y3 * (x2 + x0 / 3) - x3 * (y2 
51804+ y0 / 3)) / 20;
51805      },
51806      getBounds: function getBounds(v) {
51807        var min = v.slice(0, 2),
51808            max = min.slice(),
51809            roots = [0, 0];
51810
51811        for (var i = 0; i < 2; i++) {
51812          Curve._addBounds(v[i], v[i + 2], v[i + 4], v[i + 6], i, 0, min, max, roots);
51813        }
51814
51815        return new _Rectangle(min[0], min[1], max[0] - min[0], max[1] - min[1]);
51816      },
51817      _addBounds: function _addBounds(v0, v1, v2, v3, coord, padding, min, max, roots) {
51818        function add(value, padding) {
51819          var left = value - padding,
51820              right = value + padding;
51821          if (left < min[coord]) min[coord] = left;
51822          if (right > max[coord]) max[coord] = right;
51823        }
51824
51825        padding /= 2;
51826        var minPad = min[coord] - padding,
51827            maxPad = max[coord] + padding;
51828
51829        if (v0 < minPad || v1 < minPad || v2 < minPad || v3 < minPad || v0 > maxPad || v1 > maxPad || v2 > maxPad || v3 > maxPad) {
51830          if (v1 < v0 != v1 < v3 && v2 < v0 != v2 < v3) {
51831            add(v0, padding);
51832            add(v3, padding);
51833          } else {
51834            var a = 3 * (v1 - v2) - v0 + v3,
51835                b = 2 * (v0 + v2) - 4 * v1,
51836                c = v1 - v0,
51837                count = Numerical.solveQuadratic(a, b, c, roots),
51838                tMin = 1e-8,
51839                tMax = 1 - tMin;
51840            add(v3, 0);
51841
51842            for (var i = 0; i < count; i++) {
51843              var t = roots[i],
51844                  u = 1 - t;
51845              if (tMin <= t && t <= tMax) add(u * u * u * v0 + 3 * u * u * t * v1 + 3 * u * t * t * v2 + t * t * t * v3, padding);
51846            }
51847          }
51848        }
51849      }
51850    }
51851  }, Base.each(['getBounds', 'getStrokeBounds', 'getHandleBounds'], function (name) {
51852    this[name] = function () {
51853      if (!this._bounds) this._bounds = {};
51854      var bounds = this._bounds[name];
51855
51856      if (!bounds) {
51857        bounds = this._bounds[name] = Path[name]([this._segment1, this._segment2], false, this._path);
51858      }
51859
51860      return bounds.clone();
51861    };
51862  }, {}), Base.each({
51863    isStraight: function isStraight(p1, h1, h2, p2) {
51864      if (h1.isZero() && h2.isZero()) {
51865        return true;
51866      } else {
51867        var v = p2.subtract(p1);
51868
51869        if (v.isZero()) {
51870          return false;
51871        } else if (v.isCollinear(h1) && v.isCollinear(h2)) {
51872          var l = new Line(p1, p2),
51873              epsilon = 1e-7;
51874
51875          if (l.getDistance(p1.add(h1)) < epsilon && l.getDistance(p2.add(h2)) < epsilon) {
51876            var div = v.dot(v),
51877                s1 = v.dot(h1) / div,
51878                s2 = v.dot(h2) / div;
51879            return s1 >= 0 && s1 <= 1 && s2 <= 0 && s2 >= -1;
51880          }
51881        }
51882      }
51883
51884      return false;
51885    },
51886    isLinear: function isLinear(p1, h1, h2, p2) {
51887      var third = p2.subtract(p1).divide(3);
51888      return h1.equals(third) && h2.negate().equals(third);
51889    }
51890  }, function (test, name) {
51891    this[name] = function (epsilon) {
51892      var seg1 = this._segment1,
51893          seg2 = this._segment2;
51894      return test(seg1._point, seg1._handleOut, seg2._handleIn, seg2._point, epsilon);
51895    };
51896
51897    this.statics[name] = function (v, epsilon) {
51898      var x0 = v[0],
51899          y0 = v[1],
51900          x3 = v[6],
51901          y3 = v[7];
51902      return test(new Point(x0, y0), new Point(v[2] - x0, v[3] - y0), new Point(v[4] - x3, v[5] - y3), new Point(x3, y3), epsilon);
51903    };
51904  }, {
51905    statics: {},
51906    hasHandles: function hasHandles() {
51907      return !this._segment1._handleOut.isZero() || !this._segment2._handleIn.isZero();
51908    },
51909    hasLength: function hasLength(epsilon) {
51910      return (!this.getPoint1().equals(this.getPoint2()) || this.hasHandles()) && this.getLength() > (epsilon || 0);
51911    },
51912    isCollinear: function isCollinear(curve) {
51913      return curve && this.isStraight() && curve.isStraight() && this.getLine().isCollinear(curve.getLine());
51914    },
51915    isHorizontal: function isHorizontal() {
51916      return this.isStraight() && Math.abs(this.getTangentAtTime(0.5).y) < 1e-8;
51917    },
51918    isVertical: function isVertical() {
51919      return this.isStraight() && Math.abs(this.getTangentAtTime(0.5).x) < 1e-8;
51920    }
51921  }), {
vendor: 29,445 bytes, lines 51922-52818
51922    beans: false,
51923    getLocationAt: function getLocationAt(offset, _isTime) {
51924      return this.getLocationAtTime(_isTime ? offset : this.getTimeAt(offset));
51925    },
51926    getLocationAtTime: function getLocationAtTime(t) {
51927      return t != null && t >= 0 && t <= 1 ? new CurveLocation(this, t) : null;
51928    },
51929    getTimeAt: function getTimeAt(offset, start) {
51930      return Curve.getTimeAt(this.getValues(), offset, start);
51931    },
51932    getParameterAt: '#getTimeAt',
51933    getTimesWithTangent: function getTimesWithTangent() {
51934      var tangent = Point.read(arguments);
51935      return tangent.isZero() ? [] : Curve.getTimesWithTangent(this.getValues(), tangent);
51936    },
51937    getOffsetAtTime: function getOffsetAtTime(t) {
51938      return this.getPartLength(0, t);
51939    },
51940    getLocationOf: function getLocationOf() {
51941      return this.getLocationAtTime(this.getTimeOf(Point.read(arguments)));
51942    },
51943    getOffsetOf: function getOffsetOf() {
51944      var loc = this.getLocationOf.apply(this, arguments);
51945      return loc ? loc.getOffset() : null;
51946    },
51947    getTimeOf: function getTimeOf() {
51948      return Curve.getTimeOf(this.getValues(), Point.read(arguments));
51949    },
51950    getParameterOf: '#getTimeOf',
51951    getNearestLocation: function getNearestLocation() {
51952      var point = Point.read(arguments),
51953          values = this.getValues(),
51954          t = Curve.getNearestTime(values, point),
51955          pt = Curve.getPoint(values, t);
51956      return new CurveLocation(this, t, pt, null, point.getDistance(pt));
51957    },
51958    getNearestPoint: function getNearestPoint() {
51959      var loc = this.getNearestLocation.apply(this, arguments);
51960      return loc ? loc.getPoint() : loc;
51961    }
51962  }, new function () {
51963    var methods = ['getPoint', 'getTangent', 'getNormal', 'getWeightedTangent', 'getWeightedNormal', 'getCurvature'];
51964    return Base.each(methods, function (name) {
51965      this[name + 'At'] = function (location, _isTime) {
51966        var values = this.getValues();
51967        return Curve[name](values, _isTime ? location : Curve.getTimeAt(values, location));
51968      };
51969
51970      this[name + 'AtTime'] = function (time) {
51971        return Curve[name](this.getValues(), time);
51972      };
51973    }, {
51974      statics: {
51975        _evaluateMethods: methods
51976      }
51977    });
51978  }(), new function () {
51979    function getLengthIntegrand(v) {
51980      var x0 = v[0],
51981          y0 = v[1],
51982          x1 = v[2],
51983          y1 = v[3],
51984          x2 = v[4],
51985          y2 = v[5],
51986          x3 = v[6],
51987          y3 = v[7],
51988          ax = 9 * (x1 - x2) + 3 * (x3 - x0),
51989          bx = 6 * (x0 + x2) - 12 * x1,
51990          cx = 3 * (x1 - x0),
51991          ay = 9 * (y1 - y2) + 3 * (y3 - y0),
51992          by = 6 * (y0 + y2) - 12 * y1,
51993          cy = 3 * (y1 - y0);
51994      return function (t) {
51995        var dx = (ax * t + bx) * t + cx,
51996            dy = (ay * t + by) * t + cy;
51997        return Math.sqrt(dx * dx + dy * dy);
51998      };
51999    }
52000
52001    function getIterations(a, b) {
52002      return Math.max(2, Math.min(16, Math.ceil(Math.abs(b - a) * 32)));
52003    }
52004
52005    function evaluate(v, t, type, normalized) {
52006      if (t == null || t < 0 || t > 1) return null;
52007      var x0 = v[0],
52008          y0 = v[1],
52009          x1 = v[2],
52010          y1 = v[3],
52011          x2 = v[4],
52012          y2 = v[5],
52013          x3 = v[6],
52014          y3 = v[7],
52015          isZero = Numerical.isZero;
52016
52017      if (isZero(x1 - x0) && isZero(y1 - y0)) {
52018        x1 = x0;
52019        y1 = y0;
52020      }
52021
52022      if (isZero(x2 - x3) && isZero(y2 - y3)) {
52023        x2 = x3;
52024        y2 = y3;
52025      }
52026
52027      var cx = 3 * (x1 - x0),
52028          bx = 3 * (x2 - x1) - cx,
52029          ax = x3 - x0 - cx - bx,
52030          cy = 3 * (y1 - y0),
52031          by = 3 * (y2 - y1) - cy,
52032          ay = y3 - y0 - cy - by,
52033          x,
52034          y;
52035
52036      if (type === 0) {
52037        x = t === 0 ? x0 : t === 1 ? x3 : ((ax * t + bx) * t + cx) * t + x0;
52038        y = t === 0 ? y0 : t === 1 ? y3 : ((ay * t + by) * t + cy) * t + y0;
52039      } else {
52040        var tMin = 1e-8,
52041            tMax = 1 - tMin;
52042
52043        if (t < tMin) {
52044          x = cx;
52045          y = cy;
52046        } else if (t > tMax) {
52047          x = 3 * (x3 - x2);
52048          y = 3 * (y3 - y2);
52049        } else {
52050          x = (3 * ax * t + 2 * bx) * t + cx;
52051          y = (3 * ay * t + 2 * by) * t + cy;
52052        }
52053
52054        if (normalized) {
52055          if (x === 0 && y === 0 && (t < tMin || t > tMax)) {
52056            x = x2 - x1;
52057            y = y2 - y1;
52058          }
52059
52060          var len = Math.sqrt(x * x + y * y);
52061
52062          if (len) {
52063            x /= len;
52064            y /= len;
52065          }
52066        }
52067
52068        if (type === 3) {
52069          var x2 = 6 * ax * t + 2 * bx,
52070              y2 = 6 * ay * t + 2 * by,
52071              d = Math.pow(x * x + y * y, 3 / 2);
52072          x = d !== 0 ? (x * y2 - y * x2) / d : 0;
52073          y = 0;
52074        }
52075      }
52076
52077      return type === 2 ? new Point(y, -x) : new Point(x, y);
52078    }
52079
52080    return {
52081      statics: {
52082        classify: function classify(v) {
52083          var x0 = v[0],
52084              y0 = v[1],
52085              x1 = v[2],
52086              y1 = v[3],
52087              x2 = v[4],
52088              y2 = v[5],
52089              x3 = v[6],
52090              y3 = v[7],
52091              a1 = x0 * (y3 - y2) + y0 * (x2 - x3) + x3 * y2 - y3 * x2,
52092              a2 = x1 * (y0 - y3) + y1 * (x3 - x0) + x0 * y3 - y0 * x3,
52093              a3 = x2 * (y1 - y0) + y2 * (x0 - x1) + x1 * y0 - y1 * x0,
52094              d3 = 3 * a3,
52095              d2 = d3 - a2,
52096              d1 = d2 - a2 + a1,
52097              l = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3),
52098              s = l !== 0 ? 1 / l : 0,
52099              isZero = Numerical.isZero,
52100              serpentine = 'serpentine';
52101          d1 *= s;
52102          d2 *= s;
52103          d3 *= s;
52104
52105          function type(type, t1, t2) {
52106            var hasRoots = t1 !== undefined,
52107                t1Ok = hasRoots && t1 > 0 && t1 < 1,
52108                t2Ok = hasRoots && t2 > 0 && t2 < 1;
52109
52110            if (hasRoots && (!(t1Ok || t2Ok) || type === 'loop' && !(t1Ok && t2Ok))) {
52111              type = 'arch';
52112              t1Ok = t2Ok = false;
52113            }
52114
52115            return {
52116              type: type,
52117              roots: t1Ok || t2Ok ? t1Ok && t2Ok ? t1 < t2 ? [t1, t2] : [t2, t1] : [t1Ok ? t1 : t2] : null
52118            };
52119          }
52120
52121          if (isZero(d1)) {
52122            return isZero(d2) ? type(isZero(d3) ? 'line' : 'quadratic') : type(serpentine, d3 / (3 * d2));
52123          }
52124
52125          var d = 3 * d2 * d2 - 4 * d1 * d3;
52126
52127          if (isZero(d)) {
52128            return type('cusp', d2 / (2 * d1));
52129          }
52130
52131          var f1 = d > 0 ? Math.sqrt(d / 3) : Math.sqrt(-d),
52132              f2 = 2 * d1;
52133          return type(d > 0 ? serpentine : 'loop', (d2 + f1) / f2, (d2 - f1) / f2);
52134        },
52135        getLength: function getLength(v, a, b, ds) {
52136          if (a === undefined) a = 0;
52137          if (b === undefined) b = 1;
52138
52139          if (Curve.isStraight(v)) {
52140            var c = v;
52141
52142            if (b < 1) {
52143              c = Curve.subdivide(c, b)[0];
52144              a /= b;
52145            }
52146
52147            if (a > 0) {
52148              c = Curve.subdivide(c, a)[1];
52149            }
52150
52151            var dx = c[6] - c[0],
52152                dy = c[7] - c[1];
52153            return Math.sqrt(dx * dx + dy * dy);
52154          }
52155
52156          return Numerical.integrate(ds || getLengthIntegrand(v), a, b, getIterations(a, b));
52157        },
52158        getTimeAt: function getTimeAt(v, offset, start) {
52159          if (start === undefined) start = offset < 0 ? 1 : 0;
52160          if (offset === 0) return start;
52161          var abs = Math.abs,
52162              epsilon = 1e-12,
52163              forward = offset > 0,
52164              a = forward ? start : 0,
52165              b = forward ? 1 : start,
52166              ds = getLengthIntegrand(v),
52167              rangeLength = Curve.getLength(v, a, b, ds),
52168              diff = abs(offset) - rangeLength;
52169
52170          if (abs(diff) < epsilon) {
52171            return forward ? b : a;
52172          } else if (diff > epsilon) {
52173            return null;
52174          }
52175
52176          var guess = offset / rangeLength,
52177              length = 0;
52178
52179          function f(t) {
52180            length += Numerical.integrate(ds, start, t, getIterations(start, t));
52181            start = t;
52182            return length - offset;
52183          }
52184
52185          return Numerical.findRoot(f, ds, start + guess, a, b, 32, 1e-12);
52186        },
52187        getPoint: function getPoint(v, t) {
52188          return evaluate(v, t, 0, false);
52189        },
52190        getTangent: function getTangent(v, t) {
52191          return evaluate(v, t, 1, true);
52192        },
52193        getWeightedTangent: function getWeightedTangent(v, t) {
52194          return evaluate(v, t, 1, false);
52195        },
52196        getNormal: function getNormal(v, t) {
52197          return evaluate(v, t, 2, true);
52198        },
52199        getWeightedNormal: function getWeightedNormal(v, t) {
52200          return evaluate(v, t, 2, false);
52201        },
52202        getCurvature: function getCurvature(v, t) {
52203          return evaluate(v, t, 3, false).x;
52204        },
52205        getPeaks: function getPeaks(v) {
52206          var x0 = v[0],
52207              y0 = v[1],
52208              x1 = v[2],
52209              y1 = v[3],
52210              x2 = v[4],
52211              y2 = v[5],
52212              x3 = v[6],
52213              y3 = v[7],
52214              ax = -x0 + 3 * x1 - 3 * x2 + x3,
52215              bx = 3 * x0 - 6 * x1 + 3 * x2,
52216              cx = -3 * x0 + 3 * x1,
52217              ay = -y0 + 3 * y1 - 3 * y2 + y3,
52218              by = 3 * y0 - 6 * y1 + 3 * y2,
52219              cy = -3 * y0 + 3 * y1,
52220              tMin = 1e-8,
52221              tMax = 1 - tMin,
52222              roots = [];
52223          Numerical.solveCubic(9 * (ax * ax + ay * ay), 9 * (ax * bx + by * ay), 2 * (bx * bx + by * by) + 3 * (cx * ax + cy * ay), cx * bx + by * cy, roots, tMin, tMax);
52224          return roots.sort();
52225        }
52226      }
52227    };
52228  }(), new function () {
52229    function addLocation(locations, include, c1, t1, c2, t2, overlap) {
52230      var excludeStart = !overlap && c1.getPrevious() === c2,
52231          excludeEnd = !overlap && c1 !== c2 && c1.getNext() === c2,
52232          tMin = 1e-8,
52233          tMax = 1 - tMin;
52234
52235      if (t1 !== null && t1 >= (excludeStart ? tMin : 0) && t1 <= (excludeEnd ? tMax : 1)) {
52236        if (t2 !== null && t2 >= (excludeEnd ? tMin : 0) && t2 <= (excludeStart ? tMax : 1)) {
52237          var loc1 = new CurveLocation(c1, t1, null, overlap),
52238              loc2 = new CurveLocation(c2, t2, null, overlap);
52239          loc1._intersection = loc2;
52240          loc2._intersection = loc1;
52241
52242          if (!include || include(loc1)) {
52243            CurveLocation.insert(locations, loc1, true);
52244          }
52245        }
52246      }
52247    }
52248
52249    function addCurveIntersections(v1, v2, c1, c2, locations, include, flip, recursion, calls, tMin, tMax, uMin, uMax) {
52250      if (++calls >= 4096 || ++recursion >= 40) return calls;
52251      var fatLineEpsilon = 1e-9,
52252          q0x = v2[0],
52253          q0y = v2[1],
52254          q3x = v2[6],
52255          q3y = v2[7],
52256          getSignedDistance = Line.getSignedDistance,
52257          d1 = getSignedDistance(q0x, q0y, q3x, q3y, v2[2], v2[3]),
52258          d2 = getSignedDistance(q0x, q0y, q3x, q3y, v2[4], v2[5]),
52259          factor = d1 * d2 > 0 ? 3 / 4 : 4 / 9,
52260          dMin = factor * Math.min(0, d1, d2),
52261          dMax = factor * Math.max(0, d1, d2),
52262          dp0 = getSignedDistance(q0x, q0y, q3x, q3y, v1[0], v1[1]),
52263          dp1 = getSignedDistance(q0x, q0y, q3x, q3y, v1[2], v1[3]),
52264          dp2 = getSignedDistance(q0x, q0y, q3x, q3y, v1[4], v1[5]),
52265          dp3 = getSignedDistance(q0x, q0y, q3x, q3y, v1[6], v1[7]),
52266          hull = getConvexHull(dp0, dp1, dp2, dp3),
52267          top = hull[0],
52268          bottom = hull[1],
52269          tMinClip,
52270          tMaxClip;
52271      if (d1 === 0 && d2 === 0 && dp0 === 0 && dp1 === 0 && dp2 === 0 && dp3 === 0 || (tMinClip = clipConvexHull(top, bottom, dMin, dMax)) == null || (tMaxClip = clipConvexHull(top.reverse(), bottom.reverse(), dMin, dMax)) == null) return calls;
52272      var tMinNew = tMin + (tMax - tMin) * tMinClip,
52273          tMaxNew = tMin + (tMax - tMin) * tMaxClip;
52274
52275      if (Math.max(uMax - uMin, tMaxNew - tMinNew) < fatLineEpsilon) {
52276        var t = (tMinNew + tMaxNew) / 2,
52277            u = (uMin + uMax) / 2;
52278        addLocation(locations, include, flip ? c2 : c1, flip ? u : t, flip ? c1 : c2, flip ? t : u);
52279      } else {
52280        v1 = Curve.getPart(v1, tMinClip, tMaxClip);
52281        var uDiff = uMax - uMin;
52282
52283        if (tMaxClip - tMinClip > 0.8) {
52284          if (tMaxNew - tMinNew > uDiff) {
52285            var parts = Curve.subdivide(v1, 0.5),
52286                t = (tMinNew + tMaxNew) / 2;
52287            calls = addCurveIntersections(v2, parts[0], c2, c1, locations, include, !flip, recursion, calls, uMin, uMax, tMinNew, t);
52288            calls = addCurveIntersections(v2, parts[1], c2, c1, locations, include, !flip, recursion, calls, uMin, uMax, t, tMaxNew);
52289          } else {
52290            var parts = Curve.subdivide(v2, 0.5),
52291                u = (uMin + uMax) / 2;
52292            calls = addCurveIntersections(parts[0], v1, c2, c1, locations, include, !flip, recursion, calls, uMin, u, tMinNew, tMaxNew);
52293            calls = addCurveIntersections(parts[1], v1, c2, c1, locations, include, !flip, recursion, calls, u, uMax, tMinNew, tMaxNew);
52294          }
52295        } else {
52296          if (uDiff === 0 || uDiff >= fatLineEpsilon) {
52297            calls = addCurveIntersections(v2, v1, c2, c1, locations, include, !flip, recursion, calls, uMin, uMax, tMinNew, tMaxNew);
52298          } else {
52299            calls = addCurveIntersections(v1, v2, c1, c2, locations, include, flip, recursion, calls, tMinNew, tMaxNew, uMin, uMax);
52300          }
52301        }
52302      }
52303
52304      return calls;
52305    }
52306
52307    function getConvexHull(dq0, dq1, dq2, dq3) {
52308      var p0 = [0, dq0],
52309          p1 = [1 / 3, dq1],
52310          p2 = [2 / 3, dq2],
52311          p3 = [1, dq3],
52312          dist1 = dq1 - (2 * dq0 + dq3) / 3,
52313          dist2 = dq2 - (dq0 + 2 * dq3) / 3,
52314          hull;
52315
52316      if (dist1 * dist2 < 0) {
52317        hull = [[p0, p1, p3], [p0, p2, p3]];
52318      } else {
52319        var distRatio = dist1 / dist2;
52320        hull = [distRatio >= 2 ? [p0, p1, p3] : distRatio <= 0.5 ? [p0, p2, p3] : [p0, p1, p2, p3], [p0, p3]];
52321      }
52322
52323      return (dist1 || dist2) < 0 ? hull.reverse() : hull;
52324    }
52325
52326    function clipConvexHull(hullTop, hullBottom, dMin, dMax) {
52327      if (hullTop[0][1] < dMin) {
52328        return clipConvexHullPart(hullTop, true, dMin);
52329      } else if (hullBottom[0][1] > dMax) {
52330        return clipConvexHullPart(hullBottom, false, dMax);
52331      } else {
52332        return hullTop[0][0];
52333      }
52334    }
52335
52336    function clipConvexHullPart(part, top, threshold) {
52337      var px = part[0][0],
52338          py = part[0][1];
52339
52340      for (var i = 1, l = part.length; i < l; i++) {
52341        var qx = part[i][0],
52342            qy = part[i][1];
52343
52344        if (top ? qy >= threshold : qy <= threshold) {
52345          return qy === threshold ? qx : px + (threshold - py) * (qx - px) / (qy - py);
52346        }
52347
52348        px = qx;
52349        py = qy;
52350      }
52351
52352      return null;
52353    }
52354
52355    function getCurveLineIntersections(v, px, py, vx, vy) {
52356      var isZero = Numerical.isZero;
52357
52358      if (isZero(vx) && isZero(vy)) {
52359        var t = Curve.getTimeOf(v, new Point(px, py));
52360        return t === null ? [] : [t];
52361      }
52362
52363      var angle = Math.atan2(-vy, vx),
52364          sin = Math.sin(angle),
52365          cos = Math.cos(angle),
52366          rv = [],
52367          roots = [];
52368
52369      for (var i = 0; i < 8; i += 2) {
52370        var x = v[i] - px,
52371            y = v[i + 1] - py;
52372        rv.push(x * cos - y * sin, x * sin + y * cos);
52373      }
52374
52375      Curve.solveCubic(rv, 1, 0, roots, 0, 1);
52376      return roots;
52377    }
52378
52379    function addCurveLineIntersections(v1, v2, c1, c2, locations, include, flip) {
52380      var x1 = v2[0],
52381          y1 = v2[1],
52382          x2 = v2[6],
52383          y2 = v2[7],
52384          roots = getCurveLineIntersections(v1, x1, y1, x2 - x1, y2 - y1);
52385
52386      for (var i = 0, l = roots.length; i < l; i++) {
52387        var t1 = roots[i],
52388            p1 = Curve.getPoint(v1, t1),
52389            t2 = Curve.getTimeOf(v2, p1);
52390
52391        if (t2 !== null) {
52392          addLocation(locations, include, flip ? c2 : c1, flip ? t2 : t1, flip ? c1 : c2, flip ? t1 : t2);
52393        }
52394      }
52395    }
52396
52397    function addLineIntersection(v1, v2, c1, c2, locations, include) {
52398      var pt = Line.intersect(v1[0], v1[1], v1[6], v1[7], v2[0], v2[1], v2[6], v2[7]);
52399
52400      if (pt) {
52401        addLocation(locations, include, c1, Curve.getTimeOf(v1, pt), c2, Curve.getTimeOf(v2, pt));
52402      }
52403    }
52404
52405    function getCurveIntersections(v1, v2, c1, c2, locations, include) {
52406      var epsilon = 1e-12,
52407          min = Math.min,
52408          max = Math.max;
52409
52410      if (max(v1[0], v1[2], v1[4], v1[6]) + epsilon > min(v2[0], v2[2], v2[4], v2[6]) && min(v1[0], v1[2], v1[4], v1[6]) - epsilon < max(v2[0], v2[2], v2[4], v2[6]) && max(v1[1], v1[3], v1[5], v1[7]) + epsilon > min(v2[1], v2[3], v2[5], v2[7]) && min(v1[1], v1[3], v1[5], v1[7]) - epsilon < max(v2[1], v2[3], v2[5], v2[7])) {
52411        var overlaps = getOverlaps(v1, v2);
52412
52413        if (overlaps) {
52414          for (var i = 0; i < 2; i++) {
52415            var overlap = overlaps[i];
52416            addLocation(locations, include, c1, overlap[0], c2, overlap[1], true);
52417          }
52418        } else {
52419          var straight1 = Curve.isStraight(v1),
52420              straight2 = Curve.isStraight(v2),
52421              straight = straight1 && straight2,
52422              flip = straight1 && !straight2,
52423              before = locations.length;
52424          (straight ? addLineIntersection : straight1 || straight2 ? addCurveLineIntersections : addCurveIntersections)(flip ? v2 : v1, flip ? v1 : v2, flip ? c2 : c1, flip ? c1 : c2, locations, include, flip, 0, 0, 0, 1, 0, 1);
52425
52426          if (!straight || locations.length === before) {
52427            for (var i = 0; i < 4; i++) {
52428              var t1 = i >> 1,
52429                  t2 = i & 1,
52430                  i1 = t1 * 6,
52431                  i2 = t2 * 6,
52432                  p1 = new Point(v1[i1], v1[i1 + 1]),
52433                  p2 = new Point(v2[i2], v2[i2 + 1]);
52434
52435              if (p1.isClose(p2, epsilon)) {
52436                addLocation(locations, include, c1, t1, c2, t2);
52437              }
52438            }
52439          }
52440        }
52441      }
52442
52443      return locations;
52444    }
52445
52446    function getSelfIntersection(v1, c1, locations, include) {
52447      var info = Curve.classify(v1);
52448
52449      if (info.type === 'loop') {
52450        var roots = info.roots;
52451        addLocation(locations, include, c1, roots[0], c1, roots[1]);
52452      }
52453
52454      return locations;
52455    }
52456
52457    function getIntersections(curves1, curves2, include, matrix1, matrix2, _returnFirst) {
52458      var epsilon = 1e-7,
52459          self = !curves2;
52460      if (self) curves2 = curves1;
52461      var length1 = curves1.length,
52462          length2 = curves2.length,
52463          values1 = new Array(length1),
52464          values2 = self ? values1 : new Array(length2),
52465          locations = [];
52466
52467      for (var i = 0; i < length1; i++) {
52468        values1[i] = curves1[i].getValues(matrix1);
52469      }
52470
52471      if (!self) {
52472        for (var i = 0; i < length2; i++) {
52473          values2[i] = curves2[i].getValues(matrix2);
52474        }
52475      }
52476
52477      var boundsCollisions = CollisionDetection.findCurveBoundsCollisions(values1, values2, epsilon);
52478
52479      for (var index1 = 0; index1 < length1; index1++) {
52480        var curve1 = curves1[index1],
52481            v1 = values1[index1];
52482
52483        if (self) {
52484          getSelfIntersection(v1, curve1, locations, include);
52485        }
52486
52487        var collisions1 = boundsCollisions[index1];
52488
52489        if (collisions1) {
52490          for (var j = 0; j < collisions1.length; j++) {
52491            if (_returnFirst && locations.length) return locations;
52492            var index2 = collisions1[j];
52493
52494            if (!self || index2 > index1) {
52495              var curve2 = curves2[index2],
52496                  v2 = values2[index2];
52497              getCurveIntersections(v1, v2, curve1, curve2, locations, include);
52498            }
52499          }
52500        }
52501      }
52502
52503      return locations;
52504    }
52505
52506    function getOverlaps(v1, v2) {
52507      function getSquaredLineLength(v) {
52508        var x = v[6] - v[0],
52509            y = v[7] - v[1];
52510        return x * x + y * y;
52511      }
52512
52513      var abs = Math.abs,
52514          getDistance = Line.getDistance,
52515          timeEpsilon = 1e-8,
52516          geomEpsilon = 1e-7,
52517          straight1 = Curve.isStraight(v1),
52518          straight2 = Curve.isStraight(v2),
52519          straightBoth = straight1 && straight2,
52520          flip = getSquaredLineLength(v1) < getSquaredLineLength(v2),
52521          l1 = flip ? v2 : v1,
52522          l2 = flip ? v1 : v2,
52523          px = l1[0],
52524          py = l1[1],
52525          vx = l1[6] - px,
52526          vy = l1[7] - py;
52527
52528      if (getDistance(px, py, vx, vy, l2[0], l2[1], true) < geomEpsilon && getDistance(px, py, vx, vy, l2[6], l2[7], true) < geomEpsilon) {
52529        if (!straightBoth && getDistance(px, py, vx, vy, l1[2], l1[3], true) < geomEpsilon && getDistance(px, py, vx, vy, l1[4], l1[5], true) < geomEpsilon && getDistance(px, py, vx, vy, l2[2], l2[3], true) < geomEpsilon && getDistance(px, py, vx, vy, l2[4], l2[5], true) < geomEpsilon) {
52530          straight1 = straight2 = straightBoth = true;
52531        }
52532      } else if (straightBoth) {
52533        return null;
52534      }
52535
52536      if (straight1 ^ straight2) {
52537        return null;
52538      }
52539
52540      var v = [v1, v2],
52541          pairs = [];
52542
52543      for (var i = 0; i < 4 && pairs.length < 2; i++) {
52544        var i1 = i & 1,
52545            i2 = i1 ^ 1,
52546            t1 = i >> 1,
52547            t2 = Curve.getTimeOf(v[i1], new Point(v[i2][t1 ? 6 : 0], v[i2][t1 ? 7 : 1]));
52548
52549        if (t2 != null) {
52550          var pair = i1 ? [t1, t2] : [t2, t1];
52551
52552          if (!pairs.length || abs(pair[0] - pairs[0][0]) > timeEpsilon && abs(pair[1] - pairs[0][1]) > timeEpsilon) {
52553            pairs.push(pair);
52554          }
52555        }
52556
52557        if (i > 2 && !pairs.length) break;
52558      }
52559
52560      if (pairs.length !== 2) {
52561        pairs = null;
52562      } else if (!straightBoth) {
52563        var o1 = Curve.getPart(v1, pairs[0][0], pairs[1][0]),
52564            o2 = Curve.getPart(v2, pairs[0][1], pairs[1][1]);
52565        if (abs(o2[2] - o1[2]) > geomEpsilon || abs(o2[3] - o1[3]) > geomEpsilon || abs(o2[4] - o1[4]) > geomEpsilon || abs(o2[5] - o1[5]) > geomEpsilon) pairs = null;
52566      }
52567
52568      return pairs;
52569    }
52570
52571    function getTimesWithTangent(v, tangent) {
52572      var x0 = v[0],
52573          y0 = v[1],
52574          x1 = v[2],
52575          y1 = v[3],
52576          x2 = v[4],
52577          y2 = v[5],
52578          x3 = v[6],
52579          y3 = v[7],
52580          normalized = tangent.normalize(),
52581          tx = normalized.x,
52582          ty = normalized.y,
52583          ax = 3 * x3 - 9 * x2 + 9 * x1 - 3 * x0,
52584          ay = 3 * y3 - 9 * y2 + 9 * y1 - 3 * y0,
52585          bx = 6 * x2 - 12 * x1 + 6 * x0,
52586          by = 6 * y2 - 12 * y1 + 6 * y0,
52587          cx = 3 * x1 - 3 * x0,
52588          cy = 3 * y1 - 3 * y0,
52589          den = 2 * ax * ty - 2 * ay * tx,
52590          times = [];
52591
52592      if (Math.abs(den) < Numerical.CURVETIME_EPSILON) {
52593        var num = ax * cy - ay * cx,
52594            den = ax * by - ay * bx;
52595
52596        if (den != 0) {
52597          var t = -num / den;
52598          if (t >= 0 && t <= 1) times.push(t);
52599        }
52600      } else {
52601        var delta = (bx * bx - 4 * ax * cx) * ty * ty + (-2 * bx * by + 4 * ay * cx + 4 * ax * cy) * tx * ty + (by * by - 4 * ay * cy) * tx * tx,
52602            k = bx * ty - by * tx;
52603
52604        if (delta >= 0 && den != 0) {
52605          var d = Math.sqrt(delta),
52606              t0 = -(k + d) / den,
52607              t1 = (-k + d) / den;
52608          if (t0 >= 0 && t0 <= 1) times.push(t0);
52609          if (t1 >= 0 && t1 <= 1) times.push(t1);
52610        }
52611      }
52612
52613      return times;
52614    }
52615
52616    return {
52617      getIntersections: function getIntersections(curve) {
52618        var v1 = this.getValues(),
52619            v2 = curve && curve !== this && curve.getValues();
52620        return v2 ? getCurveIntersections(v1, v2, this, curve, []) : getSelfIntersection(v1, this, []);
52621      },
52622      statics: {
52623        getOverlaps: getOverlaps,
52624        getIntersections: getIntersections,
52625        getCurveLineIntersections: getCurveLineIntersections,
52626        getTimesWithTangent: getTimesWithTangent
52627      }
52628    };
52629  }());
52630  var CurveLocation = Base.extend({
52631    _class: 'CurveLocation',
52632    initialize: function CurveLocation(curve, time, point, _overlap, _distance) {
52633      if (time >= 0.99999999) {
52634        var next = curve.getNext();
52635
52636        if (next) {
52637          time = 0;
52638          curve = next;
52639        }
52640      }
52641
52642      this._setCurve(curve);
52643
52644      this._time = time;
52645      this._point = point || curve.getPointAtTime(time);
52646      this._overlap = _overlap;
52647      this._distance = _distance;
52648      this._intersection = this._next = this._previous = null;
52649    },
52650    _setCurve: function _setCurve(curve) {
52651      var path = curve._path;
52652      this._path = path;
52653      this._version = path ? path._version : 0;
52654      this._curve = curve;
52655      this._segment = null;
52656      this._segment1 = curve._segment1;
52657      this._segment2 = curve._segment2;
52658    },
52659    _setSegment: function _setSegment(segment) {
52660      this._setCurve(segment.getCurve());
52661
52662      this._segment = segment;
52663      this._time = segment === this._segment1 ? 0 : 1;
52664      this._point = segment._point.clone();
52665    },
52666    getSegment: function getSegment() {
52667      var segment = this._segment;
52668
52669      if (!segment) {
52670        var curve = this.getCurve(),
52671            time = this.getTime();
52672
52673        if (time === 0) {
52674          segment = curve._segment1;
52675        } else if (time === 1) {
52676          segment = curve._segment2;
52677        } else if (time != null) {
52678          segment = curve.getPartLength(0, time) < curve.getPartLength(time, 1) ? curve._segment1 : curve._segment2;
52679        }
52680
52681        this._segment = segment;
52682      }
52683
52684      return segment;
52685    },
52686    getCurve: function getCurve() {
52687      var path = this._path,
52688          that = this;
52689
52690      if (path && path._version !== this._version) {
52691        this._time = this._offset = this._curveOffset = this._curve = null;
52692      }
52693
52694      function trySegment(segment) {
52695        var curve = segment && segment.getCurve();
52696
52697        if (curve && (that._time = curve.getTimeOf(that._point)) != null) {
52698          that._setCurve(curve);
52699
52700          return curve;
52701        }
52702      }
52703
52704      return this._curve || trySegment(this._segment) || trySegment(this._segment1) || trySegment(this._segment2.getPrevious());
52705    },
52706    getPath: function getPath() {
52707      var curve = this.getCurve();
52708      return curve && curve._path;
52709    },
52710    getIndex: function getIndex() {
52711      var curve = this.getCurve();
52712      return curve && curve.getIndex();
52713    },
52714    getTime: function getTime() {
52715      var curve = this.getCurve(),
52716          time = this._time;
52717      return curve && time == null ? this._time = curve.getTimeOf(this._point) : time;
52718    },
52719    getParameter: '#getTime',
52720    getPoint: function getPoint() {
52721      return this._point;
52722    },
52723    getOffset: function getOffset() {
52724      var offset = this._offset;
52725
52726      if (offset == null) {
52727        offset = 0;
52728        var path = this.getPath(),
52729            index = this.getIndex();
52730
52731        if (path && index != null) {
52732          var curves = path.getCurves();
52733
52734          for (var i = 0; i < index; i++) {
52735            offset += curves[i].getLength();
52736          }
52737        }
52738
52739        this._offset = offset += this.getCurveOffset();
52740      }
52741
52742      return offset;
52743    },
52744    getCurveOffset: function getCurveOffset() {
52745      var offset = this._curveOffset;
52746
52747      if (offset == null) {
52748        var curve = this.getCurve(),
52749            time = this.getTime();
52750        this._curveOffset = offset = time != null && curve && curve.getPartLength(0, time);
52751      }
52752
52753      return offset;
52754    },
52755    getIntersection: function getIntersection() {
52756      return this._intersection;
52757    },
52758    getDistance: function getDistance() {
52759      return this._distance;
52760    },
52761    divide: function divide() {
52762      var curve = this.getCurve(),
52763          res = curve && curve.divideAtTime(this.getTime());
52764
52765      if (res) {
52766        this._setSegment(res._segment1);
52767      }
52768
52769      return res;
52770    },
52771    split: function split() {
52772      var curve = this.getCurve(),
52773          path = curve._path,
52774          res = curve && curve.splitAtTime(this.getTime());
52775
52776      if (res) {
52777        this._setSegment(path.getLastSegment());
52778      }
52779
52780      return res;
52781    },
52782    equals: function equals(loc, _ignoreOther) {
52783      var res = this === loc;
52784
52785      if (!res && loc instanceof CurveLocation) {
52786        var c1 = this.getCurve(),
52787            c2 = loc.getCurve(),
52788            p1 = c1._path,
52789            p2 = c2._path;
52790
52791        if (p1 === p2) {
52792          var abs = Math.abs,
52793              epsilon = 1e-7,
52794              diff = abs(this.getOffset() - loc.getOffset()),
52795              i1 = !_ignoreOther && this._intersection,
52796              i2 = !_ignoreOther && loc._intersection;
52797          res = (diff < epsilon || p1 && abs(p1.getLength() - diff) < epsilon) && (!i1 && !i2 || i1 && i2 && i1.equals(i2, true));
52798        }
52799      }
52800
52801      return res;
52802    },
52803    toString: function toString() {
52804      var parts = [],
52805          point = this.getPoint(),
52806          f = Formatter.instance;
52807      if (point) parts.push('point: ' + point);
52808      var index = this.getIndex();
52809      if (index != null) parts.push('index: ' + index);
52810      var time = this.getTime();
52811      if (time != null) parts.push('time: ' + f.number(time));
52812      if (this._distance != null) parts.push('distance: ' + f.number(this._distance));
52813      return '{ ' + parts.join(', ') + ' }';
52814    },
52815    isTouching: function isTouching() {
52816      var inter = this._intersection;
52817
52818      if (inter && this.getTangent().isCollinear(inter.getTangent())) {
52819        var curve1 = this.getCurve(),
52820            curve2 = inter.getCurve();
52821        return !(curve1.isStraight() && curve2.isStraight() && curve1.getLine().intersect(curve2.getLine()));
52822      }
52823
52824      return false;
52825    },
52826    isCrossing: function isCrossing() {
52827      var inter = this._intersection;
52828      if (!inter) return false;
52829      var t1 = this.getTime(),
52830          t2 = inter.getTime(),
52831          tMin = 1e-8,
52832          tMax = 1 - tMin,
52833          t1Inside = t1 >= tMin && t1 <= tMax,
52834          t2Inside = t2 >= tMin && t2 <= tMax;
52835      if (t1Inside && t2Inside) return !this.isTouching();
52836      var c2 = this.getCurve(),
52837          c1 = c2 && t1 < tMin ? c2.getPrevious() : c2,
52838          c4 = inter.getCurve(),
52839          c3 = c4 && t2 < tMin ? c4.getPrevious() : c4;
52840      if (t1 > tMax) c2 = c2.getNext();
52841      if (t2 > tMax) c4 = c4.getNext();
52842      if (!c1 || !c2 || !c3 || !c4) return false;
52843      var offsets = [];
52844
52845      function addOffsets(curve, end) {
52846        var v = curve.getValues(),
52847            roots = Curve.classify(v).roots || Curve.getPeaks(v),
52848            count = roots.length,
52849            offset = Curve.getLength(v, end && count ? roots[count - 1] : 0, !end && count ? roots[0] : 1);
52850        offsets.push(count ? offset : offset / 64);
52851      }
52852
52853      function isInRange(angle, min, max) {
52854        return min < max ? angle > min && angle < max : angle > min || angle < max;
52855      }
52856
52857      if (!t1Inside) {
52858        addOffsets(c1, true);
52859        addOffsets(c2, false);
52860      }
52861
52862      if (!t2Inside) {
52863        addOffsets(c3, true);
52864        addOffsets(c4, false);
52865      }
52866
52867      var pt = this.getPoint(),
52868          offset = Math.min.apply(Math, offsets),
52869          v2 = t1Inside ? c2.getTangentAtTime(t1) : c2.getPointAt(offset).subtract(pt),
52870          v1 = t1Inside ? v2.negate() : c1.getPointAt(-offset).subtract(pt),
52871          v4 = t2Inside ? c4.getTangentAtTime(t2) : c4.getPointAt(offset).subtract(pt),
52872          v3 = t2Inside ? v4.negate() : c3.getPointAt(-offset).subtract(pt),
52873          a1 = v1.getAngle(),
52874          a2 = v2.getAngle(),
52875          a3 = v3.getAngle(),
52876          a4 = v4.getAngle();
52877      return !!(t1Inside ? isInRange(a1, a3, a4) ^ isInRange(a2, a3, a4) && isInRange(a1, a4, a3) ^ isInRange(a2, a4, a3) : isInRange(a3, a1, a2) ^ isInRange(a4, a1, a2) && isInRange(a3, a2, a1) ^ isInRange(a4, a2, a1));
52878    },
52879    hasOverlap: function hasOverlap() {
52880      return !!this._overlap;
52881    }
52882  }, Base.each(Curve._evaluateMethods, function (name) {
52883    var get = name + 'At';
52884
52885    this[name] = function () {
52886      var curve = this.getCurve(),
52887          time = this.getTime();
52888      return time != null && curve && curve[get](time, true);
52889    };
52890  }, {
52891    preserve: true
52892  }), new function () {
52893    function insert(locations, loc, merge) {
52894      var length = locations.length,
52895          l = 0,
52896          r = length - 1;
52897
52898      function search(index, dir) {
52899        for (var i = index + dir; i >= -1 && i <= length; i += dir) {
52900          var loc2 = locations[(i % length + length) % length];
52901          if (!loc.getPoint().isClose(loc2.getPoint(), 1e-7)) break;
52902          if (loc.equals(loc2)) return loc2;
52903        }
52904
52905        return null;
52906      }
52907
52908      while (l <= r) {
52909        var m = l + r >>> 1,
52910            loc2 = locations[m],
52911            found;
52912
52913        if (merge && (found = loc.equals(loc2) ? loc2 : search(m, -1) || search(m, 1))) {
52914          if (loc._overlap) {
52915            found._overlap = found._intersection._overlap = true;
52916          }
52917
52918          return found;
52919        }
52920
52921        var path1 = loc.getPath(),
52922            path2 = loc2.getPath(),
52923            diff = path1 !== path2 ? path1._id - path2._id : loc.getIndex() + loc.getTime() - (loc2.getIndex() + loc2.getTime());
52924
52925        if (diff < 0) {
52926          r = m - 1;
52927        } else {
52928          l = m + 1;
52929        }
52930      }
52931
52932      locations.splice(l, 0, loc);
52933      return loc;
52934    }
52935
52936    return {
52937      statics: {
52938        insert: insert,
52939        expand: function expand(locations) {
52940          var expanded = locations.slice();
52941
52942          for (var i = locations.length - 1; i >= 0; i--) {
52943            insert(expanded, locations[i]._intersection, false);
52944          }
52945
52946          return expanded;
52947        }
52948      }
52949    };
52950  }());
52951  var PathItem = Item.extend({
52952    _class: 'PathItem',
52953    _selectBounds: false,
52954    _canScaleStroke: true,
52955    beans: true,
52956    initialize: function PathItem() {},
52957    statics: {
52958      create: function create(arg) {
52959        var data, segments, compound;
52960
52961        if (Base.isPlainObject(arg)) {
52962          segments = arg.segments;
52963          data = arg.pathData;
52964        } else if (Array.isArray(arg)) {
52965          segments = arg;
52966        } else if (typeof arg === 'string') {
52967          data = arg;
52968        }
52969
52970        if (segments) {
52971          var first = segments[0];
52972          compound = first && Array.isArray(first[0]);
52973        } else if (data) {
52974          compound = (data.match(/m/gi) || []).length > 1 || /z\s*\S+/i.test(data);
52975        }
52976
52977        var ctor = compound ? CompoundPath : Path;
52978        return new ctor(arg);
52979      }
52980    },
52981    _asPathItem: function _asPathItem() {
52982      return this;
52983    },
52984    isClockwise: function isClockwise() {
52985      return this.getArea() >= 0;
52986    },
52987    setClockwise: function setClockwise(clockwise) {
52988      if (this.isClockwise() != (clockwise = !!clockwise)) this.reverse();
52989    },
52990    setPathData: function setPathData(data) {
52991      var parts = data && data.match(/[mlhvcsqtaz][^mlhvcsqtaz]*/ig),
52992          coords,
52993          relative = false,
52994          previous,
52995          control,
52996          current = new Point(),
52997          start = new Point();
52998
52999      function getCoord(index, coord) {
53000        var val = +coords[index];
53001        if (relative) val += current[coord];
53002        return val;
53003      }
53004
53005      function getPoint(index) {
53006        return new Point(getCoord(index, 'x'), getCoord(index + 1, 'y'));
53007      }
53008
53009      this.clear();
53010
53011      for (var i = 0, l = parts && parts.length; i < l; i++) {
53012        var part = parts[i],
53013            command = part[0],
53014            lower = command.toLowerCase();
53015        coords = part.match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g);
53016        var length = coords && coords.length;
53017        relative = command === lower;
53018        if (previous === 'z' && !/[mz]/.test(lower)) this.moveTo(current);
53019
53020        switch (lower) {
53021          case 'm':
53022          case 'l':
53023            var move = lower === 'm';
53024
53025            for (var j = 0; j < length; j += 2) {
53026              this[move ? 'moveTo' : 'lineTo'](current = getPoint(j));
53027
53028              if (move) {
53029                start = current;
53030                move = false;
53031              }
53032            }
53033
53034            control = current;
53035            break;
53036
53037          case 'h':
53038          case 'v':
53039            var coord = lower === 'h' ? 'x' : 'y';
53040            current = current.clone();
53041
53042            for (var j = 0; j < length; j++) {
53043              current[coord] = getCoord(j, coord);
53044              this.lineTo(current);
53045            }
53046
53047            control = current;
53048            break;
53049
53050          case 'c':
53051            for (var j = 0; j < length; j += 6) {
53052              this.cubicCurveTo(getPoint(j), control = getPoint(j + 2), current = getPoint(j + 4));
53053            }
53054
53055            break;
53056
53057          case 's':
53058            for (var j = 0; j < length; j += 4) {
53059              this.cubicCurveTo(/[cs]/.test(previous) ? current.multiply(2).subtract(control) : current, control = getPoint(j), current = getPoint(j + 2));
53060              previous = lower;
53061            }
53062
53063            break;
53064
53065          case 'q':
53066            for (var j = 0; j < length; j += 4) {
53067              this.quadraticCurveTo(control = getPoint(j), current = getPoint(j + 2));
53068            }
53069
53070            break;
53071
53072          case 't':
53073            for (var j = 0; j < length; j += 2) {
53074              this.quadraticCurveTo(control = /[qt]/.test(previous) ? current.multiply(2).subtract(control) : current, current = getPoint(j));
53075              previous = lower;
53076            }
53077
53078            break;
53079
53080          case 'a':
53081            for (var j = 0; j < length; j += 7) {
53082              this.arcTo(current = getPoint(j + 5), new Size(+coords[j], +coords[j + 1]), +coords[j + 2], +coords[j + 4], +coords[j + 3]);
53083            }
53084
53085            break;
53086
53087          case 'z':
53088            this.closePath(1e-12);
53089            current = start;
53090            break;
53091        }
53092
53093        previous = lower;
53094      }
53095    },
53096    _canComposite: function _canComposite() {
53097      return !(this.hasFill() && this.hasStroke());
53098    },
53099    _contains: function _contains(point) {
53100      var winding = point.isInside(this.getBounds({
53101        internal: true,
53102        handle: true
53103      })) ? this._getWinding(point) : {};
53104      return winding.onPath || !!(this.getFillRule() === 'evenodd' ? winding.windingL & 1 || winding.windingR & 1 : winding.winding);
53105    },
53106    getIntersections: function getIntersections(path, include, _matrix, _returnFirst) {
53107      var self = this === path || !path,
53108          matrix1 = this._matrix._orNullIfIdentity(),
53109          matrix2 = self ? matrix1 : (_matrix || path._matrix)._orNullIfIdentity();
53110
53111      return self || this.getBounds(matrix1).intersects(path.getBounds(matrix2), 1e-12) ? Curve.getIntersections(this.getCurves(), !self && path.getCurves(), include, matrix1, matrix2, _returnFirst) : [];
53112    },
53113    getCrossings: function getCrossings(path) {
53114      return this.getIntersections(path, function (inter) {
53115        return inter.isCrossing();
53116      });
53117    },
53118    getNearestLocation: function getNearestLocation() {
53119      var point = Point.read(arguments),
53120          curves = this.getCurves(),
53121          minDist = Infinity,
53122          minLoc = null;
53123
53124      for (var i = 0, l = curves.length; i < l; i++) {
53125        var loc = curves[i].getNearestLocation(point);
53126
53127        if (loc._distance < minDist) {
53128          minDist = loc._distance;
53129          minLoc = loc;
53130        }
53131      }
53132
53133      return minLoc;
53134    },
53135    getNearestPoint: function getNearestPoint() {
53136      var loc = this.getNearestLocation.apply(this, arguments);
53137      return loc ? loc.getPoint() : loc;
53138    },
53139    interpolate: function interpolate(from, to, factor) {
53140      var isPath = !this._children,
53141          name = isPath ? '_segments' : '_children',
53142          itemsFrom = from[name],
53143          itemsTo = to[name],
53144          items = this[name];
53145
53146      if (!itemsFrom || !itemsTo || itemsFrom.length !== itemsTo.length) {
53147        throw new Error('Invalid operands in interpolate() call: ' + from + ', ' + to);
53148      }
53149
53150      var current = items.length,
53151          length = itemsTo.length;
53152
53153      if (current < length) {
53154        var ctor = isPath ? Segment : Path;
53155
53156        for (var i = current; i < length; i++) {
53157          this.add(new ctor());
53158        }
53159      } else if (current > length) {
53160        this[isPath ? 'removeSegments' : 'removeChildren'](length, current);
53161      }
53162
53163      for (var i = 0; i < length; i++) {
53164        items[i].interpolate(itemsFrom[i], itemsTo[i], factor);
53165      }
53166
53167      if (isPath) {
53168        this.setClosed(from._closed);
53169
53170        this._changed(9);
53171      }
53172    },
53173    compare: function compare(path) {
53174      var ok = false;
53175
53176      if (path) {
53177        var paths1 = this._children || [this],
53178            paths2 = path._children ? path._children.slice() : [path],
53179            length1 = paths1.length,
53180            length2 = paths2.length,
53181            matched = [],
53182            count = 0;
53183        ok = true;
53184        var boundsOverlaps = CollisionDetection.findBoundsOverlaps(paths1, paths2, Numerical.GEOMETRIC_EPSILON);
53185
53186        for (var i1 = length1 - 1; i1 >= 0 && ok; i1--) {
53187          var path1 = paths1[i1];
53188          ok = false;
53189          var pathBoundsOverlaps = boundsOverlaps[i1];
53190
53191          if (pathBoundsOverlaps) {
53192            for (var i2 = pathBoundsOverlaps.length - 1; i2 >= 0 && !ok; i2--) {
53193              if (path1.compare(paths2[pathBoundsOverlaps[i2]])) {
53194                if (!matched[pathBoundsOverlaps[i2]]) {
53195                  matched[pathBoundsOverlaps[i2]] = true;
53196                  count++;
53197                }
53198
53199                ok = true;
53200              }
53201            }
53202          }
53203        }
53204
53205        ok = ok && count === length2;
53206      }
53207
53208      return ok;
53209    }
53210  });
53211  var Path = PathItem.extend({
53212    _class: 'Path',
53213    _serializeFields: {
53214      segments: [],
53215      closed: false
53216    },
53217    initialize: function Path(arg) {
53218      this._closed = false;
53219      this._segments = [];
53220      this._version = 0;
53221      var args = arguments,
53222          segments = Array.isArray(arg) ? _typeof(arg[0]) === 'object' ? arg : args : arg && arg.size === undefined && (arg.x !== undefined || arg.point !== undefined) ? args : null;
53223
53224      if (segments && segments.length > 0) {
53225        this.setSegments(segments);
53226      } else {
53227        this._curves = undefined;
53228        this._segmentSelection = 0;
53229
53230        if (!segments && typeof arg === 'string') {
53231          this.setPathData(arg);
53232          arg = null;
53233        }
53234      }
53235
53236      this._initialize(!segments && arg);
53237    },
53238    _equals: function _equals(item) {
53239      return this._closed === item._closed && Base.equals(this._segments, item._segments);
53240    },
53241    copyContent: function copyContent(source) {
53242      this.setSegments(source._segments);
53243      this._closed = source._closed;
53244    },
53245    _changed: function _changed(flags) {
53246      _changed.base.call(this, flags);
53247
53248      if (flags & 8) {
53249        this._length = this._area = undefined;
53250
53251        if (flags & 32) {
53252          this._version++;
53253        } else if (this._curves) {
53254          for (var i = 0, l = this._curves.length; i < l; i++) {
53255            this._curves[i]._changed();
53256          }
53257        }
53258      } else if (flags & 64) {
53259        this._bounds = undefined;
53260      }
53261    },
53262    getStyle: function getStyle() {
53263      var parent = this._parent;
53264      return (parent instanceof CompoundPath ? parent : this)._style;
53265    },
53266    getSegments: function getSegments() {
53267      return this._segments;
53268    },
53269    setSegments: function setSegments(segments) {
53270      var fullySelected = this.isFullySelected(),
53271          length = segments && segments.length;
53272      this._segments.length = 0;
53273      this._segmentSelection = 0;
53274      this._curves = undefined;
53275
53276      if (length) {
53277        var last = segments[length - 1];
53278
53279        if (typeof last === 'boolean') {
53280          this.setClosed(last);
53281          length--;
53282        }
53283
53284        this._add(Segment.readList(segments, 0, {}, length));
53285      }
53286
53287      if (fullySelected) this.setFullySelected(true);
53288    },
53289    getFirstSegment: function getFirstSegment() {
53290      return this._segments[0];
53291    },
53292    getLastSegment: function getLastSegment() {
53293      return this._segments[this._segments.length - 1];
53294    },
53295    getCurves: function getCurves() {
53296      var curves = this._curves,
53297          segments = this._segments;
53298
53299      if (!curves) {
53300        var length = this._countCurves();
53301
53302        curves = this._curves = new Array(length);
53303
53304        for (var i = 0; i < length; i++) {
53305          curves[i] = new Curve(this, segments[i], segments[i + 1] || segments[0]);
53306        }
53307      }
53308
53309      return curves;
53310    },
53311    getFirstCurve: function getFirstCurve() {
53312      return this.getCurves()[0];
53313    },
53314    getLastCurve: function getLastCurve() {
53315      var curves = this.getCurves();
53316      return curves[curves.length - 1];
53317    },
53318    isClosed: function isClosed() {
53319      return this._closed;
53320    },
53321    setClosed: function setClosed(closed) {
53322      if (this._closed != (closed = !!closed)) {
53323        this._closed = closed;
53324
53325        if (this._curves) {
53326          var length = this._curves.length = this._countCurves();
53327
53328          if (closed) this._curves[length - 1] = new Curve(this, this._segments[length - 1], this._segments[0]);
53329        }
53330
53331        this._changed(41);
53332      }
53333    }
53334  }, {
53335    beans: true,
53336    getPathData: function getPathData(_matrix, _precision) {
53337      var segments = this._segments,
53338          length = segments.length,
53339          f = new Formatter(_precision),
53340          coords = new Array(6),
53341          first = true,
53342          curX,
53343          curY,
53344          prevX,
53345          prevY,
53346          inX,
53347          inY,
53348          outX,
53349          outY,
53350          parts = [];
53351
53352      function addSegment(segment, skipLine) {
53353        segment._transformCoordinates(_matrix, coords);
53354
53355        curX = coords[0];
53356        curY = coords[1];
53357
53358        if (first) {
53359          parts.push('M' + f.pair(curX, curY));
53360          first = false;
53361        } else {
53362          inX = coords[2];
53363          inY = coords[3];
53364
53365          if (inX === curX && inY === curY && outX === prevX && outY === prevY) {
53366            if (!skipLine) {
53367              var dx = curX - prevX,
53368                  dy = curY - prevY;
53369              parts.push(dx === 0 ? 'v' + f.number(dy) : dy === 0 ? 'h' + f.number(dx) : 'l' + f.pair(dx, dy));
53370            }
53371          } else {
53372            parts.push('c' + f.pair(outX - prevX, outY - prevY) + ' ' + f.pair(inX - prevX, inY - prevY) + ' ' + f.pair(curX - prevX, curY - prevY));
53373          }
53374        }
53375
53376        prevX = curX;
53377        prevY = curY;
53378        outX = coords[4];
53379        outY = coords[5];
53380      }
53381
53382      if (!length) return '';
53383
53384      for (var i = 0; i < length; i++) {
53385        addSegment(segments[i]);
53386      }
53387
53388      if (this._closed && length > 0) {
53389        addSegment(segments[0], true);
53390        parts.push('z');
53391      }
53392
53393      return parts.join('');
53394    },
53395    isEmpty: function isEmpty() {
53396      return !this._segments.length;
53397    },
53398    _transformContent: function _transformContent(matrix) {
53399      var segments = this._segments,
53400          coords = new Array(6);
53401
53402      for (var i = 0, l = segments.length; i < l; i++) {
53403        segments[i]._transformCoordinates(matrix, coords, true);
53404      }
53405
53406      return true;
53407    },
53408    _add: function _add(segs, index) {
53409      var segments = this._segments,
53410          curves = this._curves,
53411          amount = segs.length,
53412          append = index == null,
53413          index = append ? segments.length : index;
53414
53415      for (var i = 0; i < amount; i++) {
53416        var segment = segs[i];
53417        if (segment._path) segment = segs[i] = segment.clone();
53418        segment._path = this;
53419        segment._index = index + i;
53420        if (segment._selection) this._updateSelection(segment, 0, segment._selection);
53421      }
53422
53423      if (append) {
53424        Base.push(segments, segs);
53425      } else {
53426        segments.splice.apply(segments, [index, 0].concat(segs));
53427
53428        for (var i = index + amount, l = segments.length; i < l; i++) {
53429          segments[i]._index = i;
53430        }
53431      }
53432
53433      if (curves) {
53434        var total = this._countCurves(),
53435            start = index > 0 && index + amount - 1 === total ? index - 1 : index,
53436            insert = start,
53437            end = Math.min(start + amount, total);
53438
53439        if (segs._curves) {
53440          curves.splice.apply(curves, [start, 0].concat(segs._curves));
53441          insert += segs._curves.length;
53442        }
53443
53444        for (var i = insert; i < end; i++) {
53445          curves.splice(i, 0, new Curve(this, null, null));
53446        }
53447
53448        this._adjustCurves(start, end);
53449      }
53450
53451      this._changed(41);
53452
53453      return segs;
53454    },
53455    _adjustCurves: function _adjustCurves(start, end) {
53456      var segments = this._segments,
53457          curves = this._curves,
53458          curve;
53459
53460      for (var i = start; i < end; i++) {
53461        curve = curves[i];
53462        curve._path = this;
53463        curve._segment1 = segments[i];
53464        curve._segment2 = segments[i + 1] || segments[0];
53465
53466        curve._changed();
53467      }
53468
53469      if (curve = curves[this._closed && !start ? segments.length - 1 : start - 1]) {
53470        curve._segment2 = segments[start] || segments[0];
53471
53472        curve._changed();
53473      }
53474
53475      if (curve = curves[end]) {
53476        curve._segment1 = segments[end];
53477
53478        curve._changed();
53479      }
53480    },
53481    _countCurves: function _countCurves() {
53482      var length = this._segments.length;
53483      return !this._closed && length > 0 ? length - 1 : length;
53484    },
53485    add: function add(segment1) {
53486      var args = arguments;
53487      return args.length > 1 && typeof segment1 !== 'number' ? this._add(Segment.readList(args)) : this._add([Segment.read(args)])[0];
53488    },
53489    insert: function insert(index, segment1) {
53490      var args = arguments;
53491      return args.length > 2 && typeof segment1 !== 'number' ? this._add(Segment.readList(args, 1), index) : this._add([Segment.read(args, 1)], index)[0];
53492    },
53493    addSegment: function addSegment() {
53494      return this._add([Segment.read(arguments)])[0];
53495    },
53496    insertSegment: function insertSegment(index) {
53497      return this._add([Segment.read(arguments, 1)], index)[0];
53498    },
53499    addSegments: function addSegments(segments) {
53500      return this._add(Segment.readList(segments));
53501    },
53502    insertSegments: function insertSegments(index, segments) {
53503      return this._add(Segment.readList(segments), index);
53504    },
53505    removeSegment: function removeSegment(index) {
53506      return this.removeSegments(index, index + 1)[0] || null;
53507    },
53508    removeSegments: function removeSegments(start, end, _includeCurves) {
53509      start = start || 0;
53510      end = Base.pick(end, this._segments.length);
53511      var segments = this._segments,
53512          curves = this._curves,
53513          count = segments.length,
53514          removed = segments.splice(start, end - start),
53515          amount = removed.length;
53516      if (!amount) return removed;
53517
53518      for (var i = 0; i < amount; i++) {
53519        var segment = removed[i];
53520        if (segment._selection) this._updateSelection(segment, segment._selection, 0);
53521        segment._index = segment._path = null;
53522      }
53523
53524      for (var i = start, l = segments.length; i < l; i++) {
53525        segments[i]._index = i;
53526      }
53527
53528      if (curves) {
53529        var index = start > 0 && end === count + (this._closed ? 1 : 0) ? start - 1 : start,
53530            curves = curves.splice(index, amount);
53531
53532        for (var i = curves.length - 1; i >= 0; i--) {
53533          curves[i]._path = null;
53534        }
53535
53536        if (_includeCurves) removed._curves = curves.slice(1);
53537
53538        this._adjustCurves(index, index);
53539      }
53540
53541      this._changed(41);
53542
53543      return removed;
53544    },
53545    clear: '#removeSegments',
53546    hasHandles: function hasHandles() {
53547      var segments = this._segments;
53548
53549      for (var i = 0, l = segments.length; i < l; i++) {
53550        if (segments[i].hasHandles()) return true;
53551      }
53552
53553      return false;
53554    },
53555    clearHandles: function clearHandles() {
53556      var segments = this._segments;
53557
53558      for (var i = 0, l = segments.length; i < l; i++) {
53559        segments[i].clearHandles();
53560      }
53561    },
53562    getLength: function getLength() {
53563      if (this._length == null) {
53564        var curves = this.getCurves(),
53565            length = 0;
53566
53567        for (var i = 0, l = curves.length; i < l; i++) {
53568          length += curves[i].getLength();
53569        }
53570
53571        this._length = length;
53572      }
53573
53574      return this._length;
53575    },
53576    getArea: function getArea() {
53577      var area = this._area;
53578
53579      if (area == null) {
53580        var segments = this._segments,
53581            closed = this._closed;
53582        area = 0;
53583
53584        for (var i = 0, l = segments.length; i < l; i++) {
53585          var last = i + 1 === l;
53586          area += Curve.getArea(Curve.getValues(segments[i], segments[last ? 0 : i + 1], null, last && !closed));
53587        }
53588
53589        this._area = area;
53590      }
53591
53592      return area;
53593    },
53594    isFullySelected: function isFullySelected() {
53595      var length = this._segments.length;
53596      return this.isSelected() && length > 0 && this._segmentSelection === length * 7;
53597    },
53598    setFullySelected: function setFullySelected(selected) {
53599      if (selected) this._selectSegments(true);
53600      this.setSelected(selected);
53601    },
53602    setSelection: function setSelection(selection) {
53603      if (!(selection & 1)) this._selectSegments(false);
53604      setSelection.base.call(this, selection);
53605    },
53606    _selectSegments: function _selectSegments(selected) {
53607      var segments = this._segments,
53608          length = segments.length,
53609          selection = selected ? 7 : 0;
53610      this._segmentSelection = selection * length;
53611
53612      for (var i = 0; i < length; i++) {
53613        segments[i]._selection = selection;
53614      }
53615    },
53616    _updateSelection: function _updateSelection(segment, oldSelection, newSelection) {
53617      segment._selection = newSelection;
53618      var selection = this._segmentSelection += newSelection - oldSelection;
53619      if (selection > 0) this.setSelected(true);
53620    },
53621    divideAt: function divideAt(location) {
53622      var loc = this.getLocationAt(location),
53623          curve;
53624      return loc && (curve = loc.getCurve().divideAt(loc.getCurveOffset())) ? curve._segment1 : null;
53625    },
53626    splitAt: function splitAt(location) {
53627      var loc = this.getLocationAt(location),
53628          index = loc && loc.index,
53629          time = loc && loc.time,
53630          tMin = 1e-8,
53631          tMax = 1 - tMin;
53632
53633      if (time > tMax) {
53634        index++;
53635        time = 0;
53636      }
53637
53638      var curves = this.getCurves();
53639
53640      if (index >= 0 && index < curves.length) {
53641        if (time >= tMin) {
53642          curves[index++].divideAtTime(time);
53643        }
53644
53645        var segs = this.removeSegments(index, this._segments.length, true),
53646            path;
53647
53648        if (this._closed) {
53649          this.setClosed(false);
53650          path = this;
53651        } else {
53652          path = new Path(Item.NO_INSERT);
53653          path.insertAbove(this);
vendor: 20,675 bytes, lines 53654-54316
53654          path.copyAttributes(this);
53655        }
53656
53657        path._add(segs, 0);
53658
53659        this.addSegment(segs[0]);
53660        return path;
53661      }
53662
53663      return null;
53664    },
53665    split: function split(index, time) {
53666      var curve,
53667          location = time === undefined ? index : (curve = this.getCurves()[index]) && curve.getLocationAtTime(time);
53668      return location != null ? this.splitAt(location) : null;
53669    },
53670    join: function join(path, tolerance) {
53671      var epsilon = tolerance || 0;
53672
53673      if (path && path !== this) {
53674        var segments = path._segments,
53675            last1 = this.getLastSegment(),
53676            last2 = path.getLastSegment();
53677        if (!last2) return this;
53678        if (last1 && last1._point.isClose(last2._point, epsilon)) path.reverse();
53679        var first2 = path.getFirstSegment();
53680
53681        if (last1 && last1._point.isClose(first2._point, epsilon)) {
53682          last1.setHandleOut(first2._handleOut);
53683
53684          this._add(segments.slice(1));
53685        } else {
53686          var first1 = this.getFirstSegment();
53687          if (first1 && first1._point.isClose(first2._point, epsilon)) path.reverse();
53688          last2 = path.getLastSegment();
53689
53690          if (first1 && first1._point.isClose(last2._point, epsilon)) {
53691            first1.setHandleIn(last2._handleIn);
53692
53693            this._add(segments.slice(0, segments.length - 1), 0);
53694          } else {
53695            this._add(segments.slice());
53696          }
53697        }
53698
53699        if (path._closed) this._add([segments[0]]);
53700        path.remove();
53701      }
53702
53703      var first = this.getFirstSegment(),
53704          last = this.getLastSegment();
53705
53706      if (first !== last && first._point.isClose(last._point, epsilon)) {
53707        first.setHandleIn(last._handleIn);
53708        last.remove();
53709        this.setClosed(true);
53710      }
53711
53712      return this;
53713    },
53714    reduce: function reduce(options) {
53715      var curves = this.getCurves(),
53716          simplify = options && options.simplify,
53717          tolerance = simplify ? 1e-7 : 0;
53718
53719      for (var i = curves.length - 1; i >= 0; i--) {
53720        var curve = curves[i];
53721        if (!curve.hasHandles() && (!curve.hasLength(tolerance) || simplify && curve.isCollinear(curve.getNext()))) curve.remove();
53722      }
53723
53724      return this;
53725    },
53726    reverse: function reverse() {
53727      this._segments.reverse();
53728
53729      for (var i = 0, l = this._segments.length; i < l; i++) {
53730        var segment = this._segments[i];
53731        var handleIn = segment._handleIn;
53732        segment._handleIn = segment._handleOut;
53733        segment._handleOut = handleIn;
53734        segment._index = i;
53735      }
53736
53737      this._curves = null;
53738
53739      this._changed(9);
53740    },
53741    flatten: function flatten(flatness) {
53742      var flattener = new PathFlattener(this, flatness || 0.25, 256, true),
53743          parts = flattener.parts,
53744          length = parts.length,
53745          segments = [];
53746
53747      for (var i = 0; i < length; i++) {
53748        segments.push(new Segment(parts[i].curve.slice(0, 2)));
53749      }
53750
53751      if (!this._closed && length > 0) {
53752        segments.push(new Segment(parts[length - 1].curve.slice(6)));
53753      }
53754
53755      this.setSegments(segments);
53756    },
53757    simplify: function simplify(tolerance) {
53758      var segments = new PathFitter(this).fit(tolerance || 2.5);
53759      if (segments) this.setSegments(segments);
53760      return !!segments;
53761    },
53762    smooth: function smooth(options) {
53763      var that = this,
53764          opts = options || {},
53765          type = opts.type || 'asymmetric',
53766          segments = this._segments,
53767          length = segments.length,
53768          closed = this._closed;
53769
53770      function getIndex(value, _default) {
53771        var index = value && value.index;
53772
53773        if (index != null) {
53774          var path = value.path;
53775          if (path && path !== that) throw new Error(value._class + ' ' + index + ' of ' + path + ' is not part of ' + that);
53776          if (_default && value instanceof Curve) index++;
53777        } else {
53778          index = typeof value === 'number' ? value : _default;
53779        }
53780
53781        return Math.min(index < 0 && closed ? index % length : index < 0 ? index + length : index, length - 1);
53782      }
53783
53784      var loop = closed && opts.from === undefined && opts.to === undefined,
53785          from = getIndex(opts.from, 0),
53786          to = getIndex(opts.to, length - 1);
53787
53788      if (from > to) {
53789        if (closed) {
53790          from -= length;
53791        } else {
53792          var tmp = from;
53793          from = to;
53794          to = tmp;
53795        }
53796      }
53797
53798      if (/^(?:asymmetric|continuous)$/.test(type)) {
53799        var asymmetric = type === 'asymmetric',
53800            min = Math.min,
53801            amount = to - from + 1,
53802            n = amount - 1,
53803            padding = loop ? min(amount, 4) : 1,
53804            paddingLeft = padding,
53805            paddingRight = padding,
53806            knots = [];
53807
53808        if (!closed) {
53809          paddingLeft = min(1, from);
53810          paddingRight = min(1, length - to - 1);
53811        }
53812
53813        n += paddingLeft + paddingRight;
53814        if (n <= 1) return;
53815
53816        for (var i = 0, j = from - paddingLeft; i <= n; i++, j++) {
53817          knots[i] = segments[(j < 0 ? j + length : j) % length]._point;
53818        }
53819
53820        var x = knots[0]._x + 2 * knots[1]._x,
53821            y = knots[0]._y + 2 * knots[1]._y,
53822            f = 2,
53823            n_1 = n - 1,
53824            rx = [x],
53825            ry = [y],
53826            rf = [f],
53827            px = [],
53828            py = [];
53829
53830        for (var i = 1; i < n; i++) {
53831          var internal = i < n_1,
53832              a = internal ? 1 : asymmetric ? 1 : 2,
53833              b = internal ? 4 : asymmetric ? 2 : 7,
53834              u = internal ? 4 : asymmetric ? 3 : 8,
53835              v = internal ? 2 : asymmetric ? 0 : 1,
53836              m = a / f;
53837          f = rf[i] = b - m;
53838          x = rx[i] = u * knots[i]._x + v * knots[i + 1]._x - m * x;
53839          y = ry[i] = u * knots[i]._y + v * knots[i + 1]._y - m * y;
53840        }
53841
53842        px[n_1] = rx[n_1] / rf[n_1];
53843        py[n_1] = ry[n_1] / rf[n_1];
53844
53845        for (var i = n - 2; i >= 0; i--) {
53846          px[i] = (rx[i] - px[i + 1]) / rf[i];
53847          py[i] = (ry[i] - py[i + 1]) / rf[i];
53848        }
53849
53850        px[n] = (3 * knots[n]._x - px[n_1]) / 2;
53851        py[n] = (3 * knots[n]._y - py[n_1]) / 2;
53852
53853        for (var i = paddingLeft, max = n - paddingRight, j = from; i <= max; i++, j++) {
53854          var segment = segments[j < 0 ? j + length : j],
53855              pt = segment._point,
53856              hx = px[i] - pt._x,
53857              hy = py[i] - pt._y;
53858          if (loop || i < max) segment.setHandleOut(hx, hy);
53859          if (loop || i > paddingLeft) segment.setHandleIn(-hx, -hy);
53860        }
53861      } else {
53862        for (var i = from; i <= to; i++) {
53863          segments[i < 0 ? i + length : i].smooth(opts, !loop && i === from, !loop && i === to);
53864        }
53865      }
53866    },
53867    toShape: function toShape(insert) {
53868      if (!this._closed) return null;
53869      var segments = this._segments,
53870          type,
53871          size,
53872          radius,
53873          topCenter;
53874
53875      function isCollinear(i, j) {
53876        var seg1 = segments[i],
53877            seg2 = seg1.getNext(),
53878            seg3 = segments[j],
53879            seg4 = seg3.getNext();
53880        return seg1._handleOut.isZero() && seg2._handleIn.isZero() && seg3._handleOut.isZero() && seg4._handleIn.isZero() && seg2._point.subtract(seg1._point).isCollinear(seg4._point.subtract(seg3._point));
53881      }
53882
53883      function isOrthogonal(i) {
53884        var seg2 = segments[i],
53885            seg1 = seg2.getPrevious(),
53886            seg3 = seg2.getNext();
53887        return seg1._handleOut.isZero() && seg2._handleIn.isZero() && seg2._handleOut.isZero() && seg3._handleIn.isZero() && seg2._point.subtract(seg1._point).isOrthogonal(seg3._point.subtract(seg2._point));
53888      }
53889
53890      function isArc(i) {
53891        var seg1 = segments[i],
53892            seg2 = seg1.getNext(),
53893            handle1 = seg1._handleOut,
53894            handle2 = seg2._handleIn,
53895            kappa = 0.5522847498307936;
53896
53897        if (handle1.isOrthogonal(handle2)) {
53898          var pt1 = seg1._point,
53899              pt2 = seg2._point,
53900              corner = new Line(pt1, handle1, true).intersect(new Line(pt2, handle2, true), true);
53901          return corner && Numerical.isZero(handle1.getLength() / corner.subtract(pt1).getLength() - kappa) && Numerical.isZero(handle2.getLength() / corner.subtract(pt2).getLength() - kappa);
53902        }
53903
53904        return false;
53905      }
53906
53907      function getDistance(i, j) {
53908        return segments[i]._point.getDistance(segments[j]._point);
53909      }
53910
53911      if (!this.hasHandles() && segments.length === 4 && isCollinear(0, 2) && isCollinear(1, 3) && isOrthogonal(1)) {
53912        type = Shape.Rectangle;
53913        size = new Size(getDistance(0, 3), getDistance(0, 1));
53914        topCenter = segments[1]._point.add(segments[2]._point).divide(2);
53915      } else if (segments.length === 8 && isArc(0) && isArc(2) && isArc(4) && isArc(6) && isCollinear(1, 5) && isCollinear(3, 7)) {
53916        type = Shape.Rectangle;
53917        size = new Size(getDistance(1, 6), getDistance(0, 3));
53918        radius = size.subtract(new Size(getDistance(0, 7), getDistance(1, 2))).divide(2);
53919        topCenter = segments[3]._point.add(segments[4]._point).divide(2);
53920      } else if (segments.length === 4 && isArc(0) && isArc(1) && isArc(2) && isArc(3)) {
53921        if (Numerical.isZero(getDistance(0, 2) - getDistance(1, 3))) {
53922          type = Shape.Circle;
53923          radius = getDistance(0, 2) / 2;
53924        } else {
53925          type = Shape.Ellipse;
53926          radius = new Size(getDistance(2, 0) / 2, getDistance(3, 1) / 2);
53927        }
53928
53929        topCenter = segments[1]._point;
53930      }
53931
53932      if (type) {
53933        var center = this.getPosition(true),
53934            shape = new type({
53935          center: center,
53936          size: size,
53937          radius: radius,
53938          insert: false
53939        });
53940        shape.copyAttributes(this, true);
53941
53942        shape._matrix.prepend(this._matrix);
53943
53944        shape.rotate(topCenter.subtract(center).getAngle() + 90);
53945        if (insert === undefined || insert) shape.insertAbove(this);
53946        return shape;
53947      }
53948
53949      return null;
53950    },
53951    toPath: '#clone',
53952    compare: function compare(path) {
53953      if (!path || path instanceof CompoundPath) return compare.base.call(this, path);
53954      var curves1 = this.getCurves(),
53955          curves2 = path.getCurves(),
53956          length1 = curves1.length,
53957          length2 = curves2.length;
53958
53959      if (!length1 || !length2) {
53960        return length1 == length2;
53961      }
53962
53963      var v1 = curves1[0].getValues(),
53964          values2 = [],
53965          pos1 = 0,
53966          pos2,
53967          end1 = 0,
53968          end2;
53969
53970      for (var i = 0; i < length2; i++) {
53971        var v2 = curves2[i].getValues();
53972        values2.push(v2);
53973        var overlaps = Curve.getOverlaps(v1, v2);
53974
53975        if (overlaps) {
53976          pos2 = !i && overlaps[0][0] > 0 ? length2 - 1 : i;
53977          end2 = overlaps[0][1];
53978          break;
53979        }
53980      }
53981
53982      var abs = Math.abs,
53983          epsilon = 1e-8,
53984          v2 = values2[pos2],
53985          start2;
53986
53987      while (v1 && v2) {
53988        var overlaps = Curve.getOverlaps(v1, v2);
53989
53990        if (overlaps) {
53991          var t1 = overlaps[0][0];
53992
53993          if (abs(t1 - end1) < epsilon) {
53994            end1 = overlaps[1][0];
53995
53996            if (end1 === 1) {
53997              v1 = ++pos1 < length1 ? curves1[pos1].getValues() : null;
53998              end1 = 0;
53999            }
54000
54001            var t2 = overlaps[0][1];
54002
54003            if (abs(t2 - end2) < epsilon) {
54004              if (!start2) start2 = [pos2, t2];
54005              end2 = overlaps[1][1];
54006
54007              if (end2 === 1) {
54008                if (++pos2 >= length2) pos2 = 0;
54009                v2 = values2[pos2] || curves2[pos2].getValues();
54010                end2 = 0;
54011              }
54012
54013              if (!v1) {
54014                return start2[0] === pos2 && start2[1] === end2;
54015              }
54016
54017              continue;
54018            }
54019          }
54020        }
54021
54022        break;
54023      }
54024
54025      return false;
54026    },
54027    _hitTestSelf: function _hitTestSelf(point, options, viewMatrix, strokeMatrix) {
54028      var that = this,
54029          style = this.getStyle(),
54030          segments = this._segments,
54031          numSegments = segments.length,
54032          closed = this._closed,
54033          tolerancePadding = options._tolerancePadding,
54034          strokePadding = tolerancePadding,
54035          join,
54036          cap,
54037          miterLimit,
54038          area,
54039          loc,
54040          res,
54041          hitStroke = options.stroke && style.hasStroke(),
54042          hitFill = options.fill && style.hasFill(),
54043          hitCurves = options.curves,
54044          strokeRadius = hitStroke ? style.getStrokeWidth() / 2 : hitFill && options.tolerance > 0 || hitCurves ? 0 : null;
54045
54046      if (strokeRadius !== null) {
54047        if (strokeRadius > 0) {
54048          join = style.getStrokeJoin();
54049          cap = style.getStrokeCap();
54050          miterLimit = style.getMiterLimit();
54051          strokePadding = strokePadding.add(Path._getStrokePadding(strokeRadius, strokeMatrix));
54052        } else {
54053          join = cap = 'round';
54054        }
54055      }
54056
54057      function isCloseEnough(pt, padding) {
54058        return point.subtract(pt).divide(padding).length <= 1;
54059      }
54060
54061      function checkSegmentPoint(seg, pt, name) {
54062        if (!options.selected || pt.isSelected()) {
54063          var anchor = seg._point;
54064          if (pt !== anchor) pt = pt.add(anchor);
54065
54066          if (isCloseEnough(pt, strokePadding)) {
54067            return new HitResult(name, that, {
54068              segment: seg,
54069              point: pt
54070            });
54071          }
54072        }
54073      }
54074
54075      function checkSegmentPoints(seg, ends) {
54076        return (ends || options.segments) && checkSegmentPoint(seg, seg._point, 'segment') || !ends && options.handles && (checkSegmentPoint(seg, seg._handleIn, 'handle-in') || checkSegmentPoint(seg, seg._handleOut, 'handle-out'));
54077      }
54078
54079      function addToArea(point) {
54080        area.add(point);
54081      }
54082
54083      function checkSegmentStroke(segment) {
54084        var isJoin = closed || segment._index > 0 && segment._index < numSegments - 1;
54085
54086        if ((isJoin ? join : cap) === 'round') {
54087          return isCloseEnough(segment._point, strokePadding);
54088        } else {
54089          area = new Path({
54090            internal: true,
54091            closed: true
54092          });
54093
54094          if (isJoin) {
54095            if (!segment.isSmooth()) {
54096              Path._addBevelJoin(segment, join, strokeRadius, miterLimit, null, strokeMatrix, addToArea, true);
54097            }
54098          } else if (cap === 'square') {
54099            Path._addSquareCap(segment, cap, strokeRadius, null, strokeMatrix, addToArea, true);
54100          }
54101
54102          if (!area.isEmpty()) {
54103            var loc;
54104            return area.contains(point) || (loc = area.getNearestLocation(point)) && isCloseEnough(loc.getPoint(), tolerancePadding);
54105          }
54106        }
54107      }
54108
54109      if (options.ends && !options.segments && !closed) {
54110        if (res = checkSegmentPoints(segments[0], true) || checkSegmentPoints(segments[numSegments - 1], true)) return res;
54111      } else if (options.segments || options.handles) {
54112        for (var i = 0; i < numSegments; i++) {
54113          if (res = checkSegmentPoints(segments[i])) return res;
54114        }
54115      }
54116
54117      if (strokeRadius !== null) {
54118        loc = this.getNearestLocation(point);
54119
54120        if (loc) {
54121          var time = loc.getTime();
54122
54123          if (time === 0 || time === 1 && numSegments > 1) {
54124            if (!checkSegmentStroke(loc.getSegment())) loc = null;
54125          } else if (!isCloseEnough(loc.getPoint(), strokePadding)) {
54126            loc = null;
54127          }
54128        }
54129
54130        if (!loc && join === 'miter' && numSegments > 1) {
54131          for (var i = 0; i < numSegments; i++) {
54132            var segment = segments[i];
54133
54134            if (point.getDistance(segment._point) <= miterLimit * strokeRadius && checkSegmentStroke(segment)) {
54135              loc = segment.getLocation();
54136              break;
54137            }
54138          }
54139        }
54140      }
54141
54142      return !loc && hitFill && this._contains(point) || loc && !hitStroke && !hitCurves ? new HitResult('fill', this) : loc ? new HitResult(hitStroke ? 'stroke' : 'curve', this, {
54143        location: loc,
54144        point: loc.getPoint()
54145      }) : null;
54146    }
54147  }, Base.each(Curve._evaluateMethods, function (name) {
54148    this[name + 'At'] = function (offset) {
54149      var loc = this.getLocationAt(offset);
54150      return loc && loc[name]();
54151    };
54152  }, {
54153    beans: false,
54154    getLocationOf: function getLocationOf() {
54155      var point = Point.read(arguments),
54156          curves = this.getCurves();
54157
54158      for (var i = 0, l = curves.length; i < l; i++) {
54159        var loc = curves[i].getLocationOf(point);
54160        if (loc) return loc;
54161      }
54162
54163      return null;
54164    },
54165    getOffsetOf: function getOffsetOf() {
54166      var loc = this.getLocationOf.apply(this, arguments);
54167      return loc ? loc.getOffset() : null;
54168    },
54169    getLocationAt: function getLocationAt(offset) {
54170      if (typeof offset === 'number') {
54171        var curves = this.getCurves(),
54172            length = 0;
54173
54174        for (var i = 0, l = curves.length; i < l; i++) {
54175          var start = length,
54176              curve = curves[i];
54177          length += curve.getLength();
54178
54179          if (length > offset) {
54180            return curve.getLocationAt(offset - start);
54181          }
54182        }
54183
54184        if (curves.length > 0 && offset <= this.getLength()) {
54185          return new CurveLocation(curves[curves.length - 1], 1);
54186        }
54187      } else if (offset && offset.getPath && offset.getPath() === this) {
54188        return offset;
54189      }
54190
54191      return null;
54192    },
54193    getOffsetsWithTangent: function getOffsetsWithTangent() {
54194      var tangent = Point.read(arguments);
54195
54196      if (tangent.isZero()) {
54197        return [];
54198      }
54199
54200      var offsets = [];
54201      var curveStart = 0;
54202      var curves = this.getCurves();
54203
54204      for (var i = 0, l = curves.length; i < l; i++) {
54205        var curve = curves[i];
54206        var curveTimes = curve.getTimesWithTangent(tangent);
54207
54208        for (var j = 0, m = curveTimes.length; j < m; j++) {
54209          var offset = curveStart + curve.getOffsetAtTime(curveTimes[j]);
54210
54211          if (offsets.indexOf(offset) < 0) {
54212            offsets.push(offset);
54213          }
54214        }
54215
54216        curveStart += curve.length;
54217      }
54218
54219      return offsets;
54220    }
54221  }), new function () {
54222    function drawHandles(ctx, segments, matrix, size) {
54223      if (size <= 0) return;
54224      var half = size / 2,
54225          miniSize = size - 2,
54226          miniHalf = half - 1,
54227          coords = new Array(6),
54228          pX,
54229          pY;
54230
54231      function drawHandle(index) {
54232        var hX = coords[index],
54233            hY = coords[index + 1];
54234
54235        if (pX != hX || pY != hY) {
54236          ctx.beginPath();
54237          ctx.moveTo(pX, pY);
54238          ctx.lineTo(hX, hY);
54239          ctx.stroke();
54240          ctx.beginPath();
54241          ctx.arc(hX, hY, half, 0, Math.PI * 2, true);
54242          ctx.fill();
54243        }
54244      }
54245
54246      for (var i = 0, l = segments.length; i < l; i++) {
54247        var segment = segments[i],
54248            selection = segment._selection;
54249
54250        segment._transformCoordinates(matrix, coords);
54251
54252        pX = coords[0];
54253        pY = coords[1];
54254        if (selection & 2) drawHandle(2);
54255        if (selection & 4) drawHandle(4);
54256        ctx.fillRect(pX - half, pY - half, size, size);
54257
54258        if (miniSize > 0 && !(selection & 1)) {
54259          var fillStyle = ctx.fillStyle;
54260          ctx.fillStyle = '#ffffff';
54261          ctx.fillRect(pX - miniHalf, pY - miniHalf, miniSize, miniSize);
54262          ctx.fillStyle = fillStyle;
54263        }
54264      }
54265    }
54266
54267    function drawSegments(ctx, path, matrix) {
54268      var segments = path._segments,
54269          length = segments.length,
54270          coords = new Array(6),
54271          first = true,
54272          curX,
54273          curY,
54274          prevX,
54275          prevY,
54276          inX,
54277          inY,
54278          outX,
54279          outY;
54280
54281      function drawSegment(segment) {
54282        if (matrix) {
54283          segment._transformCoordinates(matrix, coords);
54284
54285          curX = coords[0];
54286          curY = coords[1];
54287        } else {
54288          var point = segment._point;
54289          curX = point._x;
54290          curY = point._y;
54291        }
54292
54293        if (first) {
54294          ctx.moveTo(curX, curY);
54295          first = false;
54296        } else {
54297          if (matrix) {
54298            inX = coords[2];
54299            inY = coords[3];
54300          } else {
54301            var handle = segment._handleIn;
54302            inX = curX + handle._x;
54303            inY = curY + handle._y;
54304          }
54305
54306          if (inX === curX && inY === curY && outX === prevX && outY === prevY) {
54307            ctx.lineTo(curX, curY);
54308          } else {
54309            ctx.bezierCurveTo(outX, outY, inX, inY, curX, curY);
54310          }
54311        }
54312
54313        prevX = curX;
54314        prevY = curY;
54315
54316        if (matrix) {
54317          outX = coords[4];
54318          outY = coords[5];
54319        } else {
54320          var handle = segment._handleOut;
54321          outX = prevX + handle._x;
54322          outY = prevY + handle._y;
54323        }
54324      }
54325
54326      for (var i = 0; i < length; i++) {
54327        drawSegment(segments[i]);
54328      }
54329
54330      if (path._closed && length > 0) drawSegment(segments[0]);
54331    }
54332
54333    return {
54334      _draw: function _draw(ctx, param, viewMatrix, strokeMatrix) {
54335        var dontStart = param.dontStart,
54336            dontPaint = param.dontFinish || param.clip,
54337            style = this.getStyle(),
54338            hasFill = style.hasFill(),
54339            hasStroke = style.hasStroke(),
54340            dashArray = style.getDashArray(),
54341            dashLength = !paper.support.nativeDash && hasStroke && dashArray && dashArray.length;
54342        if (!dontStart) ctx.beginPath();
54343
54344        if (hasFill || hasStroke && !dashLength || dontPaint) {
54345          drawSegments(ctx, this, strokeMatrix);
54346          if (this._closed) ctx.closePath();
54347        }
54348
54349        function getOffset(i) {
54350          return dashArray[(i % dashLength + dashLength) % dashLength];
54351        }
54352
54353        if (!dontPaint && (hasFill || hasStroke)) {
54354          this._setStyles(ctx, param, viewMatrix);
54355
54356          if (hasFill) {
54357            ctx.fill(style.getFillRule());
54358            ctx.shadowColor = 'rgba(0,0,0,0)';
54359          }
54360
54361          if (hasStroke) {
54362            if (dashLength) {
54363              if (!dontStart) ctx.beginPath();
54364              var flattener = new PathFlattener(this, 0.25, 32, false, strokeMatrix),
54365                  length = flattener.length,
54366                  from = -style.getDashOffset(),
54367                  to,
54368                  i = 0;
54369              from = from % length;
54370
54371              while (from > 0) {
54372                from -= getOffset(i--) + getOffset(i--);
54373              }
54374
54375              while (from < length) {
54376                to = from + getOffset(i++);
54377                if (from > 0 || to > 0) flattener.drawPart(ctx, Math.max(from, 0), Math.max(to, 0));
54378                from = to + getOffset(i++);
54379              }
54380            }
54381
54382            ctx.stroke();
54383          }
54384        }
54385      },
54386      _drawSelected: function _drawSelected(ctx, matrix) {
54387        ctx.beginPath();
54388        drawSegments(ctx, this, matrix);
54389        ctx.stroke();
54390        drawHandles(ctx, this._segments, matrix, paper.settings.handleSize);
54391      }
54392    };
54393  }(), new function () {
54394    function getCurrentSegment(that) {
54395      var segments = that._segments;
54396      if (!segments.length) throw new Error('Use a moveTo() command first');
54397      return segments[segments.length - 1];
54398    }
54399
54400    return {
54401      moveTo: function moveTo() {
54402        var segments = this._segments;
54403        if (segments.length === 1) this.removeSegment(0);
54404        if (!segments.length) this._add([new Segment(Point.read(arguments))]);
54405      },
54406      moveBy: function moveBy() {
54407        throw new Error('moveBy() is unsupported on Path items.');
54408      },
54409      lineTo: function lineTo() {
54410        this._add([new Segment(Point.read(arguments))]);
54411      },
54412      cubicCurveTo: function cubicCurveTo() {
54413        var args = arguments,
54414            handle1 = Point.read(args),
54415            handle2 = Point.read(args),
54416            to = Point.read(args),
54417            current = getCurrentSegment(this);
54418        current.setHandleOut(handle1.subtract(current._point));
54419
54420        this._add([new Segment(to, handle2.subtract(to))]);
54421      },
54422      quadraticCurveTo: function quadraticCurveTo() {
54423        var args = arguments,
54424            handle = Point.read(args),
54425            to = Point.read(args),
54426            current = getCurrentSegment(this)._point;
54427
54428        this.cubicCurveTo(handle.add(current.subtract(handle).multiply(1 / 3)), handle.add(to.subtract(handle).multiply(1 / 3)), to);
54429      },
54430      curveTo: function curveTo() {
54431        var args = arguments,
54432            through = Point.read(args),
54433            to = Point.read(args),
54434            t = Base.pick(Base.read(args), 0.5),
54435            t1 = 1 - t,
54436            current = getCurrentSegment(this)._point,
54437            handle = through.subtract(current.multiply(t1 * t1)).subtract(to.multiply(t * t)).divide(2 * t * t1);
54438
54439        if (handle.isNaN()) throw new Error('Cannot put a curve through points with parameter = ' + t);
vendor: 19,639 bytes, lines 54440-54976
54440        this.quadraticCurveTo(handle, to);
54441      },
54442      arcTo: function arcTo() {
54443        var args = arguments,
54444            abs = Math.abs,
54445            sqrt = Math.sqrt,
54446            current = getCurrentSegment(this),
54447            from = current._point,
54448            to = Point.read(args),
54449            through,
54450            peek = Base.peek(args),
54451            clockwise = Base.pick(peek, true),
54452            center,
54453            extent,
54454            vector,
54455            matrix;
54456
54457        if (typeof clockwise === 'boolean') {
54458          var middle = from.add(to).divide(2),
54459              through = middle.add(middle.subtract(from).rotate(clockwise ? -90 : 90));
54460        } else if (Base.remain(args) <= 2) {
54461          through = to;
54462          to = Point.read(args);
54463        } else if (!from.equals(to)) {
54464          var radius = Size.read(args),
54465              isZero = Numerical.isZero;
54466          if (isZero(radius.width) || isZero(radius.height)) return this.lineTo(to);
54467          var rotation = Base.read(args),
54468              clockwise = !!Base.read(args),
54469              large = !!Base.read(args),
54470              middle = from.add(to).divide(2),
54471              pt = from.subtract(middle).rotate(-rotation),
54472              x = pt.x,
54473              y = pt.y,
54474              rx = abs(radius.width),
54475              ry = abs(radius.height),
54476              rxSq = rx * rx,
54477              rySq = ry * ry,
54478              xSq = x * x,
54479              ySq = y * y;
54480          var factor = sqrt(xSq / rxSq + ySq / rySq);
54481
54482          if (factor > 1) {
54483            rx *= factor;
54484            ry *= factor;
54485            rxSq = rx * rx;
54486            rySq = ry * ry;
54487          }
54488
54489          factor = (rxSq * rySq - rxSq * ySq - rySq * xSq) / (rxSq * ySq + rySq * xSq);
54490          if (abs(factor) < 1e-12) factor = 0;
54491          if (factor < 0) throw new Error('Cannot create an arc with the given arguments');
54492          center = new Point(rx * y / ry, -ry * x / rx).multiply((large === clockwise ? -1 : 1) * sqrt(factor)).rotate(rotation).add(middle);
54493          matrix = new Matrix().translate(center).rotate(rotation).scale(rx, ry);
54494          vector = matrix._inverseTransform(from);
54495          extent = vector.getDirectedAngle(matrix._inverseTransform(to));
54496          if (!clockwise && extent > 0) extent -= 360;else if (clockwise && extent < 0) extent += 360;
54497        }
54498
54499        if (through) {
54500          var l1 = new Line(from.add(through).divide(2), through.subtract(from).rotate(90), true),
54501              l2 = new Line(through.add(to).divide(2), to.subtract(through).rotate(90), true),
54502              line = new Line(from, to),
54503              throughSide = line.getSide(through);
54504          center = l1.intersect(l2, true);
54505
54506          if (!center) {
54507            if (!throughSide) return this.lineTo(to);
54508            throw new Error('Cannot create an arc with the given arguments');
54509          }
54510
54511          vector = from.subtract(center);
54512          extent = vector.getDirectedAngle(to.subtract(center));
54513          var centerSide = line.getSide(center, true);
54514
54515          if (centerSide === 0) {
54516            extent = throughSide * abs(extent);
54517          } else if (throughSide === centerSide) {
54518            extent += extent < 0 ? 360 : -360;
54519          }
54520        }
54521
54522        if (extent) {
54523          var epsilon = 1e-7,
54524              ext = abs(extent),
54525              count = ext >= 360 ? 4 : Math.ceil((ext - epsilon) / 90),
54526              inc = extent / count,
54527              half = inc * Math.PI / 360,
54528              z = 4 / 3 * Math.sin(half) / (1 + Math.cos(half)),
54529              segments = [];
54530
54531          for (var i = 0; i <= count; i++) {
54532            var pt = to,
54533                out = null;
54534
54535            if (i < count) {
54536              out = vector.rotate(90).multiply(z);
54537
54538              if (matrix) {
54539                pt = matrix._transformPoint(vector);
54540                out = matrix._transformPoint(vector.add(out)).subtract(pt);
54541              } else {
54542                pt = center.add(vector);
54543              }
54544            }
54545
54546            if (!i) {
54547              current.setHandleOut(out);
54548            } else {
54549              var _in = vector.rotate(-90).multiply(z);
54550
54551              if (matrix) {
54552                _in = matrix._transformPoint(vector.add(_in)).subtract(pt);
54553              }
54554
54555              segments.push(new Segment(pt, _in, out));
54556            }
54557
54558            vector = vector.rotate(inc);
54559          }
54560
54561          this._add(segments);
54562        }
54563      },
54564      lineBy: function lineBy() {
54565        var to = Point.read(arguments),
54566            current = getCurrentSegment(this)._point;
54567
54568        this.lineTo(current.add(to));
54569      },
54570      curveBy: function curveBy() {
54571        var args = arguments,
54572            through = Point.read(args),
54573            to = Point.read(args),
54574            parameter = Base.read(args),
54575            current = getCurrentSegment(this)._point;
54576
54577        this.curveTo(current.add(through), current.add(to), parameter);
54578      },
54579      cubicCurveBy: function cubicCurveBy() {
54580        var args = arguments,
54581            handle1 = Point.read(args),
54582            handle2 = Point.read(args),
54583            to = Point.read(args),
54584            current = getCurrentSegment(this)._point;
54585
54586        this.cubicCurveTo(current.add(handle1), current.add(handle2), current.add(to));
54587      },
54588      quadraticCurveBy: function quadraticCurveBy() {
54589        var args = arguments,
54590            handle = Point.read(args),
54591            to = Point.read(args),
54592            current = getCurrentSegment(this)._point;
54593
54594        this.quadraticCurveTo(current.add(handle), current.add(to));
54595      },
54596      arcBy: function arcBy() {
54597        var args = arguments,
54598            current = getCurrentSegment(this)._point,
54599            point = current.add(Point.read(args)),
54600            clockwise = Base.pick(Base.peek(args), true);
54601
54602        if (typeof clockwise === 'boolean') {
54603          this.arcTo(point, clockwise);
54604        } else {
54605          this.arcTo(point, current.add(Point.read(args)));
54606        }
54607      },
54608      closePath: function closePath(tolerance) {
54609        this.setClosed(true);
54610        this.join(this, tolerance);
54611      }
54612    };
54613  }(), {
54614    _getBounds: function _getBounds(matrix, options) {
54615      var method = options.handle ? 'getHandleBounds' : options.stroke ? 'getStrokeBounds' : 'getBounds';
54616      return Path[method](this._segments, this._closed, this, matrix, options);
54617    },
54618    statics: {
54619      getBounds: function getBounds(segments, closed, path, matrix, options, strokePadding) {
54620        var first = segments[0];
54621        if (!first) return new _Rectangle();
54622
54623        var coords = new Array(6),
54624            prevCoords = first._transformCoordinates(matrix, new Array(6)),
54625            min = prevCoords.slice(0, 2),
54626            max = min.slice(),
54627            roots = new Array(2);
54628
54629        function processSegment(segment) {
54630          segment._transformCoordinates(matrix, coords);
54631
54632          for (var i = 0; i < 2; i++) {
54633            Curve._addBounds(prevCoords[i], prevCoords[i + 4], coords[i + 2], coords[i], i, strokePadding ? strokePadding[i] : 0, min, max, roots);
54634          }
54635
54636          var tmp = prevCoords;
54637          prevCoords = coords;
54638          coords = tmp;
54639        }
54640
54641        for (var i = 1, l = segments.length; i < l; i++) {
54642          processSegment(segments[i]);
54643        }
54644
54645        if (closed) processSegment(first);
54646        return new _Rectangle(min[0], min[1], max[0] - min[0], max[1] - min[1]);
54647      },
54648      getStrokeBounds: function getStrokeBounds(segments, closed, path, matrix, options) {
54649        var style = path.getStyle(),
54650            stroke = style.hasStroke(),
54651            strokeWidth = style.getStrokeWidth(),
54652            strokeMatrix = stroke && path._getStrokeMatrix(matrix, options),
54653            strokePadding = stroke && Path._getStrokePadding(strokeWidth, strokeMatrix),
54654            bounds = Path.getBounds(segments, closed, path, matrix, options, strokePadding);
54655
54656        if (!stroke) return bounds;
54657        var strokeRadius = strokeWidth / 2,
54658            join = style.getStrokeJoin(),
54659            cap = style.getStrokeCap(),
54660            miterLimit = style.getMiterLimit(),
54661            joinBounds = new _Rectangle(new Size(strokePadding));
54662
54663        function addPoint(point) {
54664          bounds = bounds.include(point);
54665        }
54666
54667        function addRound(segment) {
54668          bounds = bounds.unite(joinBounds.setCenter(segment._point.transform(matrix)));
54669        }
54670
54671        function addJoin(segment, join) {
54672          if (join === 'round' || segment.isSmooth()) {
54673            addRound(segment);
54674          } else {
54675            Path._addBevelJoin(segment, join, strokeRadius, miterLimit, matrix, strokeMatrix, addPoint);
54676          }
54677        }
54678
54679        function addCap(segment, cap) {
54680          if (cap === 'round') {
54681            addRound(segment);
54682          } else {
54683            Path._addSquareCap(segment, cap, strokeRadius, matrix, strokeMatrix, addPoint);
54684          }
54685        }
54686
54687        var length = segments.length - (closed ? 0 : 1);
54688
54689        for (var i = 1; i < length; i++) {
54690          addJoin(segments[i], join);
54691        }
54692
54693        if (closed) {
54694          addJoin(segments[0], join);
54695        } else if (length > 0) {
54696          addCap(segments[0], cap);
54697          addCap(segments[segments.length - 1], cap);
54698        }
54699
54700        return bounds;
54701      },
54702      _getStrokePadding: function _getStrokePadding(radius, matrix) {
54703        if (!matrix) return [radius, radius];
54704        var hor = new Point(radius, 0).transform(matrix),
54705            ver = new Point(0, radius).transform(matrix),
54706            phi = hor.getAngleInRadians(),
54707            a = hor.getLength(),
54708            b = ver.getLength();
54709        var sin = Math.sin(phi),
54710            cos = Math.cos(phi),
54711            tan = Math.tan(phi),
54712            tx = Math.atan2(b * tan, a),
54713            ty = Math.atan2(b, tan * a);
54714        return [Math.abs(a * Math.cos(tx) * cos + b * Math.sin(tx) * sin), Math.abs(b * Math.sin(ty) * cos + a * Math.cos(ty) * sin)];
54715      },
54716      _addBevelJoin: function _addBevelJoin(segment, join, radius, miterLimit, matrix, strokeMatrix, addPoint, isArea) {
54717        var curve2 = segment.getCurve(),
54718            curve1 = curve2.getPrevious(),
54719            point = curve2.getPoint1().transform(matrix),
54720            normal1 = curve1.getNormalAtTime(1).multiply(radius).transform(strokeMatrix),
54721            normal2 = curve2.getNormalAtTime(0).multiply(radius).transform(strokeMatrix),
54722            angle = normal1.getDirectedAngle(normal2);
54723
54724        if (angle < 0 || angle >= 180) {
54725          normal1 = normal1.negate();
54726          normal2 = normal2.negate();
54727        }
54728
54729        if (isArea) addPoint(point);
54730        addPoint(point.add(normal1));
54731
54732        if (join === 'miter') {
54733          var corner = new Line(point.add(normal1), new Point(-normal1.y, normal1.x), true).intersect(new Line(point.add(normal2), new Point(-normal2.y, normal2.x), true), true);
54734
54735          if (corner && point.getDistance(corner) <= miterLimit * radius) {
54736            addPoint(corner);
54737          }
54738        }
54739
54740        addPoint(point.add(normal2));
54741      },
54742      _addSquareCap: function _addSquareCap(segment, cap, radius, matrix, strokeMatrix, addPoint, isArea) {
54743        var point = segment._point.transform(matrix),
54744            loc = segment.getLocation(),
54745            normal = loc.getNormal().multiply(loc.getTime() === 0 ? radius : -radius).transform(strokeMatrix);
54746
54747        if (cap === 'square') {
54748          if (isArea) {
54749            addPoint(point.subtract(normal));
54750            addPoint(point.add(normal));
54751          }
54752
54753          point = point.add(normal.rotate(-90));
54754        }
54755
54756        addPoint(point.add(normal));
54757        addPoint(point.subtract(normal));
54758      },
54759      getHandleBounds: function getHandleBounds(segments, closed, path, matrix, options) {
54760        var style = path.getStyle(),
54761            stroke = options.stroke && style.hasStroke(),
54762            strokePadding,
54763            joinPadding;
54764
54765        if (stroke) {
54766          var strokeMatrix = path._getStrokeMatrix(matrix, options),
54767              strokeRadius = style.getStrokeWidth() / 2,
54768              joinRadius = strokeRadius;
54769
54770          if (style.getStrokeJoin() === 'miter') joinRadius = strokeRadius * style.getMiterLimit();
54771          if (style.getStrokeCap() === 'square') joinRadius = Math.max(joinRadius, strokeRadius * Math.SQRT2);
54772          strokePadding = Path._getStrokePadding(strokeRadius, strokeMatrix);
54773          joinPadding = Path._getStrokePadding(joinRadius, strokeMatrix);
54774        }
54775
54776        var coords = new Array(6),
54777            x1 = Infinity,
54778            x2 = -x1,
54779            y1 = x1,
54780            y2 = x2;
54781
54782        for (var i = 0, l = segments.length; i < l; i++) {
54783          var segment = segments[i];
54784
54785          segment._transformCoordinates(matrix, coords);
54786
54787          for (var j = 0; j < 6; j += 2) {
54788            var padding = !j ? joinPadding : strokePadding,
54789                paddingX = padding ? padding[0] : 0,
54790                paddingY = padding ? padding[1] : 0,
54791                x = coords[j],
54792                y = coords[j + 1],
54793                xn = x - paddingX,
54794                xx = x + paddingX,
54795                yn = y - paddingY,
54796                yx = y + paddingY;
54797            if (xn < x1) x1 = xn;
54798            if (xx > x2) x2 = xx;
54799            if (yn < y1) y1 = yn;
54800            if (yx > y2) y2 = yx;
54801          }
54802        }
54803
54804        return new _Rectangle(x1, y1, x2 - x1, y2 - y1);
54805      }
54806    }
54807  });
54808  Path.inject({
54809    statics: new function () {
54810      var kappa = 0.5522847498307936,
54811          ellipseSegments = [new Segment([-1, 0], [0, kappa], [0, -kappa]), new Segment([0, -1], [-kappa, 0], [kappa, 0]), new Segment([1, 0], [0, -kappa], [0, kappa]), new Segment([0, 1], [kappa, 0], [-kappa, 0])];
54812
54813      function createPath(segments, closed, args) {
54814        var props = Base.getNamed(args),
54815            path = new Path(props && props.insert == false && Item.NO_INSERT);
54816
54817        path._add(segments);
54818
54819        path._closed = closed;
54820        return path.set(props, {
54821          insert: true
54822        });
54823      }
54824
54825      function createEllipse(center, radius, args) {
54826        var segments = new Array(4);
54827
54828        for (var i = 0; i < 4; i++) {
54829          var segment = ellipseSegments[i];
54830          segments[i] = new Segment(segment._point.multiply(radius).add(center), segment._handleIn.multiply(radius), segment._handleOut.multiply(radius));
54831        }
54832
54833        return createPath(segments, true, args);
54834      }
54835
54836      return {
54837        Line: function Line() {
54838          var args = arguments;
54839          return createPath([new Segment(Point.readNamed(args, 'from')), new Segment(Point.readNamed(args, 'to'))], false, args);
54840        },
54841        Circle: function Circle() {
54842          var args = arguments,
54843              center = Point.readNamed(args, 'center'),
54844              radius = Base.readNamed(args, 'radius');
54845          return createEllipse(center, new Size(radius), args);
54846        },
54847        Rectangle: function Rectangle() {
54848          var args = arguments,
54849              rect = _Rectangle.readNamed(args, 'rectangle'),
54850              radius = Size.readNamed(args, 'radius', 0, {
54851            readNull: true
54852          }),
54853              bl = rect.getBottomLeft(true),
54854              tl = rect.getTopLeft(true),
54855              tr = rect.getTopRight(true),
54856              br = rect.getBottomRight(true),
54857              segments;
54858
54859          if (!radius || radius.isZero()) {
54860            segments = [new Segment(bl), new Segment(tl), new Segment(tr), new Segment(br)];
54861          } else {
54862            radius = Size.min(radius, rect.getSize(true).divide(2));
54863            var rx = radius.width,
54864                ry = radius.height,
54865                hx = rx * kappa,
54866                hy = ry * kappa;
54867            segments = [new Segment(bl.add(rx, 0), null, [-hx, 0]), new Segment(bl.subtract(0, ry), [0, hy]), new Segment(tl.add(0, ry), null, [0, -hy]), new Segment(tl.add(rx, 0), [-hx, 0], null), new Segment(tr.subtract(rx, 0), null, [hx, 0]), new Segment(tr.add(0, ry), [0, -hy], null), new Segment(br.subtract(0, ry), null, [0, hy]), new Segment(br.subtract(rx, 0), [hx, 0])];
54868          }
54869
54870          return createPath(segments, true, args);
54871        },
54872        RoundRectangle: '#Rectangle',
54873        Ellipse: function Ellipse() {
54874          var args = arguments,
54875              ellipse = Shape._readEllipse(args);
54876
54877          return createEllipse(ellipse.center, ellipse.radius, args);
54878        },
54879        Oval: '#Ellipse',
54880        Arc: function Arc() {
54881          var args = arguments,
54882              from = Point.readNamed(args, 'from'),
54883              through = Point.readNamed(args, 'through'),
54884              to = Point.readNamed(args, 'to'),
54885              props = Base.getNamed(args),
54886              path = new Path(props && props.insert == false && Item.NO_INSERT);
54887          path.moveTo(from);
54888          path.arcTo(through, to);
54889          return path.set(props);
54890        },
54891        RegularPolygon: function RegularPolygon() {
54892          var args = arguments,
54893              center = Point.readNamed(args, 'center'),
54894              sides = Base.readNamed(args, 'sides'),
54895              radius = Base.readNamed(args, 'radius'),
54896              step = 360 / sides,
54897              three = sides % 3 === 0,
54898              vector = new Point(0, three ? -radius : radius),
54899              offset = three ? -1 : 0.5,
54900              segments = new Array(sides);
54901
54902          for (var i = 0; i < sides; i++) {
54903            segments[i] = new Segment(center.add(vector.rotate((i + offset) * step)));
54904          }
54905
54906          return createPath(segments, true, args);
54907        },
54908        Star: function Star() {
54909          var args = arguments,
54910              center = Point.readNamed(args, 'center'),
54911              points = Base.readNamed(args, 'points') * 2,
54912              radius1 = Base.readNamed(args, 'radius1'),
54913              radius2 = Base.readNamed(args, 'radius2'),
54914              step = 360 / points,
54915              vector = new Point(0, -1),
54916              segments = new Array(points);
54917
54918          for (var i = 0; i < points; i++) {
54919            segments[i] = new Segment(center.add(vector.rotate(step * i).multiply(i % 2 ? radius2 : radius1)));
54920          }
54921
54922          return createPath(segments, true, args);
54923        }
54924      };
54925    }()
54926  });
54927  var CompoundPath = PathItem.extend({
54928    _class: 'CompoundPath',
54929    _serializeFields: {
54930      children: []
54931    },
54932    beans: true,
54933    initialize: function CompoundPath(arg) {
54934      this._children = [];
54935      this._namedChildren = {};
54936
54937      if (!this._initialize(arg)) {
54938        if (typeof arg === 'string') {
54939          this.setPathData(arg);
54940        } else {
54941          this.addChildren(Array.isArray(arg) ? arg : arguments);
54942        }
54943      }
54944    },
54945    insertChildren: function insertChildren(index, items) {
54946      var list = items,
54947          first = list[0];
54948      if (first && typeof first[0] === 'number') list = [list];
54949
54950      for (var i = items.length - 1; i >= 0; i--) {
54951        var item = list[i];
54952        if (list === items && !(item instanceof Path)) list = Base.slice(list);
54953
54954        if (Array.isArray(item)) {
54955          list[i] = new Path({
54956            segments: item,
54957            insert: false
54958          });
54959        } else if (item instanceof CompoundPath) {
54960          list.splice.apply(list, [i, 1].concat(item.removeChildren()));
54961          item.remove();
54962        }
54963      }
54964
54965      return insertChildren.base.call(this, index, list);
54966    },
54967    reduce: function reduce(options) {
54968      var children = this._children;
54969
54970      for (var i = children.length - 1; i >= 0; i--) {
54971        var path = children[i].reduce(options);
54972        if (path.isEmpty()) path.remove();
54973      }
54974
54975      if (!children.length) {
54976        var path = new Path(Item.NO_INSERT);
54977        path.copyAttributes(this);
54978        path.insertAbove(this);
54979        this.remove();
54980        return path;
54981      }
54982
54983      return reduce.base.call(this);
54984    },
54985    isClosed: function isClosed() {
54986      var children = this._children;
54987
54988      for (var i = 0, l = children.length; i < l; i++) {
54989        if (!children[i]._closed) return false;
54990      }
54991
54992      return true;
54993    },
54994    setClosed: function setClosed(closed) {
54995      var children = this._children;
54996
54997      for (var i = 0, l = children.length; i < l; i++) {
54998        children[i].setClosed(closed);
54999      }
55000    },
55001    getFirstSegment: function getFirstSegment() {
55002      var first = this.getFirstChild();
55003      return first && first.getFirstSegment();
55004    },
55005    getLastSegment: function getLastSegment() {
55006      var last = this.getLastChild();
55007      return last && last.getLastSegment();
55008    },
55009    getCurves: function getCurves() {
55010      var children = this._children,
55011          curves = [];
55012
55013      for (var i = 0, l = children.length; i < l; i++) {
55014        Base.push(curves, children[i].getCurves());
55015      }
55016
55017      return curves;
55018    },
55019    getFirstCurve: function getFirstCurve() {
55020      var first = this.getFirstChild();
55021      return first && first.getFirstCurve();
55022    },
55023    getLastCurve: function getLastCurve() {
55024      var last = this.getLastChild();
55025      return last && last.getLastCurve();
55026    },
55027    getArea: function getArea() {
55028      var children = this._children,
55029          area = 0;
55030
55031      for (var i = 0, l = children.length; i < l; i++) {
55032        area += children[i].getArea();
55033      }
55034
55035      return area;
55036    },
55037    getLength: function getLength() {
55038      var children = this._children,
55039          length = 0;
55040
55041      for (var i = 0, l = children.length; i < l; i++) {
55042        length += children[i].getLength();
55043      }
55044
55045      return length;
55046    },
55047    getPathData: function getPathData(_matrix, _precision) {
55048      var children = this._children,
55049          paths = [];
55050
55051      for (var i = 0, l = children.length; i < l; i++) {
55052        var child = children[i],
55053            mx = child._matrix;
55054        paths.push(child.getPathData(_matrix && !mx.isIdentity() ? _matrix.appended(mx) : _matrix, _precision));
55055      }
55056
55057      return paths.join('');
55058    },
55059    _hitTestChildren: function _hitTestChildren(point, options, viewMatrix) {
55060      return _hitTestChildren.base.call(this, point, options.class === Path || options.type === 'path' ? options : Base.set({}, options, {
55061        fill: false
55062      }), viewMatrix);
55063    },
55064    _draw: function _draw(ctx, param, viewMatrix, strokeMatrix) {
55065      var children = this._children;
55066      if (!children.length) return;
55067      param = param.extend({
55068        dontStart: true,
55069        dontFinish: true
55070      });
55071      ctx.beginPath();
55072
55073      for (var i = 0, l = children.length; i < l; i++) {
55074        children[i].draw(ctx, param, strokeMatrix);
55075      }
55076
55077      if (!param.clip) {
55078        this._setStyles(ctx, param, viewMatrix);
55079
55080        var style = this._style;
55081
55082        if (style.hasFill()) {
55083          ctx.fill(style.getFillRule());
55084          ctx.shadowColor = 'rgba(0,0,0,0)';
55085        }
55086
55087        if (style.hasStroke()) ctx.stroke();
55088      }
55089    },
55090    _drawSelected: function _drawSelected(ctx, matrix, selectionItems) {
55091      var children = this._children;
55092
55093      for (var i = 0, l = children.length; i < l; i++) {
55094        var child = children[i],
55095            mx = child._matrix;
55096
55097        if (!selectionItems[child._id]) {
55098          child._drawSelected(ctx, mx.isIdentity() ? matrix : matrix.appended(mx));
55099        }
55100      }
55101    }
55102  }, new function () {
55103    function getCurrentPath(that, check) {
55104      var children = that._children;
55105      if (check && !children.length) throw new Error('Use a moveTo() command first');
55106      return children[children.length - 1];
55107    }
55108
55109    return Base.each(['lineTo', 'cubicCurveTo', 'quadraticCurveTo', 'curveTo', 'arcTo', 'lineBy', 'cubicCurveBy', 'quadraticCurveBy', 'curveBy', 'arcBy'], function (key) {
55110      this[key] = function () {
55111        var path = getCurrentPath(this, true);
55112        path[key].apply(path, arguments);
55113      };
55114    }, {
55115      moveTo: function moveTo() {
55116        var current = getCurrentPath(this),
55117            path = current && current.isEmpty() ? current : new Path(Item.NO_INSERT);
55118        if (path !== current) this.addChild(path);
55119        path.moveTo.apply(path, arguments);
55120      },
55121      moveBy: function moveBy() {
55122        var current = getCurrentPath(this, true),
55123            last = current && current.getLastSegment(),
55124            point = Point.read(arguments);
55125        this.moveTo(last ? point.add(last._point) : point);
55126      },
55127      closePath: function closePath(tolerance) {
55128        getCurrentPath(this, true).closePath(tolerance);
55129      }
55130    });
55131  }(), Base.each(['reverse', 'flatten', 'simplify', 'smooth'], function (key) {
55132    this[key] = function (param) {
55133      var children = this._children,
55134          res;
55135
55136      for (var i = 0, l = children.length; i < l; i++) {
55137        res = children[i][key](param) || res;
55138      }
55139
55140      return res;
55141    };
55142  }, {}));
55143  PathItem.inject(new function () {
55144    var min = Math.min,
55145        max = Math.max,
55146        abs = Math.abs,
55147        operators = {
55148      unite: {
55149        '1': true,
55150        '2': true
55151      },
55152      intersect: {
55153        '2': true
55154      },
55155      subtract: {
55156        '1': true
55157      },
55158      exclude: {
55159        '1': true,
vendor: 41,408 bytes, lines 55160-56523
55160        '-1': true
55161      }
55162    };
55163
55164    function getPaths(path) {
55165      return path._children || [path];
55166    }
55167
55168    function preparePath(path, resolve) {
55169      var res = path.clone(false).reduce({
55170        simplify: true
55171      }).transform(null, true, true);
55172
55173      if (resolve) {
55174        var paths = getPaths(res);
55175
55176        for (var i = 0, l = paths.length; i < l; i++) {
55177          var path = paths[i];
55178
55179          if (!path._closed && !path.isEmpty()) {
55180            path.closePath(1e-12);
55181            path.getFirstSegment().setHandleIn(0, 0);
55182            path.getLastSegment().setHandleOut(0, 0);
55183          }
55184        }
55185
55186        res = res.resolveCrossings().reorient(res.getFillRule() === 'nonzero', true);
55187      }
55188
55189      return res;
55190    }
55191
55192    function createResult(paths, simplify, path1, path2, options) {
55193      var result = new CompoundPath(Item.NO_INSERT);
55194      result.addChildren(paths, true);
55195      result = result.reduce({
55196        simplify: simplify
55197      });
55198
55199      if (!(options && options.insert == false)) {
55200        result.insertAbove(path2 && path1.isSibling(path2) && path1.getIndex() < path2.getIndex() ? path2 : path1);
55201      }
55202
55203      result.copyAttributes(path1, true);
55204      return result;
55205    }
55206
55207    function filterIntersection(inter) {
55208      return inter.hasOverlap() || inter.isCrossing();
55209    }
55210
55211    function traceBoolean(path1, path2, operation, options) {
55212      if (options && (options.trace == false || options.stroke) && /^(subtract|intersect)$/.test(operation)) return splitBoolean(path1, path2, operation);
55213
55214      var _path1 = preparePath(path1, true),
55215          _path2 = path2 && path1 !== path2 && preparePath(path2, true),
55216          operator = operators[operation];
55217
55218      operator[operation] = true;
55219      if (_path2 && (operator.subtract || operator.exclude) ^ (_path2.isClockwise() ^ _path1.isClockwise())) _path2.reverse();
55220
55221      var crossings = divideLocations(CurveLocation.expand(_path1.getIntersections(_path2, filterIntersection))),
55222          paths1 = getPaths(_path1),
55223          paths2 = _path2 && getPaths(_path2),
55224          segments = [],
55225          curves = [],
55226          paths;
55227
55228      function collectPaths(paths) {
55229        for (var i = 0, l = paths.length; i < l; i++) {
55230          var path = paths[i];
55231          Base.push(segments, path._segments);
55232          Base.push(curves, path.getCurves());
55233          path._overlapsOnly = true;
55234        }
55235      }
55236
55237      function getCurves(indices) {
55238        var list = [];
55239
55240        for (var i = 0, l = indices && indices.length; i < l; i++) {
55241          list.push(curves[indices[i]]);
55242        }
55243
55244        return list;
55245      }
55246
55247      if (crossings.length) {
55248        collectPaths(paths1);
55249        if (paths2) collectPaths(paths2);
55250        var curvesValues = new Array(curves.length);
55251
55252        for (var i = 0, l = curves.length; i < l; i++) {
55253          curvesValues[i] = curves[i].getValues();
55254        }
55255
55256        var curveCollisions = CollisionDetection.findCurveBoundsCollisions(curvesValues, curvesValues, 0, true);
55257        var curveCollisionsMap = {};
55258
55259        for (var i = 0; i < curves.length; i++) {
55260          var curve = curves[i],
55261              id = curve._path._id,
55262              map = curveCollisionsMap[id] = curveCollisionsMap[id] || {};
55263          map[curve.getIndex()] = {
55264            hor: getCurves(curveCollisions[i].hor),
55265            ver: getCurves(curveCollisions[i].ver)
55266          };
55267        }
55268
55269        for (var i = 0, l = crossings.length; i < l; i++) {
55270          propagateWinding(crossings[i]._segment, _path1, _path2, curveCollisionsMap, operator);
55271        }
55272
55273        for (var i = 0, l = segments.length; i < l; i++) {
55274          var segment = segments[i],
55275              inter = segment._intersection;
55276
55277          if (!segment._winding) {
55278            propagateWinding(segment, _path1, _path2, curveCollisionsMap, operator);
55279          }
55280
55281          if (!(inter && inter._overlap)) segment._path._overlapsOnly = false;
55282        }
55283
55284        paths = tracePaths(segments, operator);
55285      } else {
55286        paths = reorientPaths(paths2 ? paths1.concat(paths2) : paths1.slice(), function (w) {
55287          return !!operator[w];
55288        });
55289      }
55290
55291      return createResult(paths, true, path1, path2, options);
55292    }
55293
55294    function splitBoolean(path1, path2, operation) {
55295      var _path1 = preparePath(path1),
55296          _path2 = preparePath(path2),
55297          crossings = _path1.getIntersections(_path2, filterIntersection),
55298          subtract = operation === 'subtract',
55299          divide = operation === 'divide',
55300          added = {},
55301          paths = [];
55302
55303      function addPath(path) {
55304        if (!added[path._id] && (divide || _path2.contains(path.getPointAt(path.getLength() / 2)) ^ subtract)) {
55305          paths.unshift(path);
55306          return added[path._id] = true;
55307        }
55308      }
55309
55310      for (var i = crossings.length - 1; i >= 0; i--) {
55311        var path = crossings[i].split();
55312
55313        if (path) {
55314          if (addPath(path)) path.getFirstSegment().setHandleIn(0, 0);
55315
55316          _path1.getLastSegment().setHandleOut(0, 0);
55317        }
55318      }
55319
55320      addPath(_path1);
55321      return createResult(paths, false, path1, path2);
55322    }
55323
55324    function linkIntersections(from, to) {
55325      var prev = from;
55326
55327      while (prev) {
55328        if (prev === to) return;
55329        prev = prev._previous;
55330      }
55331
55332      while (from._next && from._next !== to) {
55333        from = from._next;
55334      }
55335
55336      if (!from._next) {
55337        while (to._previous) {
55338          to = to._previous;
55339        }
55340
55341        from._next = to;
55342        to._previous = from;
55343      }
55344    }
55345
55346    function clearCurveHandles(curves) {
55347      for (var i = curves.length - 1; i >= 0; i--) {
55348        curves[i].clearHandles();
55349      }
55350    }
55351
55352    function reorientPaths(paths, isInside, clockwise) {
55353      var length = paths && paths.length;
55354
55355      if (length) {
55356        var lookup = Base.each(paths, function (path, i) {
55357          this[path._id] = {
55358            container: null,
55359            winding: path.isClockwise() ? 1 : -1,
55360            index: i
55361          };
55362        }, {}),
55363            sorted = paths.slice().sort(function (a, b) {
55364          return abs(b.getArea()) - abs(a.getArea());
55365        }),
55366            first = sorted[0];
55367        var collisions = CollisionDetection.findItemBoundsCollisions(sorted, null, Numerical.GEOMETRIC_EPSILON);
55368        if (clockwise == null) clockwise = first.isClockwise();
55369
55370        for (var i = 0; i < length; i++) {
55371          var path1 = sorted[i],
55372              entry1 = lookup[path1._id],
55373              containerWinding = 0,
55374              indices = collisions[i];
55375
55376          if (indices) {
55377            var point = null;
55378
55379            for (var j = indices.length - 1; j >= 0; j--) {
55380              if (indices[j] < i) {
55381                point = point || path1.getInteriorPoint();
55382                var path2 = sorted[indices[j]];
55383
55384                if (path2.contains(point)) {
55385                  var entry2 = lookup[path2._id];
55386                  containerWinding = entry2.winding;
55387                  entry1.winding += containerWinding;
55388                  entry1.container = entry2.exclude ? entry2.container : path2;
55389                  break;
55390                }
55391              }
55392            }
55393          }
55394
55395          if (isInside(entry1.winding) === isInside(containerWinding)) {
55396            entry1.exclude = true;
55397            paths[entry1.index] = null;
55398          } else {
55399            var container = entry1.container;
55400            path1.setClockwise(container ? !container.isClockwise() : clockwise);
55401          }
55402        }
55403      }
55404
55405      return paths;
55406    }
55407
55408    function divideLocations(locations, include, clearLater) {
55409      var results = include && [],
55410          tMin = 1e-8,
55411          tMax = 1 - tMin,
55412          clearHandles = false,
55413          clearCurves = clearLater || [],
55414          clearLookup = clearLater && {},
55415          renormalizeLocs,
55416          prevCurve,
55417          prevTime;
55418
55419      function getId(curve) {
55420        return curve._path._id + '.' + curve._segment1._index;
55421      }
55422
55423      for (var i = (clearLater && clearLater.length) - 1; i >= 0; i--) {
55424        var curve = clearLater[i];
55425        if (curve._path) clearLookup[getId(curve)] = true;
55426      }
55427
55428      for (var i = locations.length - 1; i >= 0; i--) {
55429        var loc = locations[i],
55430            time = loc._time,
55431            origTime = time,
55432            exclude = include && !include(loc),
55433            curve = loc._curve,
55434            segment;
55435
55436        if (curve) {
55437          if (curve !== prevCurve) {
55438            clearHandles = !curve.hasHandles() || clearLookup && clearLookup[getId(curve)];
55439            renormalizeLocs = [];
55440            prevTime = null;
55441            prevCurve = curve;
55442          } else if (prevTime >= tMin) {
55443            time /= prevTime;
55444          }
55445        }
55446
55447        if (exclude) {
55448          if (renormalizeLocs) renormalizeLocs.push(loc);
55449          continue;
55450        } else if (include) {
55451          results.unshift(loc);
55452        }
55453
55454        prevTime = origTime;
55455
55456        if (time < tMin) {
55457          segment = curve._segment1;
55458        } else if (time > tMax) {
55459          segment = curve._segment2;
55460        } else {
55461          var newCurve = curve.divideAtTime(time, true);
55462          if (clearHandles) clearCurves.push(curve, newCurve);
55463          segment = newCurve._segment1;
55464
55465          for (var j = renormalizeLocs.length - 1; j >= 0; j--) {
55466            var l = renormalizeLocs[j];
55467            l._time = (l._time - time) / (1 - time);
55468          }
55469        }
55470
55471        loc._setSegment(segment);
55472
55473        var inter = segment._intersection,
55474            dest = loc._intersection;
55475
55476        if (inter) {
55477          linkIntersections(inter, dest);
55478          var other = inter;
55479
55480          while (other) {
55481            linkIntersections(other._intersection, inter);
55482            other = other._next;
55483          }
55484        } else {
55485          segment._intersection = dest;
55486        }
55487      }
55488
55489      if (!clearLater) clearCurveHandles(clearCurves);
55490      return results || locations;
55491    }
55492
55493    function getWinding(point, curves, dir, closed, dontFlip) {
55494      var curvesList = Array.isArray(curves) ? curves : curves[dir ? 'hor' : 'ver'];
55495      var ia = dir ? 1 : 0,
55496          io = ia ^ 1,
55497          pv = [point.x, point.y],
55498          pa = pv[ia],
55499          po = pv[io],
55500          windingEpsilon = 1e-9,
55501          qualityEpsilon = 1e-6,
55502          paL = pa - windingEpsilon,
55503          paR = pa + windingEpsilon,
55504          windingL = 0,
55505          windingR = 0,
55506          pathWindingL = 0,
55507          pathWindingR = 0,
55508          onPath = false,
55509          onAnyPath = false,
55510          quality = 1,
55511          roots = [],
55512          vPrev,
55513          vClose;
55514
55515      function addWinding(v) {
55516        var o0 = v[io + 0],
55517            o3 = v[io + 6];
55518
55519        if (po < min(o0, o3) || po > max(o0, o3)) {
55520          return;
55521        }
55522
55523        var a0 = v[ia + 0],
55524            a1 = v[ia + 2],
55525            a2 = v[ia + 4],
55526            a3 = v[ia + 6];
55527
55528        if (o0 === o3) {
55529          if (a0 < paR && a3 > paL || a3 < paR && a0 > paL) {
55530            onPath = true;
55531          }
55532
55533          return;
55534        }
55535
55536        var t = po === o0 ? 0 : po === o3 ? 1 : paL > max(a0, a1, a2, a3) || paR < min(a0, a1, a2, a3) ? 1 : Curve.solveCubic(v, io, po, roots, 0, 1) > 0 ? roots[0] : 1,
55537            a = t === 0 ? a0 : t === 1 ? a3 : Curve.getPoint(v, t)[dir ? 'y' : 'x'],
55538            winding = o0 > o3 ? 1 : -1,
55539            windingPrev = vPrev[io] > vPrev[io + 6] ? 1 : -1,
55540            a3Prev = vPrev[ia + 6];
55541
55542        if (po !== o0) {
55543          if (a < paL) {
55544            pathWindingL += winding;
55545          } else if (a > paR) {
55546            pathWindingR += winding;
55547          } else {
55548            onPath = true;
55549          }
55550
55551          if (a > pa - qualityEpsilon && a < pa + qualityEpsilon) quality /= 2;
55552        } else {
55553          if (winding !== windingPrev) {
55554            if (a0 < paL) {
55555              pathWindingL += winding;
55556            } else if (a0 > paR) {
55557              pathWindingR += winding;
55558            }
55559          } else if (a0 != a3Prev) {
55560            if (a3Prev < paR && a > paR) {
55561              pathWindingR += winding;
55562              onPath = true;
55563            } else if (a3Prev > paL && a < paL) {
55564              pathWindingL += winding;
55565              onPath = true;
55566            }
55567          }
55568
55569          quality /= 4;
55570        }
55571
55572        vPrev = v;
55573        return !dontFlip && a > paL && a < paR && Curve.getTangent(v, t)[dir ? 'x' : 'y'] === 0 && getWinding(point, curves, !dir, closed, true);
55574      }
55575
55576      function handleCurve(v) {
55577        var o0 = v[io + 0],
55578            o1 = v[io + 2],
55579            o2 = v[io + 4],
55580            o3 = v[io + 6];
55581
55582        if (po <= max(o0, o1, o2, o3) && po >= min(o0, o1, o2, o3)) {
55583          var a0 = v[ia + 0],
55584              a1 = v[ia + 2],
55585              a2 = v[ia + 4],
55586              a3 = v[ia + 6],
55587              monoCurves = paL > max(a0, a1, a2, a3) || paR < min(a0, a1, a2, a3) ? [v] : Curve.getMonoCurves(v, dir),
55588              res;
55589
55590          for (var i = 0, l = monoCurves.length; i < l; i++) {
55591            if (res = addWinding(monoCurves[i])) return res;
55592          }
55593        }
55594      }
55595
55596      for (var i = 0, l = curvesList.length; i < l; i++) {
55597        var curve = curvesList[i],
55598            path = curve._path,
55599            v = curve.getValues(),
55600            res;
55601
55602        if (!i || curvesList[i - 1]._path !== path) {
55603          vPrev = null;
55604
55605          if (!path._closed) {
55606            vClose = Curve.getValues(path.getLastCurve().getSegment2(), curve.getSegment1(), null, !closed);
55607
55608            if (vClose[io] !== vClose[io + 6]) {
55609              vPrev = vClose;
55610            }
55611          }
55612
55613          if (!vPrev) {
55614            vPrev = v;
55615            var prev = path.getLastCurve();
55616
55617            while (prev && prev !== curve) {
55618              var v2 = prev.getValues();
55619
55620              if (v2[io] !== v2[io + 6]) {
55621                vPrev = v2;
55622                break;
55623              }
55624
55625              prev = prev.getPrevious();
55626            }
55627          }
55628        }
55629
55630        if (res = handleCurve(v)) return res;
55631
55632        if (i + 1 === l || curvesList[i + 1]._path !== path) {
55633          if (vClose && (res = handleCurve(vClose))) return res;
55634
55635          if (onPath && !pathWindingL && !pathWindingR) {
55636            pathWindingL = pathWindingR = path.isClockwise(closed) ^ dir ? 1 : -1;
55637          }
55638
55639          windingL += pathWindingL;
55640          windingR += pathWindingR;
55641          pathWindingL = pathWindingR = 0;
55642
55643          if (onPath) {
55644            onAnyPath = true;
55645            onPath = false;
55646          }
55647
55648          vClose = null;
55649        }
55650      }
55651
55652      windingL = abs(windingL);
55653      windingR = abs(windingR);
55654      return {
55655        winding: max(windingL, windingR),
55656        windingL: windingL,
55657        windingR: windingR,
55658        quality: quality,
55659        onPath: onAnyPath
55660      };
55661    }
55662
55663    function propagateWinding(segment, path1, path2, curveCollisionsMap, operator) {
55664      var chain = [],
55665          start = segment,
55666          totalLength = 0,
55667          winding;
55668
55669      do {
55670        var curve = segment.getCurve();
55671
55672        if (curve) {
55673          var length = curve.getLength();
55674          chain.push({
55675            segment: segment,
55676            curve: curve,
55677            length: length
55678          });
55679          totalLength += length;
55680        }
55681
55682        segment = segment.getNext();
55683      } while (segment && !segment._intersection && segment !== start);
55684
55685      var offsets = [0.5, 0.25, 0.75],
55686          winding = {
55687        winding: 0,
55688        quality: -1
55689      },
55690          tMin = 1e-3,
55691          tMax = 1 - tMin;
55692
55693      for (var i = 0; i < offsets.length && winding.quality < 0.5; i++) {
55694        var length = totalLength * offsets[i];
55695
55696        for (var j = 0, l = chain.length; j < l; j++) {
55697          var entry = chain[j],
55698              curveLength = entry.length;
55699
55700          if (length <= curveLength) {
55701            var curve = entry.curve,
55702                path = curve._path,
55703                parent = path._parent,
55704                operand = parent instanceof CompoundPath ? parent : path,
55705                t = Numerical.clamp(curve.getTimeAt(length), tMin, tMax),
55706                pt = curve.getPointAtTime(t),
55707                dir = abs(curve.getTangentAtTime(t).y) < Math.SQRT1_2;
55708            var wind = null;
55709
55710            if (operator.subtract && path2) {
55711              var otherPath = operand === path1 ? path2 : path1,
55712                  pathWinding = otherPath._getWinding(pt, dir, true);
55713
55714              if (operand === path1 && pathWinding.winding || operand === path2 && !pathWinding.winding) {
55715                if (pathWinding.quality < 1) {
55716                  continue;
55717                } else {
55718                  wind = {
55719                    winding: 0,
55720                    quality: 1
55721                  };
55722                }
55723              }
55724            }
55725
55726            wind = wind || getWinding(pt, curveCollisionsMap[path._id][curve.getIndex()], dir, true);
55727            if (wind.quality > winding.quality) winding = wind;
55728            break;
55729          }
55730
55731          length -= curveLength;
55732        }
55733      }
55734
55735      for (var j = chain.length - 1; j >= 0; j--) {
55736        chain[j].segment._winding = winding;
55737      }
55738    }
55739
55740    function tracePaths(segments, operator) {
55741      var paths = [],
55742          starts;
55743
55744      function isValid(seg) {
55745        var winding;
55746        return !!(seg && !seg._visited && (!operator || operator[(winding = seg._winding || {}).winding] && !(operator.unite && winding.winding === 2 && winding.windingL && winding.windingR)));
55747      }
55748
55749      function isStart(seg) {
55750        if (seg) {
55751          for (var i = 0, l = starts.length; i < l; i++) {
55752            if (seg === starts[i]) return true;
55753          }
55754        }
55755
55756        return false;
55757      }
55758
55759      function visitPath(path) {
55760        var segments = path._segments;
55761
55762        for (var i = 0, l = segments.length; i < l; i++) {
55763          segments[i]._visited = true;
55764        }
55765      }
55766
55767      function getCrossingSegments(segment, collectStarts) {
55768        var inter = segment._intersection,
55769            start = inter,
55770            crossings = [];
55771        if (collectStarts) starts = [segment];
55772
55773        function collect(inter, end) {
55774          while (inter && inter !== end) {
55775            var other = inter._segment,
55776                path = other && other._path;
55777
55778            if (path) {
55779              var next = other.getNext() || path.getFirstSegment(),
55780                  nextInter = next._intersection;
55781
55782              if (other !== segment && (isStart(other) || isStart(next) || next && isValid(other) && (isValid(next) || nextInter && isValid(nextInter._segment)))) {
55783                crossings.push(other);
55784              }
55785
55786              if (collectStarts) starts.push(other);
55787            }
55788
55789            inter = inter._next;
55790          }
55791        }
55792
55793        if (inter) {
55794          collect(inter);
55795
55796          while (inter && inter._prev) {
55797            inter = inter._prev;
55798          }
55799
55800          collect(inter, start);
55801        }
55802
55803        return crossings;
55804      }
55805
55806      segments.sort(function (seg1, seg2) {
55807        var inter1 = seg1._intersection,
55808            inter2 = seg2._intersection,
55809            over1 = !!(inter1 && inter1._overlap),
55810            over2 = !!(inter2 && inter2._overlap),
55811            path1 = seg1._path,
55812            path2 = seg2._path;
55813        return over1 ^ over2 ? over1 ? 1 : -1 : !inter1 ^ !inter2 ? inter1 ? 1 : -1 : path1 !== path2 ? path1._id - path2._id : seg1._index - seg2._index;
55814      });
55815
55816      for (var i = 0, l = segments.length; i < l; i++) {
55817        var seg = segments[i],
55818            valid = isValid(seg),
55819            path = null,
55820            finished = false,
55821            closed = true,
55822            branches = [],
55823            branch,
55824            visited,
55825            handleIn;
55826
55827        if (valid && seg._path._overlapsOnly) {
55828          var path1 = seg._path,
55829              path2 = seg._intersection._segment._path;
55830
55831          if (path1.compare(path2)) {
55832            if (path1.getArea()) paths.push(path1.clone(false));
55833            visitPath(path1);
55834            visitPath(path2);
55835            valid = false;
55836          }
55837        }
55838
55839        while (valid) {
55840          var first = !path,
55841              crossings = getCrossingSegments(seg, first),
55842              other = crossings.shift(),
55843              finished = !first && (isStart(seg) || isStart(other)),
55844              cross = !finished && other;
55845
55846          if (first) {
55847            path = new Path(Item.NO_INSERT);
55848            branch = null;
55849          }
55850
55851          if (finished) {
55852            if (seg.isFirst() || seg.isLast()) closed = seg._path._closed;
55853            seg._visited = true;
55854            break;
55855          }
55856
55857          if (cross && branch) {
55858            branches.push(branch);
55859            branch = null;
55860          }
55861
55862          if (!branch) {
55863            if (cross) crossings.push(seg);
55864            branch = {
55865              start: path._segments.length,
55866              crossings: crossings,
55867              visited: visited = [],
55868              handleIn: handleIn
55869            };
55870          }
55871
55872          if (cross) seg = other;
55873
55874          if (!isValid(seg)) {
55875            path.removeSegments(branch.start);
55876
55877            for (var j = 0, k = visited.length; j < k; j++) {
55878              visited[j]._visited = false;
55879            }
55880
55881            visited.length = 0;
55882
55883            do {
55884              seg = branch && branch.crossings.shift();
55885
55886              if (!seg || !seg._path) {
55887                seg = null;
55888                branch = branches.pop();
55889
55890                if (branch) {
55891                  visited = branch.visited;
55892                  handleIn = branch.handleIn;
55893                }
55894              }
55895            } while (branch && !isValid(seg));
55896
55897            if (!seg) break;
55898          }
55899
55900          var next = seg.getNext();
55901          path.add(new Segment(seg._point, handleIn, next && seg._handleOut));
55902          seg._visited = true;
55903          visited.push(seg);
55904          seg = next || seg._path.getFirstSegment();
55905          handleIn = next && next._handleIn;
55906        }
55907
55908        if (finished) {
55909          if (closed) {
55910            path.getFirstSegment().setHandleIn(handleIn);
55911            path.setClosed(closed);
55912          }
55913
55914          if (path.getArea() !== 0) {
55915            paths.push(path);
55916          }
55917        }
55918      }
55919
55920      return paths;
55921    }
55922
55923    return {
55924      _getWinding: function _getWinding(point, dir, closed) {
55925        return getWinding(point, this.getCurves(), dir, closed);
55926      },
55927      unite: function unite(path, options) {
55928        return traceBoolean(this, path, 'unite', options);
55929      },
55930      intersect: function intersect(path, options) {
55931        return traceBoolean(this, path, 'intersect', options);
55932      },
55933      subtract: function subtract(path, options) {
55934        return traceBoolean(this, path, 'subtract', options);
55935      },
55936      exclude: function exclude(path, options) {
55937        return traceBoolean(this, path, 'exclude', options);
55938      },
55939      divide: function divide(path, options) {
55940        return options && (options.trace == false || options.stroke) ? splitBoolean(this, path, 'divide') : createResult([this.subtract(path, options), this.intersect(path, options)], true, this, path, options);
55941      },
55942      resolveCrossings: function resolveCrossings() {
55943        var children = this._children,
55944            paths = children || [this];
55945
55946        function hasOverlap(seg, path) {
55947          var inter = seg && seg._intersection;
55948          return inter && inter._overlap && inter._path === path;
55949        }
55950
55951        var hasOverlaps = false,
55952            hasCrossings = false,
55953            intersections = this.getIntersections(null, function (inter) {
55954          return inter.hasOverlap() && (hasOverlaps = true) || inter.isCrossing() && (hasCrossings = true);
55955        }),
55956            clearCurves = hasOverlaps && hasCrossings && [];
55957        intersections = CurveLocation.expand(intersections);
55958
55959        if (hasOverlaps) {
55960          var overlaps = divideLocations(intersections, function (inter) {
55961            return inter.hasOverlap();
55962          }, clearCurves);
55963
55964          for (var i = overlaps.length - 1; i >= 0; i--) {
55965            var overlap = overlaps[i],
55966                path = overlap._path,
55967                seg = overlap._segment,
55968                prev = seg.getPrevious(),
55969                next = seg.getNext();
55970
55971            if (hasOverlap(prev, path) && hasOverlap(next, path)) {
55972              seg.remove();
55973
55974              prev._handleOut._set(0, 0);
55975
55976              next._handleIn._set(0, 0);
55977
55978              if (prev !== seg && !prev.getCurve().hasLength()) {
55979                next._handleIn.set(prev._handleIn);
55980
55981                prev.remove();
55982              }
55983            }
55984          }
55985        }
55986
55987        if (hasCrossings) {
55988          divideLocations(intersections, hasOverlaps && function (inter) {
55989            var curve1 = inter.getCurve(),
55990                seg1 = inter.getSegment(),
55991                other = inter._intersection,
55992                curve2 = other._curve,
55993                seg2 = other._segment;
55994            if (curve1 && curve2 && curve1._path && curve2._path) return true;
55995            if (seg1) seg1._intersection = null;
55996            if (seg2) seg2._intersection = null;
55997          }, clearCurves);
55998          if (clearCurves) clearCurveHandles(clearCurves);
55999          paths = tracePaths(Base.each(paths, function (path) {
56000            Base.push(this, path._segments);
56001          }, []));
56002        }
56003
56004        var length = paths.length,
56005            item;
56006
56007        if (length > 1 && children) {
56008          if (paths !== children) this.setChildren(paths);
56009          item = this;
56010        } else if (length === 1 && !children) {
56011          if (paths[0] !== this) this.setSegments(paths[0].removeSegments());
56012          item = this;
56013        }
56014
56015        if (!item) {
56016          item = new CompoundPath(Item.NO_INSERT);
56017          item.addChildren(paths);
56018          item = item.reduce();
56019          item.copyAttributes(this);
56020          this.replaceWith(item);
56021        }
56022
56023        return item;
56024      },
56025      reorient: function reorient(nonZero, clockwise) {
56026        var children = this._children;
56027
56028        if (children && children.length) {
56029          this.setChildren(reorientPaths(this.removeChildren(), function (w) {
56030            return !!(nonZero ? w : w & 1);
56031          }, clockwise));
56032        } else if (clockwise !== undefined) {
56033          this.setClockwise(clockwise);
56034        }
56035
56036        return this;
56037      },
56038      getInteriorPoint: function getInteriorPoint() {
56039        var bounds = this.getBounds(),
56040            point = bounds.getCenter(true);
56041
56042        if (!this.contains(point)) {
56043          var curves = this.getCurves(),
56044              y = point.y,
56045              intercepts = [],
56046              roots = [];
56047
56048          for (var i = 0, l = curves.length; i < l; i++) {
56049            var v = curves[i].getValues(),
56050                o0 = v[1],
56051                o1 = v[3],
56052                o2 = v[5],
56053                o3 = v[7];
56054
56055            if (y >= min(o0, o1, o2, o3) && y <= max(o0, o1, o2, o3)) {
56056              var monoCurves = Curve.getMonoCurves(v);
56057
56058              for (var j = 0, m = monoCurves.length; j < m; j++) {
56059                var mv = monoCurves[j],
56060                    mo0 = mv[1],
56061                    mo3 = mv[7];
56062
56063                if (mo0 !== mo3 && (y >= mo0 && y <= mo3 || y >= mo3 && y <= mo0)) {
56064                  var x = y === mo0 ? mv[0] : y === mo3 ? mv[6] : Curve.solveCubic(mv, 1, y, roots, 0, 1) === 1 ? Curve.getPoint(mv, roots[0]).x : (mv[0] + mv[6]) / 2;
56065                  intercepts.push(x);
56066                }
56067              }
56068            }
56069          }
56070
56071          if (intercepts.length > 1) {
56072            intercepts.sort(function (a, b) {
56073              return a - b;
56074            });
56075            point.x = (intercepts[0] + intercepts[1]) / 2;
56076          }
56077        }
56078
56079        return point;
56080      }
56081    };
56082  }());
56083  var PathFlattener = Base.extend({
56084    _class: 'PathFlattener',
56085    initialize: function initialize(path, flatness, maxRecursion, ignoreStraight, matrix) {
56086      var curves = [],
56087          parts = [],
56088          length = 0,
56089          minSpan = 1 / (maxRecursion || 32),
56090          segments = path._segments,
56091          segment1 = segments[0],
56092          segment2;
56093
56094      function addCurve(segment1, segment2) {
56095        var curve = Curve.getValues(segment1, segment2, matrix);
56096        curves.push(curve);
56097        computeParts(curve, segment1._index, 0, 1);
56098      }
56099
56100      function computeParts(curve, index, t1, t2) {
56101        if (t2 - t1 > minSpan && !(ignoreStraight && Curve.isStraight(curve)) && !Curve.isFlatEnough(curve, flatness || 0.25)) {
56102          var halves = Curve.subdivide(curve, 0.5),
56103              tMid = (t1 + t2) / 2;
56104          computeParts(halves[0], index, t1, tMid);
56105          computeParts(halves[1], index, tMid, t2);
56106        } else {
56107          var dx = curve[6] - curve[0],
56108              dy = curve[7] - curve[1],
56109              dist = Math.sqrt(dx * dx + dy * dy);
56110
56111          if (dist > 0) {
56112            length += dist;
56113            parts.push({
56114              offset: length,
56115              curve: curve,
56116              index: index,
56117              time: t2
56118            });
56119          }
56120        }
56121      }
56122
56123      for (var i = 1, l = segments.length; i < l; i++) {
56124        segment2 = segments[i];
56125        addCurve(segment1, segment2);
56126        segment1 = segment2;
56127      }
56128
56129      if (path._closed) addCurve(segment2 || segment1, segments[0]);
56130      this.curves = curves;
56131      this.parts = parts;
56132      this.length = length;
56133      this.index = 0;
56134    },
56135    _get: function _get(offset) {
56136      var parts = this.parts,
56137          length = parts.length,
56138          start,
56139          i,
56140          j = this.index;
56141
56142      for (;;) {
56143        i = j;
56144        if (!j || parts[--j].offset < offset) break;
56145      }
56146
56147      for (; i < length; i++) {
56148        var part = parts[i];
56149
56150        if (part.offset >= offset) {
56151          this.index = i;
56152          var prev = parts[i - 1],
56153              prevTime = prev && prev.index === part.index ? prev.time : 0,
56154              prevOffset = prev ? prev.offset : 0;
56155          return {
56156            index: part.index,
56157            time: prevTime + (part.time - prevTime) * (offset - prevOffset) / (part.offset - prevOffset)
56158          };
56159        }
56160      }
56161
56162      return {
56163        index: parts[length - 1].index,
56164        time: 1
56165      };
56166    },
56167    drawPart: function drawPart(ctx, from, to) {
56168      var start = this._get(from),
56169          end = this._get(to);
56170
56171      for (var i = start.index, l = end.index; i <= l; i++) {
56172        var curve = Curve.getPart(this.curves[i], i === start.index ? start.time : 0, i === end.index ? end.time : 1);
56173        if (i === start.index) ctx.moveTo(curve[0], curve[1]);
56174        ctx.bezierCurveTo.apply(ctx, curve.slice(2));
56175      }
56176    }
56177  }, Base.each(Curve._evaluateMethods, function (name) {
56178    this[name + 'At'] = function (offset) {
56179      var param = this._get(offset);
56180
56181      return Curve[name](this.curves[param.index], param.time);
56182    };
56183  }, {}));
56184  var PathFitter = Base.extend({
56185    initialize: function initialize(path) {
56186      var points = this.points = [],
56187          segments = path._segments,
56188          closed = path._closed;
56189
56190      for (var i = 0, prev, l = segments.length; i < l; i++) {
56191        var point = segments[i].point;
56192
56193        if (!prev || !prev.equals(point)) {
56194          points.push(prev = point.clone());
56195        }
56196      }
56197
56198      if (closed) {
56199        points.unshift(points[points.length - 1]);
56200        points.push(points[1]);
56201      }
56202
56203      this.closed = closed;
56204    },
56205    fit: function fit(error) {
56206      var points = this.points,
56207          length = points.length,
56208          segments = null;
56209
56210      if (length > 0) {
56211        segments = [new Segment(points[0])];
56212
56213        if (length > 1) {
56214          this.fitCubic(segments, error, 0, length - 1, points[1].subtract(points[0]), points[length - 2].subtract(points[length - 1]));
56215
56216          if (this.closed) {
56217            segments.shift();
56218            segments.pop();
56219          }
56220        }
56221      }
56222
56223      return segments;
56224    },
56225    fitCubic: function fitCubic(segments, error, first, last, tan1, tan2) {
56226      var points = this.points;
56227
56228      if (last - first === 1) {
56229        var pt1 = points[first],
56230            pt2 = points[last],
56231            dist = pt1.getDistance(pt2) / 3;
56232        this.addCurve(segments, [pt1, pt1.add(tan1.normalize(dist)), pt2.add(tan2.normalize(dist)), pt2]);
56233        return;
56234      }
56235
56236      var uPrime = this.chordLengthParameterize(first, last),
56237          maxError = Math.max(error, error * error),
56238          split,
56239          parametersInOrder = true;
56240
56241      for (var i = 0; i <= 4; i++) {
56242        var curve = this.generateBezier(first, last, uPrime, tan1, tan2);
56243        var max = this.findMaxError(first, last, curve, uPrime);
56244
56245        if (max.error < error && parametersInOrder) {
56246          this.addCurve(segments, curve);
56247          return;
56248        }
56249
56250        split = max.index;
56251        if (max.error >= maxError) break;
56252        parametersInOrder = this.reparameterize(first, last, uPrime, curve);
56253        maxError = max.error;
56254      }
56255
56256      var tanCenter = points[split - 1].subtract(points[split + 1]);
56257      this.fitCubic(segments, error, first, split, tan1, tanCenter);
56258      this.fitCubic(segments, error, split, last, tanCenter.negate(), tan2);
56259    },
56260    addCurve: function addCurve(segments, curve) {
56261      var prev = segments[segments.length - 1];
56262      prev.setHandleOut(curve[1].subtract(curve[0]));
56263      segments.push(new Segment(curve[3], curve[2].subtract(curve[3])));
56264    },
56265    generateBezier: function generateBezier(first, last, uPrime, tan1, tan2) {
56266      var epsilon = 1e-12,
56267          abs = Math.abs,
56268          points = this.points,
56269          pt1 = points[first],
56270          pt2 = points[last],
56271          C = [[0, 0], [0, 0]],
56272          X = [0, 0];
56273
56274      for (var i = 0, l = last - first + 1; i < l; i++) {
56275        var u = uPrime[i],
56276            t = 1 - u,
56277            b = 3 * u * t,
56278            b0 = t * t * t,
56279            b1 = b * t,
56280            b2 = b * u,
56281            b3 = u * u * u,
56282            a1 = tan1.normalize(b1),
56283            a2 = tan2.normalize(b2),
56284            tmp = points[first + i].subtract(pt1.multiply(b0 + b1)).subtract(pt2.multiply(b2 + b3));
56285        C[0][0] += a1.dot(a1);
56286        C[0][1] += a1.dot(a2);
56287        C[1][0] = C[0][1];
56288        C[1][1] += a2.dot(a2);
56289        X[0] += a1.dot(tmp);
56290        X[1] += a2.dot(tmp);
56291      }
56292
56293      var detC0C1 = C[0][0] * C[1][1] - C[1][0] * C[0][1],
56294          alpha1,
56295          alpha2;
56296
56297      if (abs(detC0C1) > epsilon) {
56298        var detC0X = C[0][0] * X[1] - C[1][0] * X[0],
56299            detXC1 = X[0] * C[1][1] - X[1] * C[0][1];
56300        alpha1 = detXC1 / detC0C1;
56301        alpha2 = detC0X / detC0C1;
56302      } else {
56303        var c0 = C[0][0] + C[0][1],
56304            c1 = C[1][0] + C[1][1];
56305        alpha1 = alpha2 = abs(c0) > epsilon ? X[0] / c0 : abs(c1) > epsilon ? X[1] / c1 : 0;
56306      }
56307
56308      var segLength = pt2.getDistance(pt1),
56309          eps = epsilon * segLength,
56310          handle1,
56311          handle2;
56312
56313      if (alpha1 < eps || alpha2 < eps) {
56314        alpha1 = alpha2 = segLength / 3;
56315      } else {
56316        var line = pt2.subtract(pt1);
56317        handle1 = tan1.normalize(alpha1);
56318        handle2 = tan2.normalize(alpha2);
56319
56320        if (handle1.dot(line) - handle2.dot(line) > segLength * segLength) {
56321          alpha1 = alpha2 = segLength / 3;
56322          handle1 = handle2 = null;
56323        }
56324      }
56325
56326      return [pt1, pt1.add(handle1 || tan1.normalize(alpha1)), pt2.add(handle2 || tan2.normalize(alpha2)), pt2];
56327    },
56328    reparameterize: function reparameterize(first, last, u, curve) {
56329      for (var i = first; i <= last; i++) {
56330        u[i - first] = this.findRoot(curve, this.points[i], u[i - first]);
56331      }
56332
56333      for (var i = 1, l = u.length; i < l; i++) {
56334        if (u[i] <= u[i - 1]) return false;
56335      }
56336
56337      return true;
56338    },
56339    findRoot: function findRoot(curve, point, u) {
56340      var curve1 = [],
56341          curve2 = [];
56342
56343      for (var i = 0; i <= 2; i++) {
56344        curve1[i] = curve[i + 1].subtract(curve[i]).multiply(3);
56345      }
56346
56347      for (var i = 0; i <= 1; i++) {
56348        curve2[i] = curve1[i + 1].subtract(curve1[i]).multiply(2);
56349      }
56350
56351      var pt = this.evaluate(3, curve, u),
56352          pt1 = this.evaluate(2, curve1, u),
56353          pt2 = this.evaluate(1, curve2, u),
56354          diff = pt.subtract(point),
56355          df = pt1.dot(pt1) + diff.dot(pt2);
56356      return Numerical.isMachineZero(df) ? u : u - diff.dot(pt1) / df;
56357    },
56358    evaluate: function evaluate(degree, curve, t) {
56359      var tmp = curve.slice();
56360
56361      for (var i = 1; i <= degree; i++) {
56362        for (var j = 0; j <= degree - i; j++) {
56363          tmp[j] = tmp[j].multiply(1 - t).add(tmp[j + 1].multiply(t));
56364        }
56365      }
56366
56367      return tmp[0];
56368    },
56369    chordLengthParameterize: function chordLengthParameterize(first, last) {
56370      var u = [0];
56371
56372      for (var i = first + 1; i <= last; i++) {
56373        u[i - first] = u[i - first - 1] + this.points[i].getDistance(this.points[i - 1]);
56374      }
56375
56376      for (var i = 1, m = last - first; i <= m; i++) {
56377        u[i] /= u[m];
56378      }
56379
56380      return u;
56381    },
56382    findMaxError: function findMaxError(first, last, curve, u) {
56383      var index = Math.floor((last - first + 1) / 2),
56384          maxDist = 0;
56385
56386      for (var i = first + 1; i < last; i++) {
56387        var P = this.evaluate(3, curve, u[i - first]);
56388        var v = P.subtract(this.points[i]);
56389        var dist = v.x * v.x + v.y * v.y;
56390
56391        if (dist >= maxDist) {
56392          maxDist = dist;
56393          index = i;
56394        }
56395      }
56396
56397      return {
56398        error: maxDist,
56399        index: index
56400      };
56401    }
56402  });
56403  var TextItem = Item.extend({
56404    _class: 'TextItem',
56405    _applyMatrix: false,
56406    _canApplyMatrix: false,
56407    _serializeFields: {
56408      content: null
56409    },
56410    _boundsOptions: {
56411      stroke: false,
56412      handle: false
56413    },
56414    initialize: function TextItem(arg) {
56415      this._content = '';
56416      this._lines = [];
56417      var hasProps = arg && Base.isPlainObject(arg) && arg.x === undefined && arg.y === undefined;
56418
56419      this._initialize(hasProps && arg, !hasProps && Point.read(arguments));
56420    },
56421    _equals: function _equals(item) {
56422      return this._content === item._content;
56423    },
56424    copyContent: function copyContent(source) {
56425      this.setContent(source._content);
56426    },
56427    getContent: function getContent() {
56428      return this._content;
56429    },
56430    setContent: function setContent(content) {
56431      this._content = '' + content;
56432      this._lines = this._content.split(/\r\n|\n|\r/mg);
56433
56434      this._changed(521);
56435    },
56436    isEmpty: function isEmpty() {
56437      return !this._content;
56438    },
56439    getCharacterStyle: '#getStyle',
56440    setCharacterStyle: '#setStyle',
56441    getParagraphStyle: '#getStyle',
56442    setParagraphStyle: '#setStyle'
56443  });
56444  var PointText = TextItem.extend({
56445    _class: 'PointText',
56446    initialize: function PointText() {
56447      TextItem.apply(this, arguments);
56448    },
56449    getPoint: function getPoint() {
56450      var point = this._matrix.getTranslation();
56451
56452      return new LinkedPoint(point.x, point.y, this, 'setPoint');
56453    },
56454    setPoint: function setPoint() {
56455      var point = Point.read(arguments);
56456      this.translate(point.subtract(this._matrix.getTranslation()));
56457    },
56458    _draw: function _draw(ctx, param, viewMatrix) {
56459      if (!this._content) return;
56460
56461      this._setStyles(ctx, param, viewMatrix);
56462
56463      var lines = this._lines,
56464          style = this._style,
56465          hasFill = style.hasFill(),
56466          hasStroke = style.hasStroke(),
56467          leading = style.getLeading(),
56468          shadowColor = ctx.shadowColor;
56469      ctx.font = style.getFontStyle();
56470      ctx.textAlign = style.getJustification();
56471
56472      for (var i = 0, l = lines.length; i < l; i++) {
56473        ctx.shadowColor = shadowColor;
56474        var line = lines[i];
56475
56476        if (hasFill) {
56477          ctx.fillText(line, 0, 0);
56478          ctx.shadowColor = 'rgba(0,0,0,0)';
56479        }
56480
56481        if (hasStroke) ctx.strokeText(line, 0, 0);
56482        ctx.translate(0, leading);
56483      }
56484    },
56485    _getBounds: function _getBounds(matrix, options) {
56486      var style = this._style,
56487          lines = this._lines,
56488          numLines = lines.length,
56489          justification = style.getJustification(),
56490          leading = style.getLeading(),
56491          width = this.getView().getTextWidth(style.getFontStyle(), lines),
56492          x = 0;
56493      if (justification !== 'left') x -= width / (justification === 'center' ? 2 : 1);
56494      var rect = new _Rectangle(x, numLines ? -0.75 * leading : 0, width, numLines * leading);
56495      return matrix ? matrix._transformBounds(rect, rect) : rect;
56496    }
56497  });
56498  var Color = Base.extend(new function () {
56499    var types = {
56500      gray: ['gray'],
56501      rgb: ['red', 'green', 'blue'],
56502      hsb: ['hue', 'saturation', 'brightness'],
56503      hsl: ['hue', 'saturation', 'lightness'],
56504      gradient: ['gradient', 'origin', 'destination', 'highlight']
56505    };
56506    var componentParsers = {},
56507        namedColors = {
56508      transparent: [0, 0, 0, 0]
56509    },
56510        colorCtx;
56511
56512    function fromCSS(string) {
56513      var match = string.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?$/i) || string.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])?$/i),
56514          type = 'rgb',
56515          components;
56516
56517      if (match) {
56518        var amount = match[4] ? 4 : 3;
56519        components = new Array(amount);
56520
56521        for (var i = 0; i < amount; i++) {
56522          var value = match[i + 1];
56523          components[i] = parseInt(value.length == 1 ? value + value : value, 16) / 25
565235;
56524        }
56525      } else if (match = string.match(/^(rgb|hsl)a?\((.*)\)$/)) {
56526        type = match[1];
56527        components = match[2].trim().split(/[,\s]+/g);
56528        var isHSL = type === 'hsl';
56529
56530        for (var i = 0, l = Math.min(components.length, 4); i < l; i++) {
56531          var component = components[i];
56532          var value = parseFloat(component);
56533
56534          if (isHSL) {
56535            if (i === 0) {
56536              var unit = component.match(/([a-z]*)$/)[1];
56537              value *= {
56538                turn: 360,
56539                rad: 180 / Math.PI,
56540                grad: 0.9
56541              }[unit] || 1;
56542            } else if (i < 3) {
56543              value /= 100;
56544            }
56545          } else if (i < 3) {
56546            value /= /%$/.test(component) ? 100 : 255;
56547          }
56548
56549          components[i] = value;
56550        }
56551      } else {
56552        var color = namedColors[string];
56553
56554        if (!color) {
56555          if (window) {
56556            if (!colorCtx) {
56557              colorCtx = CanvasProvider.getContext(1, 1);
56558              colorCtx.globalCompositeOperation = 'copy';
56559            }
56560
56561            colorCtx.fillStyle = 'rgba(0,0,0,0)';
56562            colorCtx.fillStyle = string;
56563            colorCtx.fillRect(0, 0, 1, 1);
56564            var data = colorCtx.getImageData(0, 0, 1, 1).data;
56565            color = namedColors[string] = [data[0] / 255, data[1] / 255, data[2] / 255];
56566          } else {
56567            color = [0, 0, 0];
56568          }
56569        }
56570
56571        components = color.slice();
56572      }
56573
56574      return [type, components];
56575    }
56576
56577    var hsbIndices = [[0, 3, 1], [2, 0, 1], [1, 0, 3], [1, 2, 0], [3, 1, 0], [0, 1, 2]];
56578    var converters = {
56579      'rgb-hsb': function rgbHsb(r, g, b) {
56580        var max = Math.max(r, g, b),
56581            min = Math.min(r, g, b),
56582            delta = max - min,
56583            h = delta === 0 ? 0 : (max == r ? (g - b) / delta + (g < b ? 6 : 0) : max == g ? (b - r) / delta + 2 : (r - g) / delta + 4) * 60;
56584        return [h, max === 0 ? 0 : delta / max, max];
56585      },
56586      'hsb-rgb': function hsbRgb(h, s, b) {
56587        h = (h / 60 % 6 + 6) % 6;
56588        var i = Math.floor(h),
56589            f = h - i,
56590            i = hsbIndices[i],
56591            v = [b, b * (1 - s), b * (1 - s * f), b * (1 - s * (1 - f))];
56592        return [v[i[0]], v[i[1]], v[i[2]]];
56593      },
56594      'rgb-hsl': function rgbHsl(r, g, b) {
56595        var max = Math.max(r, g, b),
56596            min = Math.min(r, g, b),
56597            delta = max - min,
56598            achromatic = delta === 0,
56599            h = achromatic ? 0 : (max == r ? (g - b) / delta + (g < b ? 6 : 0) : max == g ? (b - r) / delta + 2 : (r - g) / delta + 4) * 60,
56600            l = (max + min) / 2,
56601            s = achromatic ? 0 : l < 0.5 ? delta / (max + min) : delta / (2 - max - min);
56602        return [h, s, l];
56603      },
56604      'hsl-rgb': function hslRgb(h, s, l) {
56605        h = (h / 360 % 1 + 1) % 1;
56606        if (s === 0) return [l, l, l];
56607        var t3s = [h + 1 / 3, h, h - 1 / 3],
56608            t2 = l < 0.5 ? l * (1 + s) : l + s - l * s,
56609            t1 = 2 * l - t2,
56610            c = [];
56611
56612        for (var i = 0; i < 3; i++) {
56613          var t3 = t3s[i];
56614          if (t3 < 0) t3 += 1;
56615          if (t3 > 1) t3 -= 1;
56616          c[i] = 6 * t3 < 1 ? t1 + (t2 - t1) * 6 * t3 : 2 * t3 < 1 ? t2 : 3 * t3 < 2 ? t1 + (t2 - t1) * (2 / 3 - t3) * 6 : t1;
56617        }
56618
56619        return c;
56620      },
56621      'rgb-gray': function rgbGray(r, g, b) {
56622        return [r * 0.2989 + g * 0.587 + b * 0.114];
56623      },
56624      'gray-rgb': function grayRgb(g) {
56625        return [g, g, g];
56626      },
56627      'gray-hsb': function grayHsb(g) {
56628        return [0, 0, g];
56629      },
56630      'gray-hsl': function grayHsl(g) {
56631        return [0, 0, g];
56632      },
56633      'gradient-rgb': function gradientRgb() {
56634        return [];
56635      },
56636      'rgb-gradient': function rgbGradient() {
56637        return [];
56638      }
56639    };
56640    return Base.each(types, function (properties, type) {
56641      componentParsers[type] = [];
56642      Base.each(properties, function (name, index) {
56643        var part = Base.capitalize(name),
56644            hasOverlap = /^(hue|saturation)$/.test(name),
56645            parser = componentParsers[type][index] = type === 'gradient' ? name === 'gradient' ? function (value) {
56646          var current = this._components[0];
56647          value = Gradient.read(Array.isArray(value) ? value : arguments, 0, {
56648            readNull: true
56649          });
56650
56651          if (current !== value) {
56652            if (current) current._removeOwner(this);
56653            if (value) value._addOwner(this);
56654          }
56655
56656          return value;
56657        } : function () {
56658          return Point.read(arguments, 0, {
56659            readNull: name === 'highlight',
56660            clone: true
56661          });
56662        } : function (value) {
56663          return value == null || isNaN(value) ? 0 : +value;
56664        };
56665
56666        this['get' + part] = function () {
56667          return this._type === type || hasOverlap && /^hs[bl]$/.test(this._type) ? this._components[index] : this._convert(type)[index];
56668        };
56669
56670        this['set' + part] = function (value) {
56671          if (this._type !== type && !(hasOverlap && /^hs[bl]$/.test(this._type))) {
56672            this._components = this._convert(type);
56673            this._properties = types[type];
56674            this._type = type;
56675          }
56676
56677          this._components[index] = parser.call(this, value);
56678
56679          this._changed();
56680        };
56681      }, this);
56682    }, {
vendor: 11,195 bytes, lines 56683-57009
56683      _class: 'Color',
56684      _readIndex: true,
56685      initialize: function Color(arg) {
56686        var args = arguments,
56687            reading = this.__read,
56688            read = 0,
56689            type,
56690            components,
56691            alpha,
56692            values;
56693
56694        if (Array.isArray(arg)) {
56695          args = arg;
56696          arg = args[0];
56697        }
56698
56699        var argType = arg != null && _typeof(arg);
56700
56701        if (argType === 'string' && arg in types) {
56702          type = arg;
56703          arg = args[1];
56704
56705          if (Array.isArray(arg)) {
56706            components = arg;
56707            alpha = args[2];
56708          } else {
56709            if (reading) read = 1;
56710            args = Base.slice(args, 1);
56711            argType = _typeof(arg);
56712          }
56713        }
56714
56715        if (!components) {
56716          values = argType === 'number' ? args : argType === 'object' && arg.length != null ? arg : null;
56717
56718          if (values) {
56719            if (!type) type = values.length >= 3 ? 'rgb' : 'gray';
56720            var length = types[type].length;
56721            alpha = values[length];
56722
56723            if (reading) {
56724              read += values === arguments ? length + (alpha != null ? 1 : 0) : 1;
56725            }
56726
56727            if (values.length > length) values = Base.slice(values, 0, length);
56728          } else if (argType === 'string') {
56729            var converted = fromCSS(arg);
56730            type = converted[0];
56731            components = converted[1];
56732
56733            if (components.length === 4) {
56734              alpha = components[3];
56735              components.length--;
56736            }
56737          } else if (argType === 'object') {
56738            if (arg.constructor === Color) {
56739              type = arg._type;
56740              components = arg._components.slice();
56741              alpha = arg._alpha;
56742
56743              if (type === 'gradient') {
56744                for (var i = 1, l = components.length; i < l; i++) {
56745                  var point = components[i];
56746                  if (point) components[i] = point.clone();
56747                }
56748              }
56749            } else if (arg.constructor === Gradient) {
56750              type = 'gradient';
56751              values = args;
56752            } else {
56753              type = 'hue' in arg ? 'lightness' in arg ? 'hsl' : 'hsb' : 'gradient' in arg || 'stops' in arg || 'radial' in arg ? 'gradient' : 'gray' in arg ? 'gray' : 'rgb';
56754              var properties = types[type],
56755                  parsers = componentParsers[type];
56756              this._components = components = [];
56757
56758              for (var i = 0, l = properties.length; i < l; i++) {
56759                var value = arg[properties[i]];
56760
56761                if (value == null && !i && type === 'gradient' && 'stops' in arg) {
56762                  value = {
56763                    stops: arg.stops,
56764                    radial: arg.radial
56765                  };
56766                }
56767
56768                value = parsers[i].call(this, value);
56769                if (value != null) components[i] = value;
56770              }
56771
56772              alpha = arg.alpha;
56773            }
56774          }
56775
56776          if (reading && type) read = 1;
56777        }
56778
56779        this._type = type || 'rgb';
56780
56781        if (!components) {
56782          this._components = components = [];
56783          var parsers = componentParsers[this._type];
56784
56785          for (var i = 0, l = parsers.length; i < l; i++) {
56786            var value = parsers[i].call(this, values && values[i]);
56787            if (value != null) components[i] = value;
56788          }
56789        }
56790
56791        this._components = components;
56792        this._properties = types[this._type];
56793        this._alpha = alpha;
56794        if (reading) this.__read = read;
56795        return this;
56796      },
56797      set: '#initialize',
56798      _serialize: function _serialize(options, dictionary) {
56799        var components = this.getComponents();
56800        return Base.serialize(/^(gray|rgb)$/.test(this._type) ? components : [this._type].concat(components), options, true, dictionary);
56801      },
56802      _changed: function _changed() {
56803        this._canvasStyle = null;
56804
56805        if (this._owner) {
56806          if (this._setter) {
56807            this._owner[this._setter](this);
56808          } else {
56809            this._owner._changed(129);
56810          }
56811        }
56812      },
56813      _convert: function _convert(type) {
56814        var converter;
56815        return this._type === type ? this._components.slice() : (converter = converters[this._type + '-' + type]) ? converter.apply(this, this._components) : converters['rgb-' + type].apply(this, converters[this._type + '-rgb'].apply(this, this._components));
56816      },
56817      convert: function convert(type) {
56818        return new Color(type, this._convert(type), this._alpha);
56819      },
56820      getType: function getType() {
56821        return this._type;
56822      },
56823      setType: function setType(type) {
56824        this._components = this._convert(type);
56825        this._properties = types[type];
56826        this._type = type;
56827      },
56828      getComponents: function getComponents() {
56829        var components = this._components.slice();
56830
56831        if (this._alpha != null) components.push(this._alpha);
56832        return components;
56833      },
56834      getAlpha: function getAlpha() {
56835        return this._alpha != null ? this._alpha : 1;
56836      },
56837      setAlpha: function setAlpha(alpha) {
56838        this._alpha = alpha == null ? null : Math.min(Math.max(alpha, 0), 1);
56839
56840        this._changed();
56841      },
56842      hasAlpha: function hasAlpha() {
56843        return this._alpha != null;
56844      },
56845      equals: function equals(color) {
56846        var col = Base.isPlainValue(color, true) ? Color.read(arguments) : color;
56847        return col === this || col && this._class === col._class && this._type === col._type && this.getAlpha() === col.getAlpha() && Base.equals(this._components, col._components) || false;
56848      },
56849      toString: function toString() {
56850        var properties = this._properties,
56851            parts = [],
56852            isGradient = this._type === 'gradient',
56853            f = Formatter.instance;
56854
56855        for (var i = 0, l = properties.length; i < l; i++) {
56856          var value = this._components[i];
56857          if (value != null) parts.push(properties[i] + ': ' + (isGradient ? value : f.number(value)));
56858        }
56859
56860        if (this._alpha != null) parts.push('alpha: ' + f.number(this._alpha));
56861        return '{ ' + parts.join(', ') + ' }';
56862      },
56863      toCSS: function toCSS(hex) {
56864        var components = this._convert('rgb'),
56865            alpha = hex || this._alpha == null ? 1 : this._alpha;
56866
56867        function convert(val) {
56868          return Math.round((val < 0 ? 0 : val > 1 ? 1 : val) * 255);
56869        }
56870
56871        components = [convert(components[0]), convert(components[1]), convert(components[2])];
56872        if (alpha < 1) components.push(alpha < 0 ? 0 : alpha);
56873        return hex ? '#' + ((1 << 24) + (components[0] << 16) + (components[1] << 8) + components[2]).toString(16).slice(1) : (components.length == 4 ? 'rgba(' : 'rgb(') + components.join(',') + ')';
56874      },
56875      toCanvasStyle: function toCanvasStyle(ctx, matrix) {
56876        if (this._canvasStyle) return this._canvasStyle;
56877        if (this._type !== 'gradient') return this._canvasStyle = this.toCSS();
56878        var components = this._components,
56879            gradient = components[0],
56880            stops = gradient._stops,
56881            origin = components[1],
56882            destination = components[2],
56883            highlight = components[3],
56884            inverse = matrix && matrix.inverted(),
56885            canvasGradient;
56886
56887        if (inverse) {
56888          origin = inverse._transformPoint(origin);
56889          destination = inverse._transformPoint(destination);
56890          if (highlight) highlight = inverse._transformPoint(highlight);
56891        }
56892
56893        if (gradient._radial) {
56894          var radius = destination.getDistance(origin);
56895
56896          if (highlight) {
56897            var vector = highlight.subtract(origin);
56898            if (vector.getLength() > radius) highlight = origin.add(vector.normalize(radius - 0.1));
56899          }
56900
56901          var start = highlight || origin;
56902          canvasGradient = ctx.createRadialGradient(start.x, start.y, 0, origin.x, origin.y, radius);
56903        } else {
56904          canvasGradient = ctx.createLinearGradient(origin.x, origin.y, destination.x, destination.y);
56905        }
56906
56907        for (var i = 0, l = stops.length; i < l; i++) {
56908          var stop = stops[i],
56909              offset = stop._offset;
56910          canvasGradient.addColorStop(offset == null ? i / (l - 1) : offset, stop._color.toCanvasStyle());
56911        }
56912
56913        return this._canvasStyle = canvasGradient;
56914      },
56915      transform: function transform(matrix) {
56916        if (this._type === 'gradient') {
56917          var components = this._components;
56918
56919          for (var i = 1, l = components.length; i < l; i++) {
56920            var point = components[i];
56921
56922            matrix._transformPoint(point, point, true);
56923          }
56924
56925          this._changed();
56926        }
56927      },
56928      statics: {
56929        _types: types,
56930        random: function random() {
56931          var random = Math.random;
56932          return new Color(random(), random(), random());
56933        },
56934        _setOwner: function _setOwner(color, owner, setter) {
56935          if (color) {
56936            if (color._owner && owner && color._owner !== owner) {
56937              color = color.clone();
56938            }
56939
56940            if (!color._owner ^ !owner) {
56941              color._owner = owner || null;
56942              color._setter = setter || null;
56943            }
56944          }
56945
56946          return color;
56947        }
56948      }
56949    });
56950  }(), new function () {
56951    var operators = {
56952      add: function add(a, b) {
56953        return a + b;
56954      },
56955      subtract: function subtract(a, b) {
56956        return a - b;
56957      },
56958      multiply: function multiply(a, b) {
56959        return a * b;
56960      },
56961      divide: function divide(a, b) {
56962        return a / b;
56963      }
56964    };
56965    return Base.each(operators, function (operator, name) {
56966      this[name] = function (color) {
56967        color = Color.read(arguments);
56968
56969        var type = this._type,
56970            components1 = this._components,
56971            components2 = color._convert(type);
56972
56973        for (var i = 0, l = components1.length; i < l; i++) {
56974          components2[i] = operator(components1[i], components2[i]);
56975        }
56976
56977        return new Color(type, components2, this._alpha != null ? operator(this._alpha, color.getAlpha()) : null);
56978      };
56979    }, {});
56980  }());
56981  var Gradient = Base.extend({
56982    _class: 'Gradient',
56983    initialize: function Gradient(stops, radial) {
56984      this._id = UID.get();
56985
56986      if (stops && Base.isPlainObject(stops)) {
56987        this.set(stops);
56988        stops = radial = null;
56989      }
56990
56991      if (this._stops == null) {
56992        this.setStops(stops || ['white', 'black']);
56993      }
56994
56995      if (this._radial == null) {
56996        this.setRadial(typeof radial === 'string' && radial === 'radial' || radial || false);
56997      }
56998    },
56999    _serialize: function _serialize(options, dictionary) {
57000      return dictionary.add(this, function () {
57001        return Base.serialize([this._stops, this._radial], options, true, dictionary);
57002      });
57003    },
57004    _changed: function _changed() {
57005      for (var i = 0, l = this._owners && this._owners.length; i < l; i++) {
57006        this._owners[i]._changed();
57007      }
57008    },
57009    _addOwner: function _addOwner(color) {
57010      if (!this._owners) this._owners = [];
57011
57012      this._owners.push(color);
57013    },
57014    _removeOwner: function _removeOwner(color) {
57015      var index = this._owners ? this._owners.indexOf(color) : -1;
57016
57017      if (index != -1) {
57018        this._owners.splice(index, 1);
57019
57020        if (!this._owners.length) this._owners = undefined;
57021      }
57022    },
57023    clone: function clone() {
57024      var stops = [];
57025
57026      for (var i = 0, l = this._stops.length; i < l; i++) {
57027        stops[i] = this._stops[i].clone();
57028      }
57029
57030      return new Gradient(stops, this._radial);
57031    },
57032    getStops: function getStops() {
57033      return this._stops;
57034    },
57035    setStops: function setStops(stops) {
57036      if (stops.length < 2) {
57037        throw new Error('Gradient stop list needs to contain at least two stops.');
57038      }
57039
57040      var _stops = this._stops;
57041
57042      if (_stops) {
57043        for (var i = 0, l = _stops.length; i < l; i++) {
57044          _stops[i]._owner = undefined;
57045        }
57046      }
57047
57048      _stops = this._stops = GradientStop.readList(stops, 0, {
57049        clone: true
57050      });
57051
57052      for (var i = 0, l = _stops.length; i < l; i++) {
57053        _stops[i]._owner = this;
57054      }
57055
57056      this._changed();
57057    },
57058    getRadial: function getRadial() {
57059      return this._radial;
57060    },
57061    setRadial: function setRadial(radial) {
57062      this._radial = radial;
57063
57064      this._changed();
57065    },
57066    equals: function equals(gradient) {
57067      if (gradient === this) return true;
57068
57069      if (gradient && this._class === gradient._class) {
57070        var stops1 = this._stops,
57071            stops2 = gradient._stops,
57072            length = stops1.length;
57073
57074        if (length === stops2.length) {
57075          for (var i = 0; i < length; i++) {
57076            if (!stops1[i].equals(stops2[i])) return false;
57077          }
57078
57079          return true;
57080        }
57081      }
57082
57083      return false;
57084    }
57085  });
57086  var GradientStop = Base.extend({
57087    _class: 'GradientStop',
57088    initialize: function GradientStop(arg0, arg1) {
57089      var color = arg0,
57090          offset = arg1;
57091
57092      if (_typeof(arg0) === 'object' && arg1 === undefined) {
57093        if (Array.isArray(arg0) && typeof arg0[0] !== 'number') {
57094          color = arg0[0];
57095          offset = arg0[1];
57096        } else if ('color' in arg0 || 'offset' in arg0 || 'rampPoint' in arg0) {
57097          color = arg0.color;
57098          offset = arg0.offset || arg0.rampPoint || 0;
57099        }
57100      }
57101
57102      this.setColor(color);
57103      this.setOffset(offset);
57104    },
57105    clone: function clone() {
57106      return new GradientStop(this._color.clone(), this._offset);
57107    },
57108    _serialize: function _serialize(options, dictionary) {
57109      var color = this._color,
57110          offset = this._offset;
57111      return Base.serialize(offset == null ? [color] : [color, offset], options, true, dictionary);
57112    },
57113    _changed: function _changed() {
57114      if (this._owner) this._owner._changed(129);
57115    },
57116    getOffset: function getOffset() {
57117      return this._offset;
57118    },
57119    setOffset: function setOffset(offset) {
57120      this._offset = offset;
57121
57122      this._changed();
57123    },
57124    getRampPoint: '#getOffset',
57125    setRampPoint: '#setOffset',
57126    getColor: function getColor() {
57127      return this._color;
57128    },
57129    setColor: function setColor() {
57130      Color._setOwner(this._color, null);
57131
57132      this._color = Color._setOwner(Color.read(arguments, 0), this, 'setColor');
57133
57134      this._changed();
57135    },
57136    equals: function equals(stop) {
57137      return stop === this || stop && this._class === stop._class && this._color.equals(stop._color) && this._offset == stop._offset || false;
57138    }
57139  });
57140  var Style = Base.extend(new function () {
57141    var itemDefaults = {
57142      fillColor: null,
57143      fillRule: 'nonzero',
57144      strokeColor: null,
57145      strokeWidth: 1,
57146      strokeCap: 'butt',
57147      strokeJoin: 'miter',
57148      strokeScaling: true,
57149      miterLimit: 10,
57150      dashOffset: 0,
57151      dashArray: [],
57152      shadowColor: null,
57153      shadowBlur: 0,
57154      shadowOffset: new Point(),
57155      selectedColor: null
57156    },
57157        groupDefaults = Base.set({}, itemDefaults, {
57158      fontFamily: 'sans-serif',
57159      fontWeight: 'normal',
57160      fontSize: 12,
57161      leading: null,
57162      justification: 'left'
57163    }),
57164        textDefaults = Base.set({}, groupDefaults, {
57165      fillColor: new Color()
57166    }),
57167        flags = {
57168      strokeWidth: 193,
57169      strokeCap: 193,
57170      strokeJoin: 193,
57171      strokeScaling: 201,
57172      miterLimit: 193,
57173      fontFamily: 9,
57174      fontWeight: 9,
57175      fontSize: 9,
57176      font: 9,
57177      leading: 9,
57178      justification: 9
57179    },
57180        item = {
57181      beans: true
57182    },
57183        fields = {
57184      _class: 'Style',
57185      beans: true,
57186      initialize: function Style(style, _owner, _project) {
57187        this._values = {};
57188        this._owner = _owner;
57189        this._project = _owner && _owner._project || _project || paper.project;
57190        this._defaults = !_owner || _owner instanceof Group ? groupDefaults : _owner instanceof TextItem ? textDefaults : itemDefaults;
57191        if (style) this.set(style);
57192      }
57193    };
57194    Base.each(groupDefaults, function (value, key) {
57195      var isColor = /Color$/.test(key),
57196          isPoint = key === 'shadowOffset',
57197          part = Base.capitalize(key),
57198          flag = flags[key],
57199          set = 'set' + part,
57200          get = 'get' + part;
vendor: 4,267 bytes, lines 57201-57342
57201
57202      fields[set] = function (value) {
57203        var owner = this._owner,
57204            children = owner && owner._children,
57205            applyToChildren = children && children.length > 0 && !(owner instanceof CompoundPath);
57206
57207        if (applyToChildren) {
57208          for (var i = 0, l = children.length; i < l; i++) {
57209            children[i]._style[set](value);
57210          }
57211        }
57212
57213        if ((key === 'selectedColor' || !applyToChildren) && key in this._defaults) {
57214          var old = this._values[key];
57215
57216          if (old !== value) {
57217            if (isColor) {
57218              if (old) {
57219                Color._setOwner(old, null);
57220
57221                old._canvasStyle = null;
57222              }
57223
57224              if (value && value.constructor === Color) {
57225                value = Color._setOwner(value, owner, applyToChildren && set);
57226              }
57227            }
57228
57229            this._values[key] = value;
57230            if (owner) owner._changed(flag || 129);
57231          }
57232        }
57233      };
57234
57235      fields[get] = function (_dontMerge) {
57236        var owner = this._owner,
57237            children = owner && owner._children,
57238            applyToChildren = children && children.length > 0 && !(owner instanceof CompoundPath),
57239            value;
57240
57241        if (applyToChildren && !_dontMerge) {
57242          for (var i = 0, l = children.length; i < l; i++) {
57243            var childValue = children[i]._style[get]();
57244
57245            if (!i) {
57246              value = childValue;
57247            } else if (!Base.equals(value, childValue)) {
57248              return undefined;
57249            }
57250          }
57251        } else if (key in this._defaults) {
57252          var value = this._values[key];
57253
57254          if (value === undefined) {
57255            value = this._defaults[key];
57256
57257            if (value && value.clone) {
57258              value = value.clone();
57259            }
57260          } else {
57261            var ctor = isColor ? Color : isPoint ? Point : null;
57262
57263            if (ctor && !(value && value.constructor === ctor)) {
57264              this._values[key] = value = ctor.read([value], 0, {
57265                readNull: true,
57266                clone: true
57267              });
57268            }
57269          }
57270        }
57271
57272        if (value && isColor) {
57273          value = Color._setOwner(value, owner, applyToChildren && set);
57274        }
57275
57276        return value;
57277      };
57278
57279      item[get] = function (_dontMerge) {
57280        return this._style[get](_dontMerge);
57281      };
57282
57283      item[set] = function (value) {
57284        this._style[set](value);
57285      };
57286    });
57287    Base.each({
57288      Font: 'FontFamily',
57289      WindingRule: 'FillRule'
57290    }, function (value, key) {
57291      var get = 'get' + key,
57292          set = 'set' + key;
57293      fields[get] = item[get] = '#get' + value;
57294      fields[set] = item[set] = '#set' + value;
57295    });
57296    Item.inject(item);
57297    return fields;
57298  }(), {
57299    set: function set(style) {
57300      var isStyle = style instanceof Style,
57301          values = isStyle ? style._values : style;
57302
57303      if (values) {
57304        for (var key in values) {
57305          if (key in this._defaults) {
57306            var value = values[key];
57307            this[key] = value && isStyle && value.clone ? value.clone() : value;
57308          }
57309        }
57310      }
57311    },
57312    equals: function equals(style) {
57313      function compare(style1, style2, secondary) {
57314        var values1 = style1._values,
57315            values2 = style2._values,
57316            defaults2 = style2._defaults;
57317
57318        for (var key in values1) {
57319          var value1 = values1[key],
57320              value2 = values2[key];
57321          if (!(secondary && key in values2) && !Base.equals(value1, value2 === undefined ? defaults2[key] : value2)) return false;
57322        }
57323
57324        return true;
57325      }
57326
57327      return style === this || style && this._class === style._class && compare(this, style) && compare(style, this, true) || false;
57328    },
57329    _dispose: function _dispose() {
57330      var color;
57331      color = this.getFillColor();
57332      if (color) color._canvasStyle = null;
57333      color = this.getStrokeColor();
57334      if (color) color._canvasStyle = null;
57335      color = this.getShadowColor();
57336      if (color) color._canvasStyle = null;
57337    },
57338    hasFill: function hasFill() {
57339      var color = this.getFillColor();
57340      return !!color && color.alpha > 0;
57341    },
57342    hasStroke: function hasStroke() {
57343      var color = this.getStrokeColor();
57344      return !!color && color.alpha > 0 && this.getStrokeWidth() > 0;
57345    },
57346    hasShadow: function hasShadow() {
57347      var color = this.getShadowColor();
57348      return !!color && color.alpha > 0 && (this.getShadowBlur() > 0 || !this.getShadowOffset().isZero());
57349    },
57350    getView: function getView() {
57351      return this._project._view;
57352    },
57353    getFontStyle: function getFontStyle() {
57354      var fontSize = this.getFontSize();
57355      return this.getFontWeight() + ' ' + fontSize + (/[a-z]/i.test(fontSize + '') ? ' ' : 'px ') + this.getFontFamily();
57356    },
57357    getFont: '#getFontFamily',
57358    setFont: '#setFontFamily',
57359    getLeading: function getLeading() {
57360      var leading = getLeading.base.call(this),
57361          fontSize = this.getFontSize();
57362      if (/pt|em|%|px/.test(fontSize)) fontSize = this.getView().getPixelSize(fontSize);
57363      return leading != null ? leading : fontSize * 1.2;
57364    }
57365  });
57366  var DomElement = new function () {
57367    function handlePrefix(el, name, set, value) {
57368      var prefixes = ['', 'webkit', 'moz', 'Moz', 'ms', 'o'],
57369          suffix = name[0].toUpperCase() + name.substring(1);
57370
57371      for (var i = 0; i < 6; i++) {
57372        var prefix = prefixes[i],
57373            key = prefix ? prefix + suffix : name;
57374
57375        if (key in el) {
57376          if (set) {
57377            el[key] = value;
57378          } else {
57379            return el[key];
57380          }
57381
57382          break;
57383        }
57384      }
57385    }
57386
57387    return {
57388      getStyles: function getStyles(el) {
57389        var doc = el && el.nodeType !== 9 ? el.ownerDocument : el,
57390            view = doc && doc.defaultView;
57391        return view && view.getComputedStyle(el, '');
57392      },
57393      getBounds: function getBounds(el, viewport) {
57394        var doc = el.ownerDocument,
57395            body = doc.body,
57396            html = doc.documentElement,
57397            rect;
57398
57399        try {
57400          rect = el.getBoundingClientRect();
57401        } catch (e) {
57402          rect = {
57403            left: 0,
57404            top: 0,
57405            width: 0,
57406            height: 0
57407          };
57408        }
57409
57410        var x = rect.left - (html.clientLeft || body.clientLeft || 0),
57411            y = rect.top - (html.clientTop || body.clientTop || 0);
57412
57413        if (!viewport) {
57414          var view = doc.defaultView;
57415          x += view.pageXOffset || html.scrollLeft || body.scrollLeft;
57416          y += view.pageYOffset || html.scrollTop || body.scrollTop;
57417        }
57418
57419        return new _Rectangle(x, y, rect.width, rect.height);
57420      },
57421      getViewportBounds: function getViewportBounds(el) {
57422        var doc = el.ownerDocument,
57423            view = doc.defaultView,
57424            html = doc.documentElement;
57425        return new _Rectangle(0, 0, view.innerWidth || html.clientWidth, view.innerHeight || html.clientHeight);
57426      },
57427      getOffset: function getOffset(el, viewport) {
57428        return DomElement.getBounds(el, viewport).getPoint();
57429      },
57430      getSize: function getSize(el) {
57431        return DomElement.getBounds(el, true).getSize();
57432      },
57433      isInvisible: function isInvisible(el) {
57434        return DomElement.getSize(el).equals(new Size(0, 0));
57435      },
57436      isInView: function isInView(el) {
57437        return !DomElement.isInvisible(el) && DomElement.getViewportBounds(el).intersects(DomElement.getBounds(el, true));
57438      },
57439      isInserted: function isInserted(el) {
57440        return document.body.contains(el);
57441      },
57442      getPrefixed: function getPrefixed(el, name) {
57443        return el && handlePrefix(el, name);
57444      },
57445      setPrefixed: function setPrefixed(el, name, value) {
57446        if (_typeof(name) === 'object') {
57447          for (var key in name) {
57448            handlePrefix(el, key, true, name[key]);
57449          }
57450        } else {
57451          handlePrefix(el, name, true, value);
57452        }
57453      }
57454    };
57455  }();
57456  var DomEvent = {
57457    add: function add(el, events) {
57458      if (el) {
57459        for (var type in events) {
57460          var func = events[type],
57461              parts = type.split(/[\s,]+/g);
57462
57463          for (var i = 0, l = parts.length; i < l; i++) {
57464            var name = parts[i];
57465            var options = el === document && (name === 'touchstart' || name === 'touchmove') ? {
vendor: 4,342 bytes, lines 57466-57604
57466              passive: false
57467            } : false;
57468            el.addEventListener(name, func, options);
57469          }
57470        }
57471      }
57472    },
57473    remove: function remove(el, events) {
57474      if (el) {
57475        for (var type in events) {
57476          var func = events[type],
57477              parts = type.split(/[\s,]+/g);
57478
57479          for (var i = 0, l = parts.length; i < l; i++) {
57480            el.removeEventListener(parts[i], func, false);
57481          }
57482        }
57483      }
57484    },
57485    getPoint: function getPoint(event) {
57486      var pos = event.targetTouches ? event.targetTouches.length ? event.targetTouches[0] : event.changedTouches[0] : event;
57487      return new Point(pos.pageX || pos.clientX + document.documentElement.scrollLeft, pos.pageY || pos.clientY + document.documentElement.scrollTop);
57488    },
57489    getTarget: function getTarget(event) {
57490      return event.target || event.srcElement;
57491    },
57492    getRelatedTarget: function getRelatedTarget(event) {
57493      return event.relatedTarget || event.toElement;
57494    },
57495    getOffset: function getOffset(event, target) {
57496      return DomEvent.getPoint(event).subtract(DomElement.getOffset(target || DomEvent.getTarget(event)));
57497    }
57498  };
57499  DomEvent.requestAnimationFrame = new function () {
57500    var nativeRequest = DomElement.getPrefixed(window, 'requestAnimationFrame'),
57501        requested = false,
57502        callbacks = [],
57503        timer;
57504
57505    function handleCallbacks() {
57506      var functions = callbacks;
57507      callbacks = [];
57508
57509      for (var i = 0, l = functions.length; i < l; i++) {
57510        functions[i]();
57511      }
57512
57513      requested = nativeRequest && callbacks.length;
57514      if (requested) nativeRequest(handleCallbacks);
57515    }
57516
57517    return function (callback) {
57518      callbacks.push(callback);
57519
57520      if (nativeRequest) {
57521        if (!requested) {
57522          nativeRequest(handleCallbacks);
57523          requested = true;
57524        }
57525      } else if (!timer) {
57526        timer = setInterval(handleCallbacks, 1000 / 60);
57527      }
57528    };
57529  }();
57530  var View = Base.extend(Emitter, {
57531    _class: 'View',
57532    initialize: function View(project, element) {
57533      function getSize(name) {
57534        return element[name] || parseInt(element.getAttribute(name), 10);
57535      }
57536
57537      function getCanvasSize() {
57538        var size = DomElement.getSize(element);
57539        return size.isNaN() || size.isZero() ? new Size(getSize('width'), getSize('height')) : size;
57540      }
57541
57542      var size;
57543
57544      if (window && element) {
57545        this._id = element.getAttribute('id');
57546        if (this._id == null) element.setAttribute('id', this._id = 'view-' + View._id++);
57547        DomEvent.add(element, this._viewEvents);
57548        var none = 'none';
57549        DomElement.setPrefixed(element.style, {
57550          userDrag: none,
57551          userSelect: none,
57552          touchCallout: none,
57553          contentZooming: none,
57554          tapHighlightColor: 'rgba(0,0,0,0)'
57555        });
57556
57557        if (PaperScope.hasAttribute(element, 'resize')) {
57558          var that = this;
57559          DomEvent.add(window, this._windowEvents = {
57560            resize: function resize() {
57561              that.setViewSize(getCanvasSize());
57562            }
57563          });
57564        }
57565
57566        size = getCanvasSize();
57567
57568        if (PaperScope.hasAttribute(element, 'stats') && typeof Stats !== 'undefined') {
57569          this._stats = new Stats();
57570          var stats = this._stats.domElement,
57571              style = stats.style,
57572              offset = DomElement.getOffset(element);
57573          style.position = 'absolute';
57574          style.left = offset.x + 'px';
57575          style.top = offset.y + 'px';
57576          document.body.appendChild(stats);
57577        }
57578      } else {
57579        size = new Size(element);
57580        element = null;
57581      }
57582
57583      this._project = project;
57584      this._scope = project._scope;
57585      this._element = element;
57586      if (!this._pixelRatio) this._pixelRatio = window && window.devicePixelRatio || 1;
57587
57588      this._setElementSize(size.width, size.height);
57589
57590      this._viewSize = size;
57591
57592      View._views.push(this);
57593
57594      View._viewsById[this._id] = this;
57595      (this._matrix = new Matrix())._owner = this;
57596      if (!View._focused) View._focused = this;
57597      this._frameItems = {};
57598      this._frameItemCount = 0;
57599      this._itemEvents = {
57600        native: {},
57601        virtual: {}
57602      };
57603      this._autoUpdate = !paper.agent.node;
57604      this._needsUpdate = false;
57605    },
57606    remove: function remove() {
57607      if (!this._project) return false;
57608      if (View._focused === this) View._focused = null;
57609
57610      View._views.splice(View._views.indexOf(this), 1);
57611
57612      delete View._viewsById[this._id];
57613      var project = this._project;
57614      if (project._view === this) project._view = null;
57615      DomEvent.remove(this._element, this._viewEvents);
57616      DomEvent.remove(window, this._windowEvents);
57617      this._element = this._project = null;
57618      this.off('frame');
57619      this._animate = false;
57620      this._frameItems = {};
57621      return true;
57622    },
57623    _events: Base.each(Item._itemHandlers.concat(['onResize', 'onKeyDown', 'onKeyUp']), function (name) {
57624      this[name] = {};
57625    }, {
57626      onFrame: {
57627        install: function install() {
57628          this.play();
57629        },
57630        uninstall: function uninstall() {
57631          this.pause();
57632        }
57633      }
57634    }),
57635    _animate: false,
57636    _time: 0,
57637    _count: 0,
57638    getAutoUpdate: function getAutoUpdate() {
57639      return this._autoUpdate;
57640    },
57641    setAutoUpdate: function setAutoUpdate(autoUpdate) {
57642      this._autoUpdate = autoUpdate;
57643      if (autoUpdate) this.requestUpdate();
57644    },
57645    update: function update() {},
57646    draw: function draw() {
57647      this.update();
57648    },
57649    requestUpdate: function requestUpdate() {
57650      if (!this._requested) {
57651        var that = this;
57652        DomEvent.requestAnimationFrame(function () {
57653          that._requested = false;
57654
57655          if (that._animate) {
57656            that.requestUpdate();
57657            var element = that._element;
57658
57659            if ((!DomElement.getPrefixed(document, 'hidden') || PaperScope.getAttribute(element, 'keepalive') === 'true') && DomElement.isInView(element)) {
57660              that._handleFrame();
57661            }
57662          }
57663
57664          if (that._autoUpdate) that.update();
57665        });
57666        this._requested = true;
57667      }
57668    },
57669    play: function play() {
57670      this._animate = true;
57671      this.requestUpdate();
57672    },
57673    pause: function pause() {
57674      this._animate = false;
57675    },
57676    _handleFrame: function _handleFrame() {
57677      paper = this._scope;
57678      var now = Date.now() / 1000,
57679          delta = this._last ? now - this._last : 0;
57680      this._last = now;
57681      this.emit('frame', new Base({
57682        delta: delta,
57683        time: this._time += delta,
57684        count: this._count++
57685      }));
57686      if (this._stats) this._stats.update();
57687    },
57688    _animateItem: function _animateItem(item, animate) {
57689      var items = this._frameItems;
57690
57691      if (animate) {
57692        items[item._id] = {
57693          item: item,
57694          time: 0,
57695          count: 0
57696        };
57697        if (++this._frameItemCount === 1) this.on('frame', this._handleFrameItems);
57698      } else {
57699        delete items[item._id];
57700
57701        if (--this._frameItemCount === 0) {
57702          this.off('frame', this._handleFrameItems);
57703        }
57704      }
57705    },
57706    _handleFrameItems: function _handleFrameItems(event) {
57707      for (var i in this._frameItems) {
57708        var entry = this._frameItems[i];
57709        entry.item.emit('frame', new Base(event, {
57710          time: entry.time += event.delta,
57711          count: entry.count++
57712        }));
57713      }
57714    },
57715    _changed: function _changed() {
57716      this._project._changed(4097);
57717
57718      this._bounds = this._decomposed = undefined;
57719    },
57720    getElement: function getElement() {
57721      return this._element;
57722    },
57723    getPixelRatio: function getPixelRatio() {
57724      return this._pixelRatio;
57725    },
57726    getResolution: function getResolution() {
57727      return this._pixelRatio * 72;
57728    },
57729    getViewSize: function getViewSize() {
57730      var size = this._viewSize;
57731      return new LinkedSize(size.width, size.height, this, 'setViewSize');
57732    },
57733    setViewSize: function setViewSize() {
57734      var size = Size.read(arguments),
57735          delta = size.subtract(this._viewSize);
57736      if (delta.isZero()) return;
57737
57738      this._setElementSize(size.width, size.height);
57739
57740      this._viewSize.set(size);
57741
57742      this._changed();
57743
57744      this.emit('resize', {
57745        size: size,
57746        delta: delta
57747      });
57748
57749      if (this._autoUpdate) {
57750        this.update();
57751      }
57752    },
57753    _setElementSize: function _setElementSize(width, height) {
57754      var element = this._element;
57755
57756      if (element) {
57757        if (element.width !== width) element.width = width;
57758        if (element.height !== height) element.height = height;
57759      }
57760    },
57761    getBounds: function getBounds() {
57762      if (!this._bounds) this._bounds = this._matrix.inverted()._transformBounds(new _Rectangle(new Point(), this._viewSize));
57763      return this._bounds;
57764    },
57765    getSize: function getSize() {
57766      return this.getBounds().getSize();
57767    },
57768    isVisible: function isVisible() {
57769      return DomElement.isInView(this._element);
57770    },
57771    isInserted: function isInserted() {
57772      return DomElement.isInserted(this._element);
57773    },
57774    getPixelSize: function getPixelSize(size) {
57775      var element = this._element,
57776          pixels;
57777
57778      if (element) {
57779        var parent = element.parentNode,
57780            temp = document.createElement('div');
57781        temp.style.fontSize = size;
57782        parent.appendChild(temp);
57783        pixels = parseFloat(DomElement.getStyles(temp).fontSize);
57784        parent.removeChild(temp);
57785      } else {
57786        pixels = parseFloat(pixels);
57787      }
57788
57789      return pixels;
57790    },
57791    getTextWidth: function getTextWidth(font, lines) {
57792      return 0;
57793    }
57794  }, Base.each(['rotate', 'scale', 'shear', 'skew'], function (key) {
57795    var rotate = key === 'rotate';
57796
57797    this[key] = function () {
57798      var args = arguments,
57799          value = (rotate ? Base : Point).read(args),
57800          center = Point.read(args, 0, {
57801        readNull: true
57802      });
57803      return this.transform(new Matrix()[key](value, center || this.getCenter(true)));
57804    };
57805  }, {
57806    _decompose: function _decompose() {
57807      return this._decomposed || (this._decomposed = this._matrix.decompose());
57808    },
57809    translate: function translate() {
57810      var mx = new Matrix();
57811      return this.transform(mx.translate.apply(mx, arguments));
57812    },
57813    getCenter: function getCenter() {
57814      return this.getBounds().getCenter();
57815    },
57816    setCenter: function setCenter() {
57817      var center = Point.read(arguments);
57818      this.translate(this.getCenter().subtract(center));
57819    },
57820    getZoom: function getZoom() {
57821      var scaling = this._decompose().scaling;
57822
57823      return (scaling.x + scaling.y) / 2;
57824    },
57825    setZoom: function setZoom(zoom) {
57826      this.transform(new Matrix().scale(zoom / this.getZoom(), this.getCenter()));
57827    },
57828    getRotation: function getRotation() {
57829      return this._decompose().rotation;
57830    },
57831    setRotation: function setRotation(rotation) {
57832      var current = this.getRotation();
57833
57834      if (current != null && rotation != null) {
57835        this.rotate(rotation - current);
57836      }
57837    },
57838    getScaling: function getScaling() {
57839      var scaling = this._decompose().scaling;
57840
57841      return new LinkedPoint(scaling.x, scaling.y, this, 'setScaling');
57842    },
57843    setScaling: function setScaling() {
57844      var current = this.getScaling(),
57845          scaling = Point.read(arguments, 0, {
57846        clone: true,
57847        readNull: true
57848      });
57849
57850      if (current && scaling) {
57851        this.scale(scaling.x / current.x, scaling.y / current.y);
57852      }
57853    },
57854    getMatrix: function getMatrix() {
57855      return this._matrix;
57856    },
57857    setMatrix: function setMatrix() {
57858      var matrix = this._matrix;
57859      matrix.initialize.apply(matrix, arguments);
57860    },
57861    transform: function transform(matrix) {
57862      this._matrix.append(matrix);
57863    },
57864    scrollBy: function scrollBy() {
57865      this.translate(Point.read(arguments).negate());
57866    }
57867  }), {
57868    projectToView: function projectToView() {
57869      return this._matrix._transformPoint(Point.read(arguments));
57870    },
57871    viewToProject: function viewToProject() {
57872      return this._matrix._inverseTransform(Point.read(arguments));
57873    },
57874    getEventPoint: function getEventPoint(event) {
57875      return this.viewToProject(DomEvent.getOffset(event, this._element));
57876    }
57877  }, {
57878    statics: {
57879      _views: [],
57880      _viewsById: {},
57881      _id: 0,
57882      create: function create(project, element) {
57883        if (document && typeof element === 'string') element = document.getElementById(element);
57884        var ctor = window ? CanvasView : View;
57885        return new ctor(project, element);
57886      }
57887    }
57888  }, new function () {
57889    if (!window) return;
57890    var prevFocus,
57891        tempFocus,
57892        dragging = false,
57893        mouseDown = false;
57894
57895    function getView(event) {
57896      var target = DomEvent.getTarget(event);
57897      return target.getAttribute && View._viewsById[target.getAttribute('id')];
57898    }
57899
57900    function updateFocus() {
57901      var view = View._focused;
57902
57903      if (!view || !view.isVisible()) {
57904        for (var i = 0, l = View._views.length; i < l; i++) {
57905          if ((view = View._views[i]).isVisible()) {
57906            View._focused = tempFocus = view;
57907            break;
57908          }
57909        }
57910      }
57911    }
57912
57913    function handleMouseMove(view, event, point) {
57914      view._handleMouseEvent('mousemove', event, point);
57915    }
57916
57917    var navigator = window.navigator,
57918        mousedown,
57919        mousemove,
57920        mouseup;
57921
57922    if (navigator.pointerEnabled || navigator.msPointerEnabled) {
57923      mousedown = 'pointerdown MSPointerDown';
57924      mousemove = 'pointermove MSPointerMove';
57925      mouseup = 'pointerup pointercancel MSPointerUp MSPointerCancel';
57926    } else {
57927      mousedown = 'touchstart';
57928      mousemove = 'touchmove';
57929      mouseup = 'touchend touchcancel';
57930
57931      if (!('ontouchstart' in window && navigator.userAgent.match(/mobile|tablet|ip(ad|hone|od)|android|silk/i))) {
57932        mousedown += ' mousedown';
57933        mousemove += ' mousemove';
57934        mouseup += ' mouseup';
57935      }
57936    }
57937
57938    var viewEvents = {},
57939        docEvents = {
57940      mouseout: function mouseout(event) {
57941        var view = View._focused,
57942            target = DomEvent.getRelatedTarget(event);
57943
57944        if (view && (!target || target.nodeName === 'HTML')) {
57945          var offset = DomEvent.getOffset(event, view._element),
57946              x = offset.x,
57947              abs = Math.abs,
57948              ax = abs(x),
57949              max = 1 << 25,
57950              diff = ax - max;
57951          offset.x = abs(diff) < ax ? diff * (x < 0 ? -1 : 1) : x;
57952          handleMouseMove(view, event, view.viewToProject(offset));
57953        }
57954      },
57955      scroll: updateFocus
57956    };
57957
57958    viewEvents[mousedown] = function (event) {
57959      var view = View._focused = getView(event);
57960
57961      if (!dragging) {
57962        dragging = true;
57963
57964        view._handleMouseEvent('mousedown', event);
57965      }
57966    };
57967
57968    docEvents[mousemove] = function (event) {
57969      var view = View._focused;
57970
57971      if (!mouseDown) {
57972        var target = getView(event);
57973
57974        if (target) {
57975          if (view !== target) {
57976            if (view) handleMouseMove(view, event);
57977            if (!prevFocus) prevFocus = view;
vendor: 8,406 bytes, lines 57978-58251
57978            view = View._focused = tempFocus = target;
57979          }
57980        } else if (tempFocus && tempFocus === view) {
57981          if (prevFocus && !prevFocus.isInserted()) prevFocus = null;
57982          view = View._focused = prevFocus;
57983          prevFocus = null;
57984          updateFocus();
57985        }
57986      }
57987
57988      if (view) handleMouseMove(view, event);
57989    };
57990
57991    docEvents[mousedown] = function () {
57992      mouseDown = true;
57993    };
57994
57995    docEvents[mouseup] = function (event) {
57996      var view = View._focused;
57997      if (view && dragging) view._handleMouseEvent('mouseup', event);
57998      mouseDown = dragging = false;
57999    };
58000
58001    DomEvent.add(document, docEvents);
58002    DomEvent.add(window, {
58003      load: updateFocus
58004    });
58005    var called = false,
58006        prevented = false,
58007        fallbacks = {
58008      doubleclick: 'click',
58009      mousedrag: 'mousemove'
58010    },
58011        wasInView = false,
58012        overView,
58013        downPoint,
58014        lastPoint,
58015        downItem,
58016        overItem,
58017        dragItem,
58018        clickItem,
58019        clickTime,
58020        dblClick;
58021
58022    function emitMouseEvent(obj, target, type, event, point, prevPoint, stopItem) {
58023      var stopped = false,
58024          mouseEvent;
58025
58026      function emit(obj, type) {
58027        if (obj.responds(type)) {
58028          if (!mouseEvent) {
58029            mouseEvent = new MouseEvent(type, event, point, target || obj, prevPoint ? point.subtract(prevPoint) : null);
58030          }
58031
58032          if (obj.emit(type, mouseEvent)) {
58033            called = true;
58034            if (mouseEvent.prevented) prevented = true;
58035            if (mouseEvent.stopped) return stopped = true;
58036          }
58037        } else {
58038          var fallback = fallbacks[type];
58039          if (fallback) return emit(obj, fallback);
58040        }
58041      }
58042
58043      while (obj && obj !== stopItem) {
58044        if (emit(obj, type)) break;
58045        obj = obj._parent;
58046      }
58047
58048      return stopped;
58049    }
58050
58051    function emitMouseEvents(view, hitItem, type, event, point, prevPoint) {
58052      view._project.removeOn(type);
58053
58054      prevented = called = false;
58055      return dragItem && emitMouseEvent(dragItem, null, type, event, point, prevPoint) || hitItem && hitItem !== dragItem && !hitItem.isDescendant(dragItem) && emitMouseEvent(hitItem, null, type === 'mousedrag' ? 'mousemove' : type, event, point, prevPoint, dragItem) || emitMouseEvent(view, dragItem || hitItem || view, type, event, point, prevPoint);
58056    }
58057
58058    var itemEventsMap = {
58059      mousedown: {
58060        mousedown: 1,
58061        mousedrag: 1,
58062        click: 1,
58063        doubleclick: 1
58064      },
58065      mouseup: {
58066        mouseup: 1,
58067        mousedrag: 1,
58068        click: 1,
58069        doubleclick: 1
58070      },
58071      mousemove: {
58072        mousedrag: 1,
58073        mousemove: 1,
58074        mouseenter: 1,
58075        mouseleave: 1
58076      }
58077    };
58078    return {
58079      _viewEvents: viewEvents,
58080      _handleMouseEvent: function _handleMouseEvent(type, event, point) {
58081        var itemEvents = this._itemEvents,
58082            hitItems = itemEvents.native[type],
58083            nativeMove = type === 'mousemove',
58084            tool = this._scope.tool,
58085            view = this;
58086
58087        function responds(type) {
58088          return itemEvents.virtual[type] || view.responds(type) || tool && tool.responds(type);
58089        }
58090
58091        if (nativeMove && dragging && responds('mousedrag')) type = 'mousedrag';
58092        if (!point) point = this.getEventPoint(event);
58093
58094        var inView = this.getBounds().contains(point),
58095            hit = hitItems && inView && view._project.hitTest(point, {
58096          tolerance: 0,
58097          fill: true,
58098          stroke: true
58099        }),
58100            hitItem = hit && hit.item || null,
58101            handle = false,
58102            mouse = {};
58103
58104        mouse[type.substr(5)] = true;
58105
58106        if (hitItems && hitItem !== overItem) {
58107          if (overItem) {
58108            emitMouseEvent(overItem, null, 'mouseleave', event, point);
58109          }
58110
58111          if (hitItem) {
58112            emitMouseEvent(hitItem, null, 'mouseenter', event, point);
58113          }
58114
58115          overItem = hitItem;
58116        }
58117
58118        if (wasInView ^ inView) {
58119          emitMouseEvent(this, null, inView ? 'mouseenter' : 'mouseleave', event, point);
58120          overView = inView ? this : null;
58121          handle = true;
58122        }
58123
58124        if ((inView || mouse.drag) && !point.equals(lastPoint)) {
58125          emitMouseEvents(this, hitItem, nativeMove ? type : 'mousemove', event, point, lastPoint);
58126          handle = true;
58127        }
58128
58129        wasInView = inView;
58130
58131        if (mouse.down && inView || mouse.up && downPoint) {
58132          emitMouseEvents(this, hitItem, type, event, point, downPoint);
58133
58134          if (mouse.down) {
58135            dblClick = hitItem === clickItem && Date.now() - clickTime < 300;
58136            downItem = clickItem = hitItem;
58137
58138            if (!prevented && hitItem) {
58139              var item = hitItem;
58140
58141              while (item && !item.responds('mousedrag')) {
58142                item = item._parent;
58143              }
58144
58145              if (item) dragItem = hitItem;
58146            }
58147
58148            downPoint = point;
58149          } else if (mouse.up) {
58150            if (!prevented && hitItem === downItem) {
58151              clickTime = Date.now();
58152              emitMouseEvents(this, hitItem, dblClick ? 'doubleclick' : 'click', event, point, downPoint);
58153              dblClick = false;
58154            }
58155
58156            downItem = dragItem = null;
58157          }
58158
58159          wasInView = false;
58160          handle = true;
58161        }
58162
58163        lastPoint = point;
58164
58165        if (handle && tool) {
58166          called = tool._handleMouseEvent(type, event, point, mouse) || called;
58167        }
58168
58169        if (event.cancelable !== false && (called && !mouse.move || mouse.down && responds('mouseup'))) {
58170          event.preventDefault();
58171        }
58172      },
58173      _handleKeyEvent: function _handleKeyEvent(type, event, key, character) {
58174        var scope = this._scope,
58175            tool = scope.tool,
58176            keyEvent;
58177
58178        function emit(obj) {
58179          if (obj.responds(type)) {
58180            paper = scope;
58181            obj.emit(type, keyEvent = keyEvent || new KeyEvent(type, event, key, character));
58182          }
58183        }
58184
58185        if (this.isVisible()) {
58186          emit(this);
58187          if (tool && tool.responds(type)) emit(tool);
58188        }
58189      },
58190      _countItemEvent: function _countItemEvent(type, sign) {
58191        var itemEvents = this._itemEvents,
58192            native = itemEvents.native,
58193            virtual = itemEvents.virtual;
58194
58195        for (var key in itemEventsMap) {
58196          native[key] = (native[key] || 0) + (itemEventsMap[key][type] || 0) * sign;
58197        }
58198
58199        virtual[type] = (virtual[type] || 0) + sign;
58200      },
58201      statics: {
58202        updateFocus: updateFocus,
58203        _resetState: function _resetState() {
58204          dragging = mouseDown = called = wasInView = false;
58205          prevFocus = tempFocus = overView = downPoint = lastPoint = downItem = overItem = dragItem = clickItem = clickTime = dblClick = null;
58206        }
58207      }
58208    };
58209  }());
58210  var CanvasView = View.extend({
58211    _class: 'CanvasView',
58212    initialize: function CanvasView(project, canvas) {
58213      if (!(canvas instanceof window.HTMLCanvasElement)) {
58214        var size = Size.read(arguments, 1);
58215        if (size.isZero()) throw new Error('Cannot create CanvasView with the provided argument: ' + Base.slice(arguments, 1));
58216        canvas = CanvasProvider.getCanvas(size);
58217      }
58218
58219      var ctx = this._context = canvas.getContext('2d');
58220      ctx.save();
58221      this._pixelRatio = 1;
58222
58223      if (!/^off|false$/.test(PaperScope.getAttribute(canvas, 'hidpi'))) {
58224        var deviceRatio = window.devicePixelRatio || 1,
58225            backingStoreRatio = DomElement.getPrefixed(ctx, 'backingStorePixelRatio') || 1;
58226        this._pixelRatio = deviceRatio / backingStoreRatio;
58227      }
58228
58229      View.call(this, project, canvas);
58230      this._needsUpdate = true;
58231    },
58232    remove: function remove() {
58233      this._context.restore();
58234
58235      return remove.base.call(this);
58236    },
58237    _setElementSize: function _setElementSize(width, height) {
58238      var pixelRatio = this._pixelRatio;
58239
58240      _setElementSize.base.call(this, width * pixelRatio, height * pixelRatio);
58241
58242      if (pixelRatio !== 1) {
58243        var element = this._element,
58244            ctx = this._context;
58245
58246        if (!PaperScope.hasAttribute(element, 'resize')) {
58247          var style = element.style;
58248          style.width = width + 'px';
58249          style.height = height + 'px';
58250        }
58251
58252        ctx.restore();
58253        ctx.save();
58254        ctx.scale(pixelRatio, pixelRatio);
58255      }
58256    },
58257    getContext: function getContext() {
58258      return this._context;
58259    },
58260    getPixelSize: function getPixelSize(size) {
58261      var agent = paper.agent,
58262          pixels;
58263
58264      if (agent && agent.firefox) {
58265        pixels = getPixelSize.base.call(this, size);
58266      } else {
58267        var ctx = this._context,
58268            prevFont = ctx.font;
58269        ctx.font = size + ' serif';
58270        pixels = parseFloat(ctx.font);
58271        ctx.font = prevFont;
58272      }
58273
58274      return pixels;
58275    },
58276    getTextWidth: function getTextWidth(font, lines) {
58277      var ctx = this._context,
58278          prevFont = ctx.font,
58279          width = 0;
58280      ctx.font = font;
58281
58282      for (var i = 0, l = lines.length; i < l; i++) {
58283        width = Math.max(width, ctx.measureText(lines[i]).width);
58284      }
58285
58286      ctx.font = prevFont;
58287      return width;
58288    },
58289    update: function update() {
58290      if (!this._needsUpdate) return false;
58291      var project = this._project,
58292          ctx = this._context,
58293          size = this._viewSize;
58294      ctx.clearRect(0, 0, size.width + 1, size.height + 1);
58295      if (project) project.draw(ctx, this._matrix, this._pixelRatio);
58296      this._needsUpdate = false;
58297      return true;
58298    }
58299  });
58300  var Event = Base.extend({
58301    _class: 'Event',
58302    initialize: function Event(event) {
58303      this.event = event;
58304      this.type = event && event.type;
58305    },
58306    prevented: false,
58307    stopped: false,
58308    preventDefault: function preventDefault() {
58309      this.prevented = true;
58310      this.event.preventDefault();
58311    },
58312    stopPropagation: function stopPropagation() {
58313      this.stopped = true;
58314      this.event.stopPropagation();
58315    },
58316    stop: function stop() {
58317      this.stopPropagation();
58318      this.preventDefault();
58319    },
58320    getTimeStamp: function getTimeStamp() {
58321      return this.event.timeStamp;
58322    },
58323    getModifiers: function getModifiers() {
58324      return Key.modifiers;
58325    }
58326  });
58327  var KeyEvent = Event.extend({
58328    _class: 'KeyEvent',
58329    initialize: function KeyEvent(type, event, key, character) {
58330      this.type = type;
58331      this.event = event;
58332      this.key = key;
58333      this.character = character;
58334    },
58335    toString: function toString() {
58336      return "{ type: '" + this.type + "', key: '" + this.key + "', character: '" + this.character + "', modifiers: " + this.getModifiers() + " }";
58337    }
58338  });
58339  var Key = new function () {
58340    var keyLookup = {
58341      '\t': 'tab',
58342      ' ': 'space',
58343      '\b': 'backspace',
58344      '\x7f': 'delete',
58345      'Spacebar': 'space',
58346      'Del': 'delete',
58347      'Win': 'meta',
58348      'Esc': 'escape'
58349    },
58350        charLookup = {
58351      'tab': '\t',
58352      'space': ' ',
58353      'enter': '\r'
58354    },
58355        keyMap = {},
58356        charMap = {},
58357        metaFixMap,
58358        downKey,
58359        modifiers = new Base({
58360      shift: false,
58361      control: false,
58362      alt: false,
58363      meta: false,
58364      capsLock: false,
58365      space: false
58366    }).inject({
58367      option: {
58368        get: function get() {
58369          return this.alt;
58370        }
58371      },
58372      command: {
58373        get: function get() {
58374          var agent = paper && paper.agent;
58375          return agent && agent.mac ? this.meta : this.control;
58376        }
58377      }
58378    });
58379
58380    function getKey(event) {
58381      var key = event.key || event.keyIdentifier;
58382      key = /^U\+/.test(key) ? String.fromCharCode(parseInt(key.substr(2), 16)) : /^Arrow[A-Z]/.test(key) ? key.substr(5) : key === 'Unidentified' || key === undefined ? String.fromCharCode(event.keyCode) : key;
58383      return keyLookup[key] || (key.length > 1 ? Base.hyphenate(key) : key.toLowerCase());
58384    }
58385
58386    function handleKey(down, key, character, event) {
58387      var type = down ? 'keydown' : 'keyup',
58388          view = View._focused,
58389          name;
58390      keyMap[key] = down;
58391
58392      if (down) {
58393        charMap[key] = character;
58394      } else {
58395        delete charMap[key];
58396      }
58397
58398      if (key.length > 1 && (name = Base.camelize(key)) in modifiers) {
58399        modifiers[name] = down;
58400        var agent = paper && paper.agent;
58401
58402        if (name === 'meta' && agent && agent.mac) {
58403          if (down) {
58404            metaFixMap = {};
58405          } else {
58406            for (var k in metaFixMap) {
58407              if (k in charMap) handleKey(false, k, metaFixMap[k], event);
58408            }
58409
58410            metaFixMap = null;
58411          }
58412        }
58413      } else if (down && metaFixMap) {
58414        metaFixMap[key] = character;
58415      }
58416
58417      if (view) {
58418        view._handleKeyEvent(down ? 'keydown' : 'keyup', event, key, character);
58419      }
58420    }
58421
58422    DomEvent.add(document, {
58423      keydown: function keydown(event) {
58424        var key = getKey(event),
58425            agent = paper && paper.agent;
58426
58427        if (key.length > 1 || agent && agent.chrome && (event.altKey || agent.mac && event.metaKey || !agent.mac && event.ctrlKey)) {
58428          handleKey(true, key, charLookup[key] || (key.length > 1 ? '' : key), event);
58429        } else {
58430          downKey = key;
58431        }
58432      },
58433      keypress: function keypress(event) {
58434        if (downKey) {
58435          var key = getKey(event),
58436              code = event.charCode,
58437              character = code >= 32 ? String.fromCharCode(code) : key.length > 1 ? '' : key;
58438
58439          if (key !== downKey) {
58440            key = character.toLowerCase();
58441          }
58442
58443          handleKey(true, key, character, event);
58444          downKey = null;
58445        }
58446      },
58447      keyup: function keyup(event) {
58448        var key = getKey(event);
58449        if (key in charMap) handleKey(false, key, charMap[key], event);
58450      }
58451    });
58452    DomEvent.add(window, {
58453      blur: function blur(event) {
58454        for (var key in charMap) {
58455          handleKey(false, key, charMap[key], event);
58456        }
58457      }
58458    });
58459    return {
58460      modifiers: modifiers,
58461      isDown: function isDown(key) {
58462        return !!keyMap[key];
58463      }
58464    };
58465  }();
58466  var MouseEvent = Event.extend({
58467    _class: 'MouseEvent',
58468    initialize: function MouseEvent(type, event, point, target, delta) {
58469      this.type = type;
58470      this.event = event;
58471      this.point = point;
58472      this.target = target;
58473      this.delta = delta;
58474    },
58475    toString: function toString() {
58476      return "{ type: '" + this.type + "', point: " + this.point + ', target: ' + this.target + (this.delta ? ', delta: ' + this.delta : '') + ', modifiers: ' + this.getModifiers() + ' }';
58477    }
58478  });
58479  var ToolEvent = Event.extend({
58480    _class: 'ToolEvent',
58481    _item: null,
58482    initialize: function ToolEvent(tool, type, event) {
58483      this.tool = tool;
58484      this.type = type;
58485      this.event = event;
58486    },
58487    _choosePoint: function _choosePoint(point, toolPoint) {
58488      return point ? point : toolPoint ? toolPoint.clone() : null;
58489    },
58490    getPoint: function getPoint() {
58491      return this._choosePoint(this._point, this.tool._point);
58492    },
58493    setPoint: function setPoint(point) {
58494      this._point = point;
58495    },
58496    getLastPoint: function getLastPoint() {
58497      return this._choosePoint(this._lastPoint, this.tool._lastPoint);
58498    },
58499    setLastPoint: function setLastPoint(lastPoint) {
58500      this._lastPoint = lastPoint;
58501    },
58502    getDownPoint: function getDownPoint() {
58503      return this._choosePoint(this._downPoint, this.tool._downPoint);
58504    },
58505    setDownPoint: function setDownPoint(downPoint) {
58506      this._downPoint = downPoint;
58507    },
58508    getMiddlePoint: function getMiddlePoint() {
58509      if (!this._middlePoint && this.tool._lastPoint) {
58510        return this.tool._point.add(this.tool._lastPoint).divide(2);
58511      }
58512
58513      return this._middlePoint;
58514    },
58515    setMiddlePoint: function setMiddlePoint(middlePoint) {
58516      this._middlePoint = middlePoint;
58517    },
58518    getDelta: function getDelta() {
58519      return !this._delta && this.tool._lastPoint ? this.tool._point.subtract(this.tool._lastPoint) : this._delta;
58520    },
58521    setDelta: function setDelta(delta) {
58522      this._delta = delta;
58523    },
58524    getCount: function getCount() {
58525      return this.tool[/^mouse(down|up)$/.test(this.type) ? '_downCount' : '_moveCount'];
58526    },
58527    setCount: function setCount(count) {
58528      this.tool[/^mouse(down|up)$/.test(this.type) ? 'downCount' : 'count'] = count;
58529    },
58530    getItem: function getItem() {
58531      if (!this._item) {
58532        var result = this.tool._scope.project.hitTest(this.getPoint());
58533
58534        if (result) {
58535          var item = result.item,
58536              parent = item._parent;
58537
58538          while (/^(Group|CompoundPath)$/.test(parent._class)) {
58539            item = parent;
58540            parent = parent._parent;
58541          }
58542
58543          this._item = item;
58544        }
58545      }
58546
58547      return this._item;
58548    },
58549    setItem: function setItem(item) {
58550      this._item = item;
58551    },
58552    toString: function toString() {
58553      return '{ type: ' + this.type + ', point: ' + this.getPoint() + ', count: ' + this.getCount() + ', modifiers: ' + this.getModifiers() + ' }';
58554    }
58555  });
58556  var Tool = PaperScopeItem.extend({
58557    _class: 'Tool',
58558    _list: 'tools',
58559    _reference: 'tool',
58560    _events: ['onMouseDown', 'onMouseUp', 'onMouseDrag', 'onMouseMove', 'onActivate', 'onDeactivate', 'onEditOptions', 'onKeyDown', 'onKeyUp'],
58561    initialize: function Tool(props) {
58562      PaperScopeItem.call(this);
58563      this._moveCount = -1;
58564      this._downCount = -1;
58565      this.set(props);
58566    },
58567    getMinDistance: function getMinDistance() {
58568      return this._minDistance;
58569    },
58570    setMinDistance: function setMinDistance(minDistance) {
58571      this._minDistance = minDistance;
58572
58573      if (minDistance != null && this._maxDistance != null && minDistance > this._maxDistance) {
58574        this._maxDistance = minDistance;
58575      }
58576    },
58577    getMaxDistance: function getMaxDistance() {
58578      return this._maxDistance;
58579    },
58580    setMaxDistance: function setMaxDistance(maxDistance) {
58581      this._maxDistance = maxDistance;
58582
58583      if (this._minDistance != null && maxDistance != null && maxDistance < this._minDistance) {
58584        this._minDistance = maxDistance;
58585      }
58586    },
58587    getFixedDistance: function getFixedDistance() {
58588      return this._minDistance == this._maxDistance ? this._minDistance : null;
58589    },
58590    setFixedDistance: function setFixedDistance(distance) {
58591      this._minDistance = this._maxDistance = distance;
58592    },
58593    _handleMouseEvent: function _handleMouseEvent(type, event, point, mouse) {
58594      paper = this._scope;
58595      if (mouse.drag && !this.responds(type)) type = 'mousemove';
58596      var move = mouse.move || mouse.drag,
58597          responds = this.responds(type),
58598          minDistance = this.minDistance,
58599          maxDistance = this.maxDistance,
58600          called = false,
58601          tool = this;
58602
58603      function update(minDistance, maxDistance) {
58604        var pt = point,
58605            toolPoint = move ? tool._point : tool._downPoint || pt;
58606
58607        if (move) {
58608          if (tool._moveCount >= 0 && pt.equals(toolPoint)) {
58609            return false;
58610          }
58611
58612          if (toolPoint && (minDistance != null || maxDistance != null)) {
58613            var vector = pt.subtract(toolPoint),
58614                distance = vector.getLength();
58615            if (distance < (minDistance || 0)) return false;
58616
58617            if (maxDistance) {
58618              pt = toolPoint.add(vector.normalize(Math.min(distance, maxDistance)));
58619            }
58620          }
58621
58622          tool._moveCount++;
58623        }
58624
58625        tool._point = pt;
58626        tool._lastPoint = toolPoint || pt;
58627
58628        if (mouse.down) {
58629          tool._moveCount = -1;
58630          tool._downPoint = pt;
58631          tool._downCount++;
58632        }
58633
58634        return true;
58635      }
58636
58637      function emit() {
58638        if (responds) {
58639          called = tool.emit(type, new ToolEvent(tool, type, event)) || c
58639alled;
58640        }
58641      }
58642
58643      if (mouse.down) {
58644        update();
58645        emit();
58646      } else if (mouse.up) {
58647        update(null, maxDistance);
58648        emit();
58649      } else if (responds) {
58650        while (update(minDistance, maxDistance)) {
58651          emit();
58652        }
58653      }
58654
58655      return called;
58656    }
58657  });
58658  var Tween = Base.extend(Emitter, {
58659    _class: 'Tween',
58660    statics: {
58661      easings: {
58662        linear: function linear(t) {
58663          return t;
58664        },
58665        easeInQuad: function easeInQuad(t) {
58666          return t * t;
58667        },
58668        easeOutQuad: function easeOutQuad(t) {
58669          return t * (2 - t);
58670        },
58671        easeInOutQuad: function easeInOutQuad(t) {
58672          return t < 0.5 ? 2 * t * t : -1 + 2 * (2 - t) * t;
58673        },
58674        easeInCubic: function easeInCubic(t) {
58675          return t * t * t;
58676        },
58677        easeOutCubic: function easeOutCubic(t) {
58678          return --t * t * t + 1;
58679        },
58680        easeInOutCubic: function easeInOutCubic(t) {
58681          return t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1;
58682        },
58683        easeInQuart: function easeInQuart(t) {
58684          return t * t * t * t;
58685        },
58686        easeOutQuart: function easeOutQuart(t) {
58687          return 1 - --t * t * t * t;
58688        },
58689        easeInOutQuart: function easeInOutQuart(t) {
58690          return t < 0.5 ? 8 * t * t * t * t : 1 - 8 * --t * t * t * t;
58691        },
58692        easeInQuint: function easeInQuint(t) {
58693          return t * t * t * t * t;
58694        },
58695        easeOutQuint: function easeOutQuint(t) {
58696          return 1 + --t * t * t * t * t;
58697        },
58698        easeInOutQuint: function easeInOutQuint(t) {
58699          return t < 0.5 ? 16 * t * t * t * t * t : 1 + 16 * --t * t * t * t * t;
58700        }
58701      }
58702    },
58703    initialize: function Tween(object, from, to, duration, easing, start) {
58704      this.object = object;
58705
58706      var type = _typeof(easing);
58707
58708      var isFunction = type === 'function';
58709      this.type = isFunction ? type : type === 'string' ? easing : 'linear';
58710      this.easing = isFunction ? easing : Tween.easings[this.type];
58711      this.duration = duration;
58712      this.running = false;
58713      this._then = null;
58714      this._startTime = null;
58715      var state = from || to;
58716      this._keys = state ? Object.keys(state) : [];
58717      this._parsedKeys = this._parseKeys(this._keys);
58718      this._from = state && this._getState(from);
58719      this._to = state && this._getState(to);
58720
58721      if (start !== false) {
58722        this.start();
58723      }
58724    },
58725    then: function then(_then) {
58726      this._then = _then;
58727      return this;
58728    },
58729    start: function start() {
58730      this._startTime = null;
58731      this.running = true;
58732      return this;
58733    },
58734    stop: function stop() {
58735      this.running = false;
58736      return this;
58737    },
58738    update: function update(progress) {
58739      if (this.running) {
58740        if (progress > 1) {
58741          progress = 1;
58742          this.running = false;
58743        }
58744
58745        var factor = this.easing(progress),
58746            keys = this._keys,
58747            getValue = function getValue(value) {
58748          return typeof value === 'function' ? value(factor, progress) : value;
58749        };
58750
58751        for (var i = 0, l = keys && keys.length; i < l; i++) {
58752          var key = keys[i],
58753              from = getValue(this._from[key]),
58754              to = getValue(this._to[key]),
58755              value = from && to && from.__add && to.__add ? to.__subtract(from).__multiply(factor).__add(from) : (to - from) * factor + from;
58756
58757          this._setProperty(this._parsedKeys[key], value);
58758        }
58759
58760        if (!this.running && this._then) {
58761          this._then(this.object);
58762        }
58763
58764        if (this.responds('update')) {
58765          this.emit('update', new Base({
58766            progress: progress,
58767            factor: factor
58768          }));
58769        }
58770      }
58771
58772      return this;
58773    },
58774    _events: {
58775      onUpdate: {}
58776    },
58777    _handleFrame: function _handleFrame(time) {
58778      var startTime = this._startTime,
58779          progress = startTime ? (time - startTime) / this.duration : 0;
58780
58781      if (!startTime) {
58782        this._startTime = time;
58783      }
58784
58785      this.update(progress);
58786    },
58787    _getState: function _getState(state) {
58788      var keys = this._keys,
58789          result = {};
58790
58791      for (var i = 0, l = keys.length; i < l; i++) {
58792        var key = keys[i],
58793            path = this._parsedKeys[key],
58794            current = this._getProperty(path),
58795            value;
58796
58797        if (state) {
58798          var resolved = this._resolveValue(current, state[key]);
58799
58800          this._setProperty(path, resolved);
58801
58802          value = this._getProperty(path);
58803          value = value && value.clone ? value.clone() : value;
58804
58805          this._setProperty(path, current);
58806        } else {
58807          value = current && current.clone ? current.clone() : current;
58808        }
58809
58810        result[key] = value;
58811      }
58812
58813      return result;
58814    },
58815    _resolveValue: function _resolveValue(current, value) {
58816      if (value) {
58817        if (Array.isArray(value) && value.length === 2) {
58818          var operator = value[0];
58819          return operator && operator.match && operator.match(/^[+\-\*\/]=/) ? this._calculate(current, operator[0], value[1]) : value;
58820        } else if (typeof value === 'string') {
58821          var match = value.match(/^[+\-*/]=(.*)/);
58822
58823          if (match) {
58824            var parsed = JSON.parse(match[1].replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g, '"$2": '));
58825            return this._calculate(current, value[0], parsed);
58826          }
58827        }
58828      }
58829
58830      return value;
58831    },
58832    _calculate: function _calculate(left, operator, right) {
58833      return paper.PaperScript.calculateBinary(left, operator, right);
58834    },
58835    _parseKeys: function _parseKeys(keys) {
58836      var parsed = {};
58837
58838      for (var i = 0, l = keys.length; i < l; i++) {
58839        var key = keys[i],
58840            path = key.replace(/\.([^.]*)/g, '/$1').replace(/\[['"]?([^'"\]]*)['"]?\]/g, '/$1');
58841        parsed[key] = path.split('/');
58842      }
58843
58844      return parsed;
58845    },
58846    _getProperty: function _getProperty(path, offset) {
58847      var obj = this.object;
58848
58849      for (var i = 0, l = path.length - (offset || 0); i < l && obj; i++) {
58850        obj = obj[path[i]];
58851      }
58852
58853      return obj;
58854    },
58855    _setProperty: function _setProperty(path, value) {
58856      var dest = this._getProperty(path, 1);
58857
58858      if (dest) {
58859        dest[path[path.length - 1]] = value;
58860      }
58861    }
58862  });
58863  var Http = {
58864    request: function request(options) {
58865      var xhr = new self.XMLHttpRequest();
58866      xhr.open((options.method || 'get').toUpperCase(), options.url, Base.pick(options.async, true));
58867      if (options.mimeType) xhr.overrideMimeType(options.mimeType);
58868
58869      xhr.onload = function () {
58870        var status = xhr.status;
58871
58872        if (status === 0 || status === 200) {
58873          if (options.onLoad) {
58874            options.onLoad.call(xhr, xhr.responseText);
58875          }
58876        } else {
58877          xhr.onerror();
58878        }
58879      };
58880
58881      xhr.onerror = function () {
58882        var status = xhr.status,
58883            message = 'Could not load "' + options.url + '" (Status: ' + status + ')';
58884
58885        if (options.onError) {
58886          options.onError(message, status);
58887        } else {
58888          throw new Error(message);
58889        }
58890      };
58891
58892      return xhr.send(null);
58893    }
58894  };
58895  var CanvasProvider = {
58896    canvases: [],
58897    getCanvas: function getCanvas(width, height) {
58898      if (!window) return null;
58899      var canvas,
58900          clear = true;
58901
58902      if (_typeof(width) === 'object') {
58903        height = width.height;
58904        width = width.width;
58905      }
58906
58907      if (this.canvases.length) {
58908        canvas = this.canvases.pop();
58909      } else {
58910        canvas = document.createElement('canvas');
58911        clear = false;
58912      }
58913
58914      var ctx = canvas.getContext('2d');
58915
58916      if (!ctx) {
58917        throw new Error('Canvas ' + canvas + ' is unable to provide a 2D context.');
58918      }
58919
58920      if (canvas.width === width && canvas.height === height) {
58921        if (clear) ctx.clearRect(0, 0, width + 1, height + 1);
58922      } else {
58923        canvas.width = width;
58924        canvas.height = height;
58925      }
58926
58927      ctx.save();
58928      return canvas;
58929    },
58930    getContext: function getContext(width, height) {
58931      var canvas = this.getCanvas(width, height);
58932      return canvas ? canvas.getContext('2d') : null;
58933    },
58934    release: function release(obj) {
58935      var canvas = obj && obj.canvas ? obj.canvas : obj;
58936
58937      if (canvas && canvas.getContext) {
58938        canvas.getContext('2d').restore();
58939        this.canvases.push(canvas);
58940      }
58941    }
58942  };
58943  var BlendMode = new function () {
58944    var min = Math.min,
58945        max = Math.max,
58946        abs = Math.abs,
58947        sr,
58948        sg,
58949        sb,
58950        sa,
58951        br,
58952        bg,
58953        bb,
58954        ba,
58955        dr,
58956        dg,
58957        db;
58958
58959    function getLum(r, g, b) {
58960      return 0.2989 * r + 0.587 * g + 0.114 * b;
58961    }
58962
58963    function setLum(r, g, b, l) {
58964      var d = l - getLum(r, g, b);
58965      dr = r + d;
58966      dg = g + d;
58967      db = b + d;
58968      var l = getLum(dr, dg, db),
58969          mn = min(dr, dg, db),
58970          mx = max(dr, dg, db);
58971
58972      if (mn < 0) {
58973        var lmn = l - mn;
58974        dr = l + (dr - l) * l / lmn;
58975        dg = l + (dg - l) * l / lmn;
58976        db = l + (db - l) * l / lmn;
58977      }
58978
58979      if (mx > 255) {
58980        var ln = 255 - l,
58981            mxl = mx - l;
58982        dr = l + (dr - l) * ln / mxl;
58983        dg = l + (dg - l) * ln / mxl;
58984        db = l + (db - l) * ln / mxl;
58985      }
58986    }
58987
58988    function getSat(r, g, b) {
58989      return max(r, g, b) - min(r, g, b);
58990    }
58991
58992    function setSat(r, g, b, s) {
58993      var col = [r, g, b],
58994          mx = max(r, g, b),
58995          mn = min(r, g, b),
58996          md;
58997      mn = mn === r ? 0 : mn === g ? 1 : 2;
58998      mx = mx === r ? 0 : mx === g ? 1 : 2;
58999      md = min(mn, mx) === 0 ? max(mn, mx) === 1 ? 2 : 1 : 0;
59000
59001      if (col[mx] > col[mn]) {
59002        col[md] = (col[md] - col[mn]) * s / (col[mx] - col[mn]);
59003        col[mx] = s;
59004      } else {
59005        col[md] = col[mx] = 0;
59006      }
59007
59008      col[mn] = 0;
59009      dr = col[0];
59010      dg = col[1];
59011      db = col[2];
59012    }
59013
59014    var modes = {
59015      multiply: function multiply() {
59016        dr = br * sr / 255;
59017        dg = bg * sg / 255;
59018        db = bb * sb / 255;
59019      },
59020      screen: function screen() {
59021        dr = br + sr - br * sr / 255;
59022        dg = bg + sg - bg * sg / 255;
59023        db = bb + sb - bb * sb / 255;
59024      },
59025      overlay: function overlay() {
59026        dr = br < 128 ? 2 * br * sr / 255 : 255 - 2 * (255 - br) * (255 - sr) / 255;
59027        dg = bg < 128 ? 2 * bg * sg / 255 : 255 - 2 * (255 - bg) * (255 - sg) / 255;
59028        db = bb < 128 ? 2 * bb * sb / 255 : 255 - 2 * (255 - bb) * (255 - sb) / 255;
59029      },
59030      'soft-light': function softLight() {
59031        var t = sr * br / 255;
59032        dr = t + br * (255 - (255 - br) * (255 - sr) / 255 - t) / 255;
59033        t = sg * bg / 255;
59034        dg = t + bg * (255 - (255 - bg) * (255 - sg) / 255 - t) / 255;
59035        t = sb * bb / 255;
59036        db = t + bb * (255 - (255 - bb) * (255 - sb) / 255 - t) / 255;
59037      },
59038      'hard-light': function hardLight() {
59039        dr = sr < 128 ? 2 * sr * br / 255 : 255 - 2 * (255 - sr) * (255 - br) / 255;
59040        dg = sg < 128 ? 2 * sg * bg / 255 : 255 - 2 * (255 - sg) * (255 - bg) / 255;
59041        db = sb < 128 ? 2 * sb * bb / 255 : 255 - 2 * (255 - sb) * (255 - bb) / 255;
59042      },
59043      'color-dodge': function colorDodge() {
59044        dr = br === 0 ? 0 : sr === 255 ? 255 : min(255, 255 * br / (255 - sr));
59045        dg = bg === 0 ? 0 : sg === 255 ? 255 : min(255, 255 * bg / (255 - sg));
59046        db = bb === 0 ? 0 : sb === 255 ? 255 : min(255, 255 * bb / (255 - sb));
59047      },
59048      'color-burn': function colorBurn() {
59049        dr = br === 255 ? 255 : sr === 0 ? 0 : max(0, 255 - (255 - br) * 255 / sr);
59050        dg = bg === 255 ? 255 : sg === 0 ? 0 : max(0, 255 - (255 - bg) * 255 / sg);
59051        db = bb === 255 ? 255 : sb === 0 ? 0 : max(0, 255 - (255 - bb) * 255 / sb);
59052      },
59053      darken: function darken() {
59054        dr = br < sr ? br : sr;
59055        dg = bg < sg ? bg : sg;
59056        db = bb < sb ? bb : sb;
59057      },
59058      lighten: function lighten() {
59059        dr = br > sr ? br : sr;
59060        dg = bg > sg ? bg : sg;
59061        db = bb > sb ? bb : sb;
59062      },
59063      difference: function difference() {
59064        dr = br - sr;
59065        if (dr < 0) dr = -dr;
59066        dg = bg - sg;
59067        if (dg < 0) dg = -dg;
59068        db = bb - sb;
59069        if (db < 0) db = -db;
59070      },
59071      exclusion: function exclusion() {
59072        dr = br + sr * (255 - br - br) / 255;
59073        dg = bg + sg * (255 - bg - bg) / 255;
59074        db = bb + sb * (255 - bb - bb) / 255;
59075      },
59076      hue: function hue() {
59077        setSat(sr, sg, sb, getSat(br, bg, bb));
59078        setLum(dr, dg, db, getLum(br, bg, bb));
59079      },
59080      saturation: function saturation() {
59081        setSat(br, bg, bb, getSat(sr, sg, sb));
59082        setLum(dr, dg, db, getLum(br, bg, bb));
59083      },
59084      luminosity: function luminosity() {
59085        setLum(br, bg, bb, getLum(sr, sg, sb));
59086      },
59087      color: function color() {
59088        setLum(sr, sg, sb, getLum(br, bg, bb));
59089      },
59090      add: function add() {
59091        dr = min(br + sr, 255);
59092        dg = min(bg + sg, 255);
59093        db = min(bb + sb, 255);
59094      },
59095      subtract: function subtract() {
59096        dr = max(br - sr, 0);
59097        dg = max(bg - sg, 0);
59098        db = max(bb - sb, 0);
59099      },
59100      average: function average() {
59101        dr = (br + sr) / 2;
59102        dg = (bg + sg) / 2;
59103        db = (bb + sb) / 2;
59104      },
59105      negation: function negation() {
59106        dr = 255 - abs(255 - sr - br);
59107        dg = 255 - abs(255 - sg - bg);
59108        db = 255 - abs(255 - sb - bb);
59109      }
59110    };
59111    var nativeModes = this.nativeModes = Base.each(['source-over', 'source-in', 's
vendor: 9,502 bytes, lines 59111-59422
59111ource-out', 'source-atop', 'destination-over', 'destination-in', 'destination-out', 'destination-atop', 'lighter', 'darker', 'copy', 'xor'], function (mode) {
59112      this[mode] = true;
59113    }, {});
59114    var ctx = CanvasProvider.getContext(1, 1);
59115
59116    if (ctx) {
59117      Base.each(modes, function (func, mode) {
59118        var darken = mode === 'darken',
59119            ok = false;
59120        ctx.save();
59121
59122        try {
59123          ctx.fillStyle = darken ? '#300' : '#a00';
59124          ctx.fillRect(0, 0, 1, 1);
59125          ctx.globalCompositeOperation = mode;
59126
59127          if (ctx.globalCompositeOperation === mode) {
59128            ctx.fillStyle = darken ? '#a00' : '#300';
59129            ctx.fillRect(0, 0, 1, 1);
59130            ok = ctx.getImageData(0, 0, 1, 1).data[0] !== darken ? 170 : 51;
59131          }
59132        } catch (e) {}
59133
59134        ctx.restore();
59135        nativeModes[mode] = ok;
59136      });
59137      CanvasProvider.release(ctx);
59138    }
59139
59140    this.process = function (mode, srcContext, dstContext, alpha, offset) {
59141      var srcCanvas = srcContext.canvas,
59142          normal = mode === 'normal';
59143
59144      if (normal || nativeModes[mode]) {
59145        dstContext.save();
59146        dstContext.setTransform(1, 0, 0, 1, 0, 0);
59147        dstContext.globalAlpha = alpha;
59148        if (!normal) dstContext.globalCompositeOperation = mode;
59149        dstContext.drawImage(srcCanvas, offset.x, offset.y);
59150        dstContext.restore();
59151      } else {
59152        var process = modes[mode];
59153        if (!process) return;
59154        var dstData = dstContext.getImageData(offset.x, offset.y, srcCanvas.width, srcCanvas.height),
59155            dst = dstData.data,
59156            src = srcContext.getImageData(0, 0, srcCanvas.width, srcCanvas.height).data;
59157
59158        for (var i = 0, l = dst.length; i < l; i += 4) {
59159          sr = src[i];
59160          br = dst[i];
59161          sg = src[i + 1];
59162          bg = dst[i + 1];
59163          sb = src[i + 2];
59164          bb = dst[i + 2];
59165          sa = src[i + 3];
59166          ba = dst[i + 3];
59167          process();
59168          var a1 = sa * alpha / 255,
59169              a2 = 1 - a1;
59170          dst[i] = a1 * dr + a2 * br;
59171          dst[i + 1] = a1 * dg + a2 * bg;
59172          dst[i + 2] = a1 * db + a2 * bb;
59173          dst[i + 3] = sa * alpha + a2 * ba;
59174        }
59175
59176        dstContext.putImageData(dstData, offset.x, offset.y);
59177      }
59178    };
59179  }();
59180  var SvgElement = new function () {
59181    var svg = 'http://www.w3.org/2000/svg',
59182        xmlns = 'http://www.w3.org/2000/xmlns',
59183        xlink = 'http://www.w3.org/1999/xlink',
59184        attributeNamespace = {
59185      href: xlink,
59186      xlink: xmlns,
59187      xmlns: xmlns + '/',
59188      'xmlns:xlink': xmlns + '/'
59189    };
59190
59191    function create(tag, attributes, formatter) {
59192      return set(document.createElementNS(svg, tag), attributes, formatter);
59193    }
59194
59195    function get(node, name) {
59196      var namespace = attributeNamespace[name],
59197          value = namespace ? node.getAttributeNS(namespace, name) : node.getAttribute(name);
59198      return value === 'null' ? null : value;
59199    }
59200
59201    function set(node, attributes, formatter) {
59202      for (var name in attributes) {
59203        var value = attributes[name],
59204            namespace = attributeNamespace[name];
59205        if (typeof value === 'number' && formatter) value = formatter.number(value);
59206
59207        if (namespace) {
59208          node.setAttributeNS(namespace, name, value);
59209        } else {
59210          node.setAttribute(name, value);
59211        }
59212      }
59213
59214      return node;
59215    }
59216
59217    return {
59218      svg: svg,
59219      xmlns: xmlns,
59220      xlink: xlink,
59221      create: create,
59222      get: get,
59223      set: set
59224    };
59225  }();
59226  var SvgStyles = Base.each({
59227    fillColor: ['fill', 'color'],
59228    fillRule: ['fill-rule', 'string'],
59229    strokeColor: ['stroke', 'color'],
59230    strokeWidth: ['stroke-width', 'number'],
59231    strokeCap: ['stroke-linecap', 'string'],
59232    strokeJoin: ['stroke-linejoin', 'string'],
59233    strokeScaling: ['vector-effect', 'lookup', {
59234      true: 'none',
59235      false: 'non-scaling-stroke'
59236    }, function (item, value) {
59237      return !value && (item instanceof PathItem || item instanceof Shape || item instanceof TextItem);
59238    }],
59239    miterLimit: ['stroke-miterlimit', 'number'],
59240    dashArray: ['stroke-dasharray', 'array'],
59241    dashOffset: ['stroke-dashoffset', 'number'],
59242    fontFamily: ['font-family', 'string'],
59243    fontWeight: ['font-weight', 'string'],
59244    fontSize: ['font-size', 'number'],
59245    justification: ['text-anchor', 'lookup', {
59246      left: 'start',
59247      center: 'middle',
59248      right: 'end'
59249    }],
59250    opacity: ['opacity', 'number'],
59251    blendMode: ['mix-blend-mode', 'style']
59252  }, function (entry, key) {
59253    var part = Base.capitalize(key),
59254        lookup = entry[2];
59255    this[key] = {
59256      type: entry[1],
59257      property: key,
59258      attribute: entry[0],
59259      toSVG: lookup,
59260      fromSVG: lookup && Base.each(lookup, function (value, name) {
59261        this[value] = name;
59262      }, {}),
59263      exportFilter: entry[3],
59264      get: 'get' + part,
59265      set: 'set' + part
59266    };
59267  }, {});
59268  new function () {
59269    var formatter;
59270
59271    function getTransform(matrix, coordinates, center) {
59272      var attrs = new Base(),
59273          trans = matrix.getTranslation();
59274
59275      if (coordinates) {
59276        var point;
59277
59278        if (matrix.isInvertible()) {
59279          matrix = matrix._shiftless();
59280          point = matrix._inverseTransform(trans);
59281          trans = null;
59282        } else {
59283          point = new Point();
59284        }
59285
59286        attrs[center ? 'cx' : 'x'] = point.x;
59287        attrs[center ? 'cy' : 'y'] = point.y;
59288      }
59289
59290      if (!matrix.isIdentity()) {
59291        var decomposed = matrix.decompose();
59292
59293        if (decomposed) {
59294          var parts = [],
59295              angle = decomposed.rotation,
59296              scale = decomposed.scaling,
59297              skew = decomposed.skewing;
59298          if (trans && !trans.isZero()) parts.push('translate(' + formatter.point(trans) + ')');
59299          if (angle) parts.push('rotate(' + formatter.number(angle) + ')');
59300          if (!Numerical.isZero(scale.x - 1) || !Numerical.isZero(scale.y - 1)) parts.push('scale(' + formatter.point(scale) + ')');
59301          if (skew.x) parts.push('skewX(' + formatter.number(skew.x) + ')');
59302          if (skew.y) parts.push('skewY(' + formatter.number(skew.y) + ')');
59303          attrs.transform = parts.join(' ');
59304        } else {
59305          attrs.transform = 'matrix(' + matrix.getValues().join(',') + ')';
59306        }
59307      }
59308
59309      return attrs;
59310    }
59311
59312    function exportGroup(item, options) {
59313      var attrs = getTransform(item._matrix),
59314          children = item._children;
59315      var node = SvgElement.create('g', attrs, formatter);
59316
59317      for (var i = 0, l = children.length; i < l; i++) {
59318        var child = children[i];
59319
59320        var childNode = _exportSVG(child, options);
59321
59322        if (childNode) {
59323          if (child.isClipMask()) {
59324            var clip = SvgElement.create('clipPath');
59325            clip.appendChild(childNode);
59326            setDefinition(child, clip, 'clip');
59327            SvgElement.set(node, {
59328              'clip-path': 'url(#' + clip.id + ')'
59329            });
59330          } else {
59331            node.appendChild(childNode);
59332          }
59333        }
59334      }
59335
59336      return node;
59337    }
59338
59339    function exportRaster(item, options) {
59340      var attrs = getTransform(item._matrix, true),
59341          size = item.getSize(),
59342          image = item.getImage();
59343      attrs.x -= size.width / 2;
59344      attrs.y -= size.height / 2;
59345      attrs.width = size.width;
59346      attrs.height = size.height;
59347      attrs.href = options.embedImages == false && image && image.src || item.toDataURL();
59348      return SvgElement.create('image', attrs, formatter);
59349    }
59350
59351    function exportPath(item, options) {
59352      var matchShapes = options.matchShapes;
59353
59354      if (matchShapes) {
59355        var shape = item.toShape(false);
59356        if (shape) return exportShape(shape, options);
59357      }
59358
59359      var segments = item._segments,
59360          length = segments.length,
59361          type,
59362          attrs = getTransform(item._matrix);
59363
59364      if (matchShapes && length >= 2 && !item.hasHandles()) {
59365        if (length > 2) {
59366          type = item._closed ? 'polygon' : 'polyline';
59367          var parts = [];
59368
59369          for (var i = 0; i < length; i++) {
59370            parts.push(formatter.point(segments[i]._point));
59371          }
59372
59373          attrs.points = parts.join(' ');
59374        } else {
59375          type = 'line';
59376          var start = segments[0]._point,
59377              end = segments[1]._point;
59378          attrs.set({
59379            x1: start.x,
59380            y1: start.y,
59381            x2: end.x,
59382            y2: end.y
59383          });
59384        }
59385      } else {
59386        type = 'path';
59387        attrs.d = item.getPathData(null, options.precision);
59388      }
59389
59390      return SvgElement.create(type, attrs, formatter);
59391    }
59392
59393    function exportShape(item) {
59394      var type = item._type,
59395          radius = item._radius,
59396          attrs = getTransform(item._matrix, true, type !== 'rectangle');
59397
59398      if (type === 'rectangle') {
59399        type = 'rect';
59400        var size = item._size,
59401            width = size.width,
59402            height = size.height;
59403        attrs.x -= width / 2;
59404        attrs.y -= height / 2;
59405        attrs.width = width;
59406        attrs.height = height;
59407        if (radius.isZero()) radius = null;
59408      }
59409
59410      if (radius) {
59411        if (type === 'circle') {
59412          attrs.r = radius;
59413        } else {
59414          attrs.rx = radius.width;
59415          attrs.ry = radius.height;
59416        }
59417      }
59418
59419      return SvgElement.create(type, attrs, formatter);
59420    }
59421
59422    function exportCompoundPath(item, options) {
vendor: 17,476 bytes, lines 59423-59947
59423      var attrs = getTransform(item._matrix);
59424      var data = item.getPathData(null, options.precision);
59425      if (data) attrs.d = data;
59426      return SvgElement.create('path', attrs, formatter);
59427    }
59428
59429    function exportSymbolItem(item, options) {
59430      var attrs = getTransform(item._matrix, true),
59431          definition = item._definition,
59432          node = getDefinition(definition, 'symbol'),
59433          definitionItem = definition._item,
59434          bounds = definitionItem.getStrokeBounds();
59435
59436      if (!node) {
59437        node = SvgElement.create('symbol', {
59438          viewBox: formatter.rectangle(bounds)
59439        });
59440        node.appendChild(_exportSVG(definitionItem, options));
59441        setDefinition(definition, node, 'symbol');
59442      }
59443
59444      attrs.href = '#' + node.id;
59445      attrs.x += bounds.x;
59446      attrs.y += bounds.y;
59447      attrs.width = bounds.width;
59448      attrs.height = bounds.height;
59449      attrs.overflow = 'visible';
59450      return SvgElement.create('use', attrs, formatter);
59451    }
59452
59453    function exportGradient(color) {
59454      var gradientNode = getDefinition(color, 'color');
59455
59456      if (!gradientNode) {
59457        var gradient = color.getGradient(),
59458            radial = gradient._radial,
59459            origin = color.getOrigin(),
59460            destination = color.getDestination(),
59461            attrs;
59462
59463        if (radial) {
59464          attrs = {
59465            cx: origin.x,
59466            cy: origin.y,
59467            r: origin.getDistance(destination)
59468          };
59469          var highlight = color.getHighlight();
59470
59471          if (highlight) {
59472            attrs.fx = highlight.x;
59473            attrs.fy = highlight.y;
59474          }
59475        } else {
59476          attrs = {
59477            x1: origin.x,
59478            y1: origin.y,
59479            x2: destination.x,
59480            y2: destination.y
59481          };
59482        }
59483
59484        attrs.gradientUnits = 'userSpaceOnUse';
59485        gradientNode = SvgElement.create((radial ? 'radial' : 'linear') + 'Gradient', attrs, formatter);
59486        var stops = gradient._stops;
59487
59488        for (var i = 0, l = stops.length; i < l; i++) {
59489          var stop = stops[i],
59490              stopColor = stop._color,
59491              alpha = stopColor.getAlpha(),
59492              offset = stop._offset;
59493          attrs = {
59494            offset: offset == null ? i / (l - 1) : offset
59495          };
59496          if (stopColor) attrs['stop-color'] = stopColor.toCSS(true);
59497          if (alpha < 1) attrs['stop-opacity'] = alpha;
59498          gradientNode.appendChild(SvgElement.create('stop', attrs, formatter));
59499        }
59500
59501        setDefinition(color, gradientNode, 'color');
59502      }
59503
59504      return 'url(#' + gradientNode.id + ')';
59505    }
59506
59507    function exportText(item) {
59508      var node = SvgElement.create('text', getTransform(item._matrix, true), formatter);
59509      node.textContent = item._content;
59510      return node;
59511    }
59512
59513    var exporters = {
59514      Group: exportGroup,
59515      Layer: exportGroup,
59516      Raster: exportRaster,
59517      Path: exportPath,
59518      Shape: exportShape,
59519      CompoundPath: exportCompoundPath,
59520      SymbolItem: exportSymbolItem,
59521      PointText: exportText
59522    };
59523
59524    function applyStyle(item, node, isRoot) {
59525      var attrs = {},
59526          parent = !isRoot && item.getParent(),
59527          style = [];
59528      if (item._name != null) attrs.id = item._name;
59529      Base.each(SvgStyles, function (entry) {
59530        var get = entry.get,
59531            type = entry.type,
59532            value = item[get]();
59533
59534        if (entry.exportFilter ? entry.exportFilter(item, value) : !parent || !Base.equals(parent[get](), value)) {
59535          if (type === 'color' && value != null) {
59536            var alpha = value.getAlpha();
59537            if (alpha < 1) attrs[entry.attribute + '-opacity'] = alpha;
59538          }
59539
59540          if (type === 'style') {
59541            style.push(entry.attribute + ': ' + value);
59542          } else {
59543            attrs[entry.attribute] = value == null ? 'none' : type === 'color' ? value.gradient ? exportGradient(value, item) : value.toCSS(true) : type === 'array' ? value.join(',') : type === 'lookup' ? entry.toSVG[value] : value;
59544          }
59545        }
59546      });
59547      if (style.length) attrs.style = style.join(';');
59548      if (attrs.opacity === 1) delete attrs.opacity;
59549      if (!item._visible) attrs.visibility = 'hidden';
59550      return SvgElement.set(node, attrs, formatter);
59551    }
59552
59553    var definitions;
59554
59555    function getDefinition(item, type) {
59556      if (!definitions) definitions = {
59557        ids: {},
59558        svgs: {}
59559      };
59560      return item && definitions.svgs[type + '-' + (item._id || item.__id || (item.__id = UID.get('svg')))];
59561    }
59562
59563    function setDefinition(item, node, type) {
59564      if (!definitions) getDefinition();
59565      var typeId = definitions.ids[type] = (definitions.ids[type] || 0) + 1;
59566      node.id = type + '-' + typeId;
59567      definitions.svgs[type + '-' + (item._id || item.__id)] = node;
59568    }
59569
59570    function exportDefinitions(node, options) {
59571      var svg = node,
59572          defs = null;
59573
59574      if (definitions) {
59575        svg = node.nodeName.toLowerCase() === 'svg' && node;
59576
59577        for (var i in definitions.svgs) {
59578          if (!defs) {
59579            if (!svg) {
59580              svg = SvgElement.create('svg');
59581              svg.appendChild(node);
59582            }
59583
59584            defs = svg.insertBefore(SvgElement.create('defs'), svg.firstChild);
59585          }
59586
59587          defs.appendChild(definitions.svgs[i]);
59588        }
59589
59590        definitions = null;
59591      }
59592
59593      return options.asString ? new self.XMLSerializer().serializeToString(svg) : svg;
59594    }
59595
59596    function _exportSVG(item, options, isRoot) {
59597      var exporter = exporters[item._class],
59598          node = exporter && exporter(item, options);
59599
59600      if (node) {
59601        var onExport = options.onExport;
59602        if (onExport) node = onExport(item, node, options) || node;
59603        var data = JSON.stringify(item._data);
59604        if (data && data !== '{}' && data !== 'null') node.setAttribute('data-paper-data', data);
59605      }
59606
59607      return node && applyStyle(item, node, isRoot);
59608    }
59609
59610    function setOptions(options) {
59611      if (!options) options = {};
59612      formatter = new Formatter(options.precision);
59613      return options;
59614    }
59615
59616    Item.inject({
59617      exportSVG: function exportSVG(options) {
59618        options = setOptions(options);
59619        return exportDefinitions(_exportSVG(this, options, true), options);
59620      }
59621    });
59622    Project.inject({
59623      exportSVG: function exportSVG(options) {
59624        options = setOptions(options);
59625        var children = this._children,
59626            view = this.getView(),
59627            bounds = Base.pick(options.bounds, 'view'),
59628            mx = options.matrix || bounds === 'view' && view._matrix,
59629            matrix = mx && Matrix.read([mx]),
59630            rect = bounds === 'view' ? new _Rectangle([0, 0], view.getViewSize()) : bounds === 'content' ? Item._getBounds(children, matrix, {
59631          stroke: true
59632        }).rect : _Rectangle.read([bounds], 0, {
59633          readNull: true
59634        }),
59635            attrs = {
59636          version: '1.1',
59637          xmlns: SvgElement.svg,
59638          'xmlns:xlink': SvgElement.xlink
59639        };
59640
59641        if (rect) {
59642          attrs.width = rect.width;
59643          attrs.height = rect.height;
59644          if (rect.x || rect.x === 0 || rect.y || rect.y === 0) attrs.viewBox = formatter.rectangle(rect);
59645        }
59646
59647        var node = SvgElement.create('svg', attrs, formatter),
59648            parent = node;
59649
59650        if (matrix && !matrix.isIdentity()) {
59651          parent = node.appendChild(SvgElement.create('g', getTransform(matrix), formatter));
59652        }
59653
59654        for (var i = 0, l = children.length; i < l; i++) {
59655          parent.appendChild(_exportSVG(children[i], options, true));
59656        }
59657
59658        return exportDefinitions(node, options);
59659      }
59660    });
59661  }();
59662  new function () {
59663    var definitions = {},
59664        rootSize;
59665
59666    function getValue(node, name, isString, allowNull, allowPercent, defaultValue) {
59667      var value = SvgElement.get(node, name) || defaultValue,
59668          res = value == null ? allowNull ? null : isString ? '' : 0 : isString ? value : parseFloat(value);
59669      return /%\s*$/.test(value) ? res / 100 * (allowPercent ? 1 : rootSize[/x|^width/.test(name) ? 'width' : 'height']) : res;
59670    }
59671
59672    function getPoint(node, x, y, allowNull, allowPercent, defaultX, defaultY) {
59673      x = getValue(node, x || 'x', false, allowNull, allowPercent, defaultX);
59674      y = getValue(node, y || 'y', false, allowNull, allowPercent, defaultY);
59675      return allowNull && (x == null || y == null) ? null : new Point(x, y);
59676    }
59677
59678    function getSize(node, w, h, allowNull, allowPercent) {
59679      w = getValue(node, w || 'width', false, allowNull, allowPercent);
59680      h = getValue(node, h || 'height', false, allowNull, allowPercent);
59681      return allowNull && (w == null || h == null) ? null : new Size(w, h);
59682    }
59683
59684    function convertValue(value, type, lookup) {
59685      return value === 'none' ? null : type === 'number' ? parseFloat(value) : type === 'array' ? value ? value.split(/[\s,]+/g).map(parseFloat) : [] : type === 'color' ? getDefinition(value) || value : type === 'lookup' ? lookup[value] : value;
59686    }
59687
59688    function importGroup(node, type, options, isRoot) {
59689      var nodes = node.childNodes,
59690          isClip = type === 'clippath',
59691          isDefs = type === 'defs',
59692          item = new Group(),
59693          project = item._project,
59694          currentStyle = project._currentStyle,
59695          children = [];
59696
59697      if (!isClip && !isDefs) {
59698        item = applyAttributes(item, node, isRoot);
59699        project._currentStyle = item._style.clone();
59700      }
59701
59702      if (isRoot) {
59703        var defs = node.querySelectorAll('defs');
59704
59705        for (var i = 0, l = defs.length; i < l; i++) {
59706          importNode(defs[i], options, false);
59707        }
59708      }
59709
59710      for (var i = 0, l = nodes.length; i < l; i++) {
59711        var childNode = nodes[i],
59712            child;
59713        if (childNode.nodeType === 1 && !/^defs$/i.test(childNode.nodeName) && (child = importNode(childNode, options, false)) && !(child instanceof SymbolDefinition)) children.push(child);
59714      }
59715
59716      item.addChildren(children);
59717      if (isClip) item = applyAttributes(item.reduce(), node, isRoot);
59718      project._currentStyle = currentStyle;
59719
59720      if (isClip || isDefs) {
59721        item.remove();
59722        item = null;
59723      }
59724
59725      return item;
59726    }
59727
59728    function importPoly(node, type) {
59729      var coords = node.getAttribute('points').match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g),
59730          points = [];
59731
59732      for (var i = 0, l = coords.length; i < l; i += 2) {
59733        points.push(new Point(parseFloat(coords[i]), parseFloat(coords[i + 1])));
59734      }
59735
59736      var path = new Path(points);
59737      if (type === 'polygon') path.closePath();
59738      return path;
59739    }
59740
59741    function importPath(node) {
59742      return PathItem.create(node.getAttribute('d'));
59743    }
59744
59745    function importGradient(node, type) {
59746      var id = (getValue(node, 'href', true) || '').substring(1),
59747          radial = type === 'radialgradient',
59748          gradient;
59749
59750      if (id) {
59751        gradient = definitions[id].getGradient();
59752
59753        if (gradient._radial ^ radial) {
59754          gradient = gradient.clone();
59755          gradient._radial = radial;
59756        }
59757      } else {
59758        var nodes = node.childNodes,
59759            stops = [];
59760
59761        for (var i = 0, l = nodes.length; i < l; i++) {
59762          var child = nodes[i];
59763          if (child.nodeType === 1) stops.push(applyAttributes(new GradientStop(), child));
59764        }
59765
59766        gradient = new Gradient(stops, radial);
59767      }
59768
59769      var origin,
59770          destination,
59771          highlight,
59772          scaleToBounds = getValue(node, 'gradientUnits', true) !== 'userSpaceOnUse';
59773
59774      if (radial) {
59775        origin = getPoint(node, 'cx', 'cy', false, scaleToBounds, '50%', '50%');
59776        destination = origin.add(getValue(node, 'r', false, false, scaleToBounds, '50%'), 0);
59777        highlight = getPoint(node, 'fx', 'fy', true, scaleToBounds);
59778      } else {
59779        origin = getPoint(node, 'x1', 'y1', false, scaleToBounds, '0%', '0%');
59780        destination = getPoint(node, 'x2', 'y2', false, scaleToBounds, '100%', '0%');
59781      }
59782
59783      var color = applyAttributes(new Color(gradient, origin, destination, highlight), node);
59784      color._scaleToBounds = scaleToBounds;
59785      return null;
59786    }
59787
59788    var importers = {
59789      '#document': function document(node, type, options, isRoot) {
59790        var nodes = node.childNodes;
59791
59792        for (var i = 0, l = nodes.length; i < l; i++) {
59793          var child = nodes[i];
59794          if (child.nodeType === 1) return importNode(child, options, isRoot);
59795        }
59796      },
59797      g: importGroup,
59798      svg: importGroup,
59799      clippath: importGroup,
59800      polygon: importPoly,
59801      polyline: importPoly,
59802      path: importPath,
59803      lineargradient: importGradient,
59804      radialgradient: importGradient,
59805      image: function image(node) {
59806        var raster = new Raster(getValue(node, 'href', true));
59807        raster.on('load', function () {
59808          var size = getSize(node);
59809          this.setSize(size);
59810          var center = getPoint(node).add(size.divide(2));
59811
59812          this._matrix.append(new Matrix().translate(center));
59813        });
59814        return raster;
59815      },
59816      symbol: function symbol(node, type, options, isRoot) {
59817        return new SymbolDefinition(importGroup(node, type, options, isRoot), true);
59818      },
59819      defs: importGroup,
59820      use: function use(node) {
59821        var id = (getValue(node, 'href', true) || '').substring(1),
59822            definition = definitions[id],
59823            point = getPoint(node);
59824        return definition ? definition instanceof SymbolDefinition ? definition.place(point) : definition.clone().translate(point) : null;
59825      },
59826      circle: function circle(node) {
59827        return new Shape.Circle(getPoint(node, 'cx', 'cy'), getValue(node, 'r'));
59828      },
59829      ellipse: function ellipse(node) {
59830        return new Shape.Ellipse({
59831          center: getPoint(node, 'cx', 'cy'),
59832          radius: getSize(node, 'rx', 'ry')
59833        });
59834      },
59835      rect: function rect(node) {
59836        return new Shape.Rectangle(new _Rectangle(getPoint(node), getSize(node)), getSize(node, 'rx', 'ry'));
59837      },
59838      line: function line(node) {
59839        return new Path.Line(getPoint(node, 'x1', 'y1'), getPoint(node, 'x2', 'y2'));
59840      },
59841      text: function text(node) {
59842        var text = new PointText(getPoint(node).add(getPoint(node, 'dx', 'dy')));
59843        text.setContent(node.textContent.trim() || '');
59844        return text;
59845      },
59846      switch: importGroup
59847    };
59848
59849    function applyTransform(item, value, name, node) {
59850      if (item.transform) {
59851        var transforms = (node.getAttribute(name) || '').split(/\)\s*/g),
59852            matrix = new Matrix();
59853
59854        for (var i = 0, l = transforms.length; i < l; i++) {
59855          var transform = transforms[i];
59856          if (!transform) break;
59857          var parts = transform.split(/\(\s*/),
59858              command = parts[0],
59859              v = parts[1].split(/[\s,]+/g);
59860
59861          for (var j = 0, m = v.length; j < m; j++) {
59862            v[j] = parseFloat(v[j]);
59863          }
59864
59865          switch (command) {
59866            case 'matrix':
59867              matrix.append(new Matrix(v[0], v[1], v[2], v[3], v[4], v[5]));
59868              break;
59869
59870            case 'rotate':
59871              matrix.rotate(v[0], v[1] || 0, v[2] || 0);
59872              break;
59873
59874            case 'translate':
59875              matrix.translate(v[0], v[1] || 0);
59876              break;
59877
59878            case 'scale':
59879              matrix.scale(v);
59880              break;
59881
59882            case 'skewX':
59883              matrix.skew(v[0], 0);
59884              break;
59885
59886            case 'skewY':
59887              matrix.skew(0, v[0]);
59888              break;
59889          }
59890        }
59891
59892        item.transform(matrix);
59893      }
59894    }
59895
59896    function applyOpacity(item, value, name) {
59897      var key = name === 'fill-opacity' ? 'getFillColor' : 'getStrokeColor',
59898          color = item[key] && item[key]();
59899      if (color) color.setAlpha(parseFloat(value));
59900    }
59901
59902    var attributes = Base.set(Base.each(SvgStyles, function (entry) {
59903      this[entry.attribute] = function (item, value) {
59904        if (item[entry.set]) {
59905          item[entry.set](convertValue(value, entry.type, entry.fromSVG));
59906
59907          if (entry.type === 'color') {
59908            var color = item[entry.get]();
59909
59910            if (color) {
59911              if (color._scaleToBounds) {
59912                var bounds = item.getBounds();
59913                color.transform(new Matrix().translate(bounds.getPoint()).scale(bounds.getSize()));
59914              }
59915            }
59916          }
59917        }
59918      };
59919    }, {}), {
59920      id: function id(item, value) {
59921        definitions[value] = item;
59922        if (item.setName) item.setName(value);
59923      },
59924      'clip-path': function clipPath(item, value) {
59925        var clip = getDefinition(value);
59926
59927        if (clip) {
59928          clip = clip.clone();
59929          clip.setClipMask(true);
59930
59931          if (item instanceof Group) {
59932            item.insertChild(0, clip);
59933          } else {
59934            return new Group(clip, item);
59935          }
59936        }
59937      },
59938      gradientTransform: applyTransform,
59939      transform: applyTransform,
59940      'fill-opacity': applyOpacity,
59941      'stroke-opacity': applyOpacity,
59942      visibility: function visibility(item, value) {
59943        if (item.setVisible) item.setVisible(value === 'visible');
59944      },
59945      display: function display(item, value) {
59946        if (item.setVisible) item.setVisible(value !== null);
59947      },
vendor: 3,615 bytes, lines 59948-60053
59948      'stop-color': function stopColor(item, value) {
59949        if (item.setColor) item.setColor(value);
59950      },
59951      'stop-opacity': function stopOpacity(item, value) {
59952        if (item._color) item._color.setAlpha(parseFloat(value));
59953      },
59954      offset: function offset(item, value) {
59955        if (item.setOffset) {
59956          var percent = value.match(/(.*)%$/);
59957          item.setOffset(percent ? percent[1] / 100 : parseFloat(value));
59958        }
59959      },
59960      viewBox: function viewBox(item, value, name, node, styles) {
59961        var rect = new _Rectangle(convertValue(value, 'array')),
59962            size = getSize(node, null, null, true),
59963            group,
59964            matrix;
59965
59966        if (item instanceof Group) {
59967          var scale = size ? size.divide(rect.getSize()) : 1,
59968              matrix = new Matrix().scale(scale).translate(rect.getPoint().negate());
59969          group = item;
59970        } else if (item instanceof SymbolDefinition) {
59971          if (size) rect.setSize(size);
59972          group = item._item;
59973        }
59974
59975        if (group) {
59976          if (getAttribute(node, 'overflow', styles) !== 'visible') {
59977            var clip = new Shape.Rectangle(rect);
59978            clip.setClipMask(true);
59979            group.addChild(clip);
59980          }
59981
59982          if (matrix) group.transform(matrix);
59983        }
59984      }
59985    });
59986
59987    function getAttribute(node, name, styles) {
59988      var attr = node.attributes[name],
59989          value = attr && attr.value;
59990
59991      if (!value && node.style) {
59992        var style = Base.camelize(name);
59993        value = node.style[style];
59994        if (!value && styles.node[style] !== styles.parent[style]) value = styles.node[style];
59995      }
59996
59997      return !value ? undefined : value === 'none' ? null : value;
59998    }
59999
60000    function applyAttributes(item, node, isRoot) {
60001      var parent = node.parentNode,
60002          styles = {
60003        node: DomElement.getStyles(node) || {},
60004        parent: !isRoot && !/^defs$/i.test(parent.tagName) && DomElement.getStyles(parent) || {}
60005      };
60006      Base.each(attributes, function (apply, name) {
60007        var value = getAttribute(node, name, styles);
60008        item = value !== undefined && apply(item, value, name, node, styles) || item;
60009      });
60010      return item;
60011    }
60012
60013    function getDefinition(value) {
60014      var match = value && value.match(/\((?:["'#]*)([^"')]+)/),
60015          name = match && match[1],
60016          res = name && definitions[window ? name.replace(window.location.href.split('#')[0] + '#', '') : name];
60017
60018      if (res && res._scaleToBounds) {
60019        res = res.clone();
60020        res._scaleToBounds = true;
60021      }
60022
60023      return res;
60024    }
60025
60026    function importNode(node, options, isRoot) {
60027      var type = node.nodeName.toLowerCase(),
60028          isElement = type !== '#document',
60029          body = document.body,
60030          container,
60031          parent,
60032          next;
60033
60034      if (isRoot && isElement) {
60035        rootSize = paper.getView().getSize();
60036        rootSize = getSize(node, null, null, true) || rootSize;
60037        container = SvgElement.create('svg', {
60038          style: 'stroke-width: 1px; stroke-miterlimit: 10'
60039        });
60040        parent = node.parentNode;
60041        next = node.nextSibling;
60042        container.appendChild(node);
60043        body.appendChild(container);
60044      }
60045
60046      var settings = paper.settings,
60047          applyMatrix = settings.applyMatrix,
60048          insertItems = settings.insertItems;
60049      settings.applyMatrix = false;
60050      settings.insertItems = false;
60051      var importer = importers[type],
60052          item = importer && importer(node, type, options, isRoot) || null;
60053      settings.insertItems = insertItems;
60054      settings.applyMatrix = applyMatrix;
60055
60056      if (item) {
60057        if (isElement && !(item instanceof Group)) item = applyAttributes(item, node, isRoot);
60058        var onImport = options.onImport,
60059            data = isElement && node.getAttribute('data-paper-data');
60060        if (onImport) item = onImport(node, item, options) || item;
60061
60062        if (options.expandShapes && item instanceof Shape) {
60063          item.remove();
60064          item = item.toPath();
60065        }
60066
60067        if (data) item._data = JSON.parse(data);
60068      }
60069
60070      if (container) {
60071        body.removeChild(container);
60072
60073        if (parent) {
60074          if (next) {
60075            parent.insertBefore(node, next);
60076          } else {
60077            parent.appendChild(node);
60078          }
60079        }
60080      }
60081
60082      if (isRoot) {
60083        definitions = {};
60084        if (item && Base.pick(options.applyMatrix, applyMatrix)) item.matrix.apply(true, true);
60085      }
60086
60087      return item;
60088    }
60089
60090    function _importSVG(source, options, owner) {
60091      if (!source) return null;
60092      options = typeof options === 'function' ? {
60093        onLoad: options
60094      } : options || {};
60095      var scope = paper,
60096          item = null;
60097
60098      function onLoad(svg) {
60099        try {
60100          var node = _typeof(svg) === 'object' ? svg : new self.DOMParser().parseFromString(svg, 'image/svg+xml');
60101
60102          if (!node.nodeName) {
60103            node = null;
60104            throw new Error('Unsupported SVG source: ' + source);
60105          }
60106
60107          paper = scope;
60108          item = importNode(node, options, true);
60109
60110          if (!options || options.insert !== false) {
60111            owner._insertItem(undefined, item);
60112          }
60113
60114          var onLoad = options.onLoad;
60115          if (onLoad) onLoad(item, svg);
60116        } catch (e) {
60117          onError(e);
60118        }
60119      }
60120
60121      function onError(message, status) {
60122        var onError = options.onError;
60123
60124        if (onError) {
60125          onError(message, status);
60126        } else {
60127          throw new Error(message);
60128        }
60129      }
60130
60131      if (typeof source === 'string' && !/^.*</.test(source)) {
60132        var node = document.getElementById(source);
60133
60134        if (node) {
60135          onLoad(node);
60136        } else {
60137          Http.request({
60138            url: source,
60139            async: true,
60140            onLoad: onLoad,
60141            onError: onError
60142          });
60143        }
60144      } else if (typeof File !== 'undefined' && source instanceof File) {
60145        var reader = new FileReader();
60146
60147        reader.onload = function () {
60148          onLoad(reader.result);
60149        };
60150
60151        reader.onerror = function () {
60152          onError(reader.error);
60153        };
60154
60155        return reader.readAsText(source);
60156      } else {
60157        onLoad(source);
60158      }
60159
60160      return item;
60161    }
60162
60163    Item.inject({
60164      importSVG: function importSVG(node, options) {
60165        return _importSVG(node, options, this);
60166      }
60167    });
60168    Project.inject({
60169      importSVG: function importSVG(node, options) {
60170        this.activate();
60171        return _importSVG(node, options, this);
60172      }
60173    });
60174  }();
60175
60176  Base.exports.PaperScript = function () {
60177    var global = this,
60178        acorn = global.acorn;
60179
60180    if (!acorn && typeof require !== 'undefined') {
60181      try {
60182        acorn = require('acorn');
60183      } catch (e) {}
60184    }
60185
60186    if (!acorn) {
60187      var exports, module;
60188      acorn = exports = module = {};
60189
60190      (function (root, mod) {
60191        if (_typeof(exports) == "object" && _typeof(module) == "object") return mod(exports);
60192        if (typeof define == "function" && define.amd) return define(["exports"], mod);
60193        mod(root.acorn || (root.acorn = {}));
60194      })(this, function (exports) {
60195        "use strict";
60196
60197        exports.version = "0.5.0";
60198        var options, input, inputLen, sourceFile;
60199
60200        exports.parse = function (inpt, opts) {
60201          input = String(inpt);
60202          inputLen = input.length;
60203          setOptions(opts);
60204          initTokenState();
60205          return parseTopLevel(options.program);
60206        };
60207
60208        var defaultOptions = exports.defaultOptions = {
60209          ecmaVersion: 5,
vendor: 8,676 bytes, lines 60210-60578
60210          strictSemicolons: false,
60211          allowTrailingCommas: true,
60212          forbidReserved: false,
60213          allowReturnOutsideFunction: false,
60214          locations: false,
60215          onComment: null,
60216          ranges: false,
60217          program: null,
60218          sourceFile: null,
60219          directSourceFile: null
60220        };
60221
60222        function setOptions(opts) {
60223          options = opts || {};
60224
60225          for (var opt in defaultOptions) {
60226            if (!Object.prototype.hasOwnProperty.call(options, opt)) options[opt] = defaultOptions[opt];
60227          }
60228
60229          sourceFile = options.sourceFile || null;
60230        }
60231
60232        var getLineInfo = exports.getLineInfo = function (input, offset) {
60233          for (var line = 1, cur = 0;;) {
60234            lineBreak.lastIndex = cur;
60235            var match = lineBreak.exec(input);
60236
60237            if (match && match.index < offset) {
60238              ++line;
60239              cur = match.index + match[0].length;
60240            } else break;
60241          }
60242
60243          return {
60244            line: line,
60245            column: offset - cur
60246          };
60247        };
60248
60249        exports.tokenize = function (inpt, opts) {
60250          input = String(inpt);
60251          inputLen = input.length;
60252          setOptions(opts);
60253          initTokenState();
60254          var t = {};
60255
60256          function getToken(forceRegexp) {
60257            lastEnd = tokEnd;
60258            readToken(forceRegexp);
60259            t.start = tokStart;
60260            t.end = tokEnd;
60261            t.startLoc = tokStartLoc;
60262            t.endLoc = tokEndLoc;
60263            t.type = tokType;
60264            t.value = tokVal;
60265            return t;
60266          }
60267
60268          getToken.jumpTo = function (pos, reAllowed) {
60269            tokPos = pos;
60270
60271            if (options.locations) {
60272              tokCurLine = 1;
60273              tokLineStart = lineBreak.lastIndex = 0;
60274              var match;
60275
60276              while ((match = lineBreak.exec(input)) && match.index < pos) {
60277                ++tokCurLine;
60278                tokLineStart = match.index + match[0].length;
60279              }
60280            }
60281
60282            tokRegexpAllowed = reAllowed;
60283            skipSpace();
60284          };
60285
60286          return getToken;
60287        };
60288
60289        var tokPos;
60290        var tokStart, tokEnd;
60291        var tokStartLoc, tokEndLoc;
60292        var tokType, tokVal;
60293        var tokRegexpAllowed;
60294        var tokCurLine, tokLineStart;
60295        var lastStart, lastEnd, lastEndLoc;
60296        var inFunction, labels, strict;
60297
60298        function raise(pos, message) {
60299          var loc = getLineInfo(input, pos);
60300          message += " (" + loc.line + ":" + loc.column + ")";
60301          var err = new SyntaxError(message);
60302          err.pos = pos;
60303          err.loc = loc;
60304          err.raisedAt = tokPos;
60305          throw err;
60306        }
60307
60308        var empty = [];
60309        var _num = {
60310          type: "num"
60311        },
60312            _regexp = {
60313          type: "regexp"
60314        },
60315            _string = {
60316          type: "string"
60317        };
60318        var _name = {
60319          type: "name"
60320        },
60321            _eof = {
60322          type: "eof"
60323        };
60324        var _break = {
60325          keyword: "break"
60326        },
60327            _case = {
60328          keyword: "case",
60329          beforeExpr: true
60330        },
60331            _catch = {
60332          keyword: "catch"
60333        };
60334        var _continue = {
60335          keyword: "continue"
60336        },
60337            _debugger = {
60338          keyword: "debugger"
60339        },
60340            _default = {
60341          keyword: "default"
60342        };
60343        var _do = {
60344          keyword: "do",
60345          isLoop: true
60346        },
60347            _else = {
60348          keyword: "else",
60349          beforeExpr: true
60350        };
60351        var _finally = {
60352          keyword: "finally"
60353        },
60354            _for = {
60355          keyword: "for",
60356          isLoop: true
60357        },
60358            _function = {
60359          keyword: "function"
60360        };
60361        var _if = {
60362          keyword: "if"
60363        },
60364            _return = {
60365          keyword: "return",
60366          beforeExpr: true
60367        },
60368            _switch = {
60369          keyword: "switch"
60370        };
60371        var _throw = {
60372          keyword: "throw",
60373          beforeExpr: true
60374        },
60375            _try = {
60376          keyword: "try"
60377        },
60378            _var = {
60379          keyword: "var"
60380        };
60381        var _while = {
60382          keyword: "while",
60383          isLoop: true
60384        },
60385            _with = {
60386          keyword: "with"
60387        },
60388            _new = {
60389          keyword: "new",
60390          beforeExpr: true
60391        };
60392        var _this = {
60393          keyword: "this"
60394        };
60395        var _null = {
60396          keyword: "null",
60397          atomValue: null
60398        },
60399            _true = {
60400          keyword: "true",
60401          atomValue: true
60402        };
60403        var _false = {
60404          keyword: "false",
60405          atomValue: false
60406        };
60407        var _in = {
60408          keyword: "in",
60409          binop: 7,
60410          beforeExpr: true
60411        };
60412        var keywordTypes = {
60413          "break": _break,
60414          "case": _case,
60415          "catch": _catch,
60416          "continue": _continue,
60417          "debugger": _debugger,
60418          "default": _default,
60419          "do": _do,
60420          "else": _else,
60421          "finally": _finally,
60422          "for": _for,
60423          "function": _function,
60424          "if": _if,
60425          "return": _return,
60426          "switch": _switch,
60427          "throw": _throw,
60428          "try": _try,
60429          "var": _var,
60430          "while": _while,
60431          "with": _with,
60432          "null": _null,
60433          "true": _true,
60434          "false": _false,
60435          "new": _new,
60436          "in": _in,
60437          "instanceof": {
60438            keyword: "instanceof",
60439            binop: 7,
60440            beforeExpr: true
60441          },
60442          "this": _this,
60443          "typeof": {
60444            keyword: "typeof",
60445            prefix: true,
60446            beforeExpr: true
60447          },
60448          "void": {
60449            keyword: "void",
60450            prefix: true,
60451            beforeExpr: true
60452          },
60453          "delete": {
60454            keyword: "delete",
60455            prefix: true,
60456            beforeExpr: true
60457          }
60458        };
60459        var _bracketL = {
60460          type: "[",
60461          beforeExpr: true
60462        },
60463            _bracketR = {
60464          type: "]"
60465        },
60466            _braceL = {
60467          type: "{",
60468          beforeExpr: true
60469        };
60470        var _braceR = {
60471          type: "}"
60472        },
60473            _parenL = {
60474          type: "(",
60475          beforeExpr: true
60476        },
60477            _parenR = {
60478          type: ")"
60479        };
60480        var _comma = {
60481          type: ",",
60482          beforeExpr: true
60483        },
60484            _semi = {
60485          type: ";",
60486          beforeExpr: true
60487        };
60488        var _colon = {
60489          type: ":",
60490          beforeExpr: true
60491        },
60492            _dot = {
60493          type: "."
60494        },
60495            _question = {
60496          type: "?",
60497          beforeExpr: true
60498        };
60499        var _slash = {
60500          binop: 10,
60501          beforeExpr: true
60502        },
60503            _eq = {
60504          isAssign: true,
60505          beforeExpr: true
60506        };
60507        var _assign = {
60508          isAssign: true,
60509          beforeExpr: true
60510        };
60511        var _incDec = {
60512          postfix: true,
60513          prefix: true,
60514          isUpdate: true
60515        },
60516            _prefix = {
60517          prefix: true,
60518          beforeExpr: true
60519        };
60520        var _logicalOR = {
60521          binop: 1,
60522          beforeExpr: true
60523        };
60524        var _logicalAND = {
60525          binop: 2,
60526          beforeExpr: true
60527        };
60528        var _bitwiseOR = {
60529          binop: 3,
60530          beforeExpr: true
60531        };
60532        var _bitwiseXOR = {
60533          binop: 4,
60534          beforeExpr: true
60535        };
60536        var _bitwiseAND = {
60537          binop: 5,
60538          beforeExpr: true
60539        };
60540        var _equality = {
60541          binop: 6,
60542          beforeExpr: true
60543        };
60544        var _relational = {
60545          binop: 7,
60546          beforeExpr: true
60547        };
60548        var _bitShift = {
60549          binop: 8,
60550          beforeExpr: true
60551        };
60552        var _plusMin = {
60553          binop: 9,
60554          prefix: true,
60555          beforeExpr: true
60556        };
60557        var _multiplyModulo = {
60558          binop: 10,
60559          beforeExpr: true
60560        };
60561        exports.tokTypes = {
60562          bracketL: _bracketL,
60563          bracketR: _bracketR,
60564          braceL: _braceL,
60565          braceR: _braceR,
60566          parenL: _parenL,
60567          parenR: _parenR,
60568          comma: _comma,
60569          semi: _semi,
60570          colon: _colon,
60571          dot: _dot,
60572          question: _question,
60573          slash: _slash,
60574          eq: _eq,
60575          name: _name,
60576          eof: _eof,
60577          num: _num,
60578          regexp: _regexp,
60579          string: _string
60580        };
60581
60582        for (var kw in keywordTypes) {
60583          exports.tokTypes["_" + kw] = keywordTypes[kw];
60584        }
60585
60586        function makePredicate(words) {
60587          words = words.split(" ");
60588          var f = "",
60589              cats = [];
60590
60591          out: for (var i = 0; i < words.length; ++i) {
60592            for (var j = 0; j < cats.length; ++j) {
60593              if (cats[j][0].length == words[i].length) {
60594                cats[j].push(words[i]);
60595                continue out;
60596              }
60597            }
60598
60599            cats.push([words[i]]);
60600          }
60601
60602          function compareTo(arr) {
60603            if (arr.length == 1) return f += "return str === " + JSON.stringify(arr[0]) + ";";
60604            f += "switch(str){";
60605
60606            for (var i = 0; i < arr.length; ++i) {
60607              f += "case " + JSON.stringify(arr[i]) + ":";
60608            }
60609
60610            f += "return true}return false;";
60611          }
60612
60613          if (cats.length > 3) {
60614            cats.sort(function (a, b) {
60615              return b.length - a.length;
60616            });
60617            f += "switch(str.length){";
60618
60619            for (var i = 0; i < cats.length; ++i) {
60620              var cat = cats[i];
60621              f += "case " + cat[0].length + ":";
60622              compareTo(cat);
60623            }
60624
60625            f += "}";
60626          } else {
60627            compareTo(words);
60628          }
60629
60630          return new Function("str", f);
60631        }
60632
60633        var isReservedWord3 = makePredicate("abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile");
60634        var isReservedWord5 = makePredicate("class enum extends super const export import");
60635        var isStrictReservedWord = makePredicate("implements interface let package private protected public static yield");
60636        var isStrictBadIdWord = makePredicate("eval arguments");
60637        var isKeyword = makePredicate("break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this");
60638        var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
60639        var nonASCIIidentifierStartChars = "\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFB
vendor: 47,372 bytes, lines 60639-62050
60639D3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC";
60640        var nonASCIIidentifierChars = "\u0300-\u036F\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u0620-\u0649\u0672-\u06D3\u06E7-\u06E8\u06FB-\u06FC\u0730-\u074A\u0800-\u0814\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0840-\u0857\u08E4-\u08FE\u0900-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962-\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09D7\u09DF-\u09E0\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5F-\u0B60\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2-\u0CE3\u0CE6-\u0CEF\u0D02\u0D03\u0D46-\u0D48\u0D57\u0D62-\u0D63\u0D66-\u0D6F\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E34-\u0E3A\u0E40-\u0E45\u0E50-\u0E59\u0EB4-\u0EB9\u0EC8-\u0ECD\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F41-\u0F47\u0F71-\u0F84\u0F86-\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1029\u1040-\u1049\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u170E-\u1710\u1720-\u1730\u1740-\u1750\u1772\u1773\u1780-\u17B2\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1920-\u192B\u1930-\u193B\u1951-\u196D\u19B0-\u19C0\u19C8-\u19C9\u19D0-\u19D9\u1A00-\u1A15\u1A20-\u1A53\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1B46-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C00-\u1C22\u1C40-\u1C49\u1C5B-\u1C7D\u1CD0-\u1CD2\u1D00-\u1DBE\u1E01-\u1F15\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2D81-\u2D96\u2DE0-\u2DFF\u3021-\u3028\u3099\u309A\uA640-\uA66D\uA674-\uA67D\uA69F\uA6F0-\uA6F1\uA7F8-\uA800\uA806\uA80B\uA823-\uA827\uA880-\uA881\uA8B4-\uA8C4\uA8D0-\uA8D9\uA8F3-\uA8F7\uA900-\uA909\uA926-\uA92D\uA930-\uA945\uA980-\uA983\uA9B3-\uA9C0\uAA00-\uAA27\uAA40-\uAA41\uAA4C-\uAA4D\uAA50-\uAA59\uAA7B\uAAE0-\uAAE9\uAAF2-\uAAF3\uABC0-\uABE1\uABEC\uABED\uABF0-\uABF9\uFB20-\uFB28\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F";
60641        var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
60642        var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
60643        var newline = /[\n\r\u2028\u2029]/;
60644        var lineBreak = /\r\n|[\n\r\u2028\u2029]/g;
60645
60646        var isIdentifierStart = exports.isIdentifierStart = function (code) {
60647          if (code < 65) return code === 36;
60648          if (code < 91) return true;
60649          if (code < 97) return code === 95;
60650          if (code < 123) return true;
60651          return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
60652        };
60653
60654        var isIdentifierChar = exports.isIdentifierChar = function (code) {
60655          if (code < 48) return code === 36;
60656          if (code < 58) return true;
60657          if (code < 65) return false;
60658          if (code < 91) return true;
60659          if (code < 97) return code === 95;
60660          if (code < 123) return true;
60661          return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
60662        };
60663
60664        function line_loc_t() {
60665          this.line = tokCurLine;
60666          this.column = tokPos - tokLineStart;
60667        }
60668
60669        function initTokenState() {
60670          tokCurLine = 1;
60671          tokPos = tokLineStart = 0;
60672          tokRegexpAllowed = true;
60673          skipSpace();
60674        }
60675
60676        function finishToken(type, val) {
60677          tokEnd = tokPos;
60678          if (options.locations) tokEndLoc = new line_loc_t();
60679          tokType = type;
60680          skipSpace();
60681          tokVal = val;
60682          tokRegexpAllowed = type.beforeExpr;
60683        }
60684
60685        function skipBlockComment() {
60686          var startLoc = options.onComment && options.locations && new line_loc_t();
60687          var start = tokPos,
60688              end = input.indexOf("*/", tokPos += 2);
60689          if (end === -1) raise(tokPos - 2, "Unterminated comment");
60690          tokPos = end + 2;
60691
60692          if (options.locations) {
60693            lineBreak.lastIndex = start;
60694            var match;
60695
60696            while ((match = lineBreak.exec(input)) && match.index < tokPos) {
60697              ++tokCurLine;
60698              tokLineStart = match.index + match[0].length;
60699            }
60700          }
60701
60702          if (options.onComment) options.onComment(true, input.slice(start + 2, end), start, tokPos, startLoc, options.locations && new line_loc_t());
60703        }
60704
60705        function skipLineComment() {
60706          var start = tokPos;
60707          var startLoc = options.onComment && options.locations && new line_loc_t();
60708          var ch = input.charCodeAt(tokPos += 2);
60709
60710          while (tokPos < inputLen && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) {
60711            ++tokPos;
60712            ch = input.charCodeAt(tokPos);
60713          }
60714
60715          if (options.onComment) options.onComment(false, input.slice(start + 2, tokPos), start, tokPos, startLoc, options.locations && new line_loc_t());
60716        }
60717
60718        function skipSpace() {
60719          while (tokPos < inputLen) {
60720            var ch = input.charCodeAt(tokPos);
60721
60722            if (ch === 32) {
60723              ++tokPos;
60724            } else if (ch === 13) {
60725              ++tokPos;
60726              var next = input.charCodeAt(tokPos);
60727
60728              if (next === 10) {
60729                ++tokPos;
60730              }
60731
60732              if (options.locations) {
60733                ++tokCurLine;
60734                tokLineStart = tokPos;
60735              }
60736            } else if (ch === 10 || ch === 8232 || ch === 8233) {
60737              ++tokPos;
60738
60739              if (options.locations) {
60740                ++tokCurLine;
60741                tokLineStart = tokPos;
60742              }
60743            } else if (ch > 8 && ch < 14) {
60744              ++tokPos;
60745            } else if (ch === 47) {
60746              var next = input.charCodeAt(tokPos + 1);
60747
60748              if (next === 42) {
60749                skipBlockComment();
60750              } else if (next === 47) {
60751                skipLineComment();
60752              } else break;
60753            } else if (ch === 160) {
60754              ++tokPos;
60755            } else if (ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
60756              ++tokPos;
60757            } else {
60758              break;
60759            }
60760          }
60761        }
60762
60763        function readToken_dot() {
60764          var next = input.charCodeAt(tokPos + 1);
60765          if (next >= 48 && next <= 57) return readNumber(true);
60766          ++tokPos;
60767          return finishToken(_dot);
60768        }
60769
60770        function readToken_slash() {
60771          var next = input.charCodeAt(tokPos + 1);
60772
60773          if (tokRegexpAllowed) {
60774            ++tokPos;
60775            return readRegexp();
60776          }
60777
60778          if (next === 61) return finishOp(_assign, 2);
60779          return finishOp(_slash, 1);
60780        }
60781
60782        function readToken_mult_modulo() {
60783          var next = input.charCodeAt(tokPos + 1);
60784          if (next === 61) return finishOp(_assign, 2);
60785          return finishOp(_multiplyModulo, 1);
60786        }
60787
60788        function readToken_pipe_amp(code) {
60789          var next = input.charCodeAt(tokPos + 1);
60790          if (next === code) return finishOp(code === 124 ? _logicalOR : _logicalAND, 2);
60791          if (next === 61) return finishOp(_assign, 2);
60792          return finishOp(code === 124 ? _bitwiseOR : _bitwiseAND, 1);
60793        }
60794
60795        function readToken_caret() {
60796          var next = input.charCodeAt(tokPos + 1);
60797          if (next === 61) return finishOp(_assign, 2);
60798          return finishOp(_bitwiseXOR, 1);
60799        }
60800
60801        function readToken_plus_min(code) {
60802          var next = input.charCodeAt(tokPos + 1);
60803
60804          if (next === code) {
60805            if (next == 45 && input.charCodeAt(tokPos + 2) == 62 && newline.test(input.slice(lastEnd, tokPos))) {
60806              tokPos += 3;
60807              skipLineComment();
60808              skipSpace();
60809              return readToken();
60810            }
60811
60812            return finishOp(_incDec, 2);
60813          }
60814
60815          if (next === 61) return finishOp(_assign, 2);
60816          return finishOp(_plusMin, 1);
60817        }
60818
60819        function readToken_lt_gt(code) {
60820          var next = input.charCodeAt(tokPos + 1);
60821          var size = 1;
60822
60823          if (next === code) {
60824            size = code === 62 && input.charCodeAt(tokPos + 2) === 62 ? 3 : 2;
60825            if (input.charCodeAt(tokPos + size) === 61) return finishOp(_assign, size + 1);
60826            return finishOp(_bitShift, size);
60827          }
60828
60829          if (next == 33 && code == 60 && input.charCodeAt(tokPos + 2) == 45 && input.charCodeAt(tokPos + 3) == 45) {
60830            tokPos += 4;
60831            skipLineComment();
60832            skipSpace();
60833            return readToken();
60834          }
60835
60836          if (next === 61) size = input.charCodeAt(tokPos + 2) === 61 ? 3 : 2;
60837          return finishOp(_relational, size);
60838        }
60839
60840        function readToken_eq_excl(code) {
60841          var next = input.charCodeAt(tokPos + 1);
60842          if (next === 61) return finishOp(_equality, input.charCodeAt(tokPos + 2) === 61 ? 3 : 2);
60843          return finishOp(code === 61 ? _eq : _prefix, 1);
60844        }
60845
60846        function getTokenFromCode(code) {
60847          switch (code) {
60848            case 46:
60849              return readToken_dot();
60850
60851            case 40:
60852              ++tokPos;
60853              return finishToken(_parenL);
60854
60855            case 41:
60856              ++tokPos;
60857              return finishToken(_parenR);
60858
60859            case 59:
60860              ++tokPos;
60861              return finishToken(_semi);
60862
60863            case 44:
60864              ++tokPos;
60865              return finishToken(_comma);
60866
60867            case 91:
60868              ++tokPos;
60869              return finishToken(_bracketL);
60870
60871            case 93:
60872              ++tokPos;
60873              return finishToken(_bracketR);
60874
60875            case 123:
60876              ++tokPos;
60877              return finishToken(_braceL);
60878
60879            case 125:
60880              ++tokPos;
60881              return finishToken(_braceR);
60882
60883            case 58:
60884              ++tokPos;
60885              return finishToken(_colon);
60886
60887            case 63:
60888              ++tokPos;
60889              return finishToken(_question);
60890
60891            case 48:
60892              var next = input.charCodeAt(tokPos + 1);
60893              if (next === 120 || next === 88) return readHexNumber();
60894
60895            case 49:
60896            case 50:
60897            case 51:
60898            case 52:
60899            case 53:
60900            case 54:
60901            case 55:
60902            case 56:
60903            case 57:
60904              return readNumber(false);
60905
60906            case 34:
60907            case 39:
60908              return readString(code);
60909
60910            case 47:
60911              return readToken_slash(code);
60912
60913            case 37:
60914            case 42:
60915              return readToken_mult_modulo();
60916
60917            case 124:
60918            case 38:
60919              return readToken_pipe_amp(code);
60920
60921            case 94:
60922              return readToken_caret();
60923
60924            case 43:
60925            case 45:
60926              return readToken_plus_min(code);
60927
60928            case 60:
60929            case 62:
60930              return readToken_lt_gt(code);
60931
60932            case 61:
60933            case 33:
60934              return readToken_eq_excl(code);
60935
60936            case 126:
60937              return finishOp(_prefix, 1);
60938          }
60939
60940          return false;
60941        }
60942
60943        function readToken(forceRegexp) {
60944          if (!forceRegexp) tokStart = tokPos;else tokPos = tokStart + 1;
60945          if (options.locations) tokStartLoc = new line_loc_t();
60946          if (forceRegexp) return readRegexp();
60947          if (tokPos >= inputLen) return finishToken(_eof);
60948          var code = input.charCodeAt(tokPos);
60949          if (isIdentifierStart(code) || code === 92) return readWord();
60950          var tok = getTokenFromCode(code);
60951
60952          if (tok === false) {
60953            var ch = String.fromCharCode(code);
60954            if (ch === "\\" || nonASCIIidentifierStart.test(ch)) return readWord();
60955            raise(tokPos, "Unexpected character '" + ch + "'");
60956          }
60957
60958          return tok;
60959        }
60960
60961        function finishOp(type, size) {
60962          var str = input.slice(tokPos, tokPos + size);
60963          tokPos += size;
60964          finishToken(type, str);
60965        }
60966
60967        function readRegexp() {
60968          var content = "",
60969              escaped,
60970              inClass,
60971              start = tokPos;
60972
60973          for (;;) {
60974            if (tokPos >= inputLen) raise(start, "Unterminated regular expression");
60975            var ch = input.charAt(tokPos);
60976            if (newline.test(ch)) raise(start, "Unterminated regular expression");
60977
60978            if (!escaped) {
60979              if (ch === "[") inClass = true;else if (ch === "]" && inClass) inClass = false;else if (ch === "/" && !inClass) break;
60980              escaped = ch === "\\";
60981            } else escaped = false;
60982
60983            ++tokPos;
60984          }
60985
60986          var content = input.slice(start, tokPos);
60987          ++tokPos;
60988          var mods = readWord1();
60989          if (mods && !/^[gmsiy]*$/.test(mods)) raise(start, "Invalid regexp flag");
60990
60991          try {
60992            var value = new RegExp(content, mods);
60993          } catch (e) {
60994            if (e instanceof SyntaxError) raise(start, e.message);
60995            raise(e);
60996          }
60997
60998          return finishToken(_regexp, value);
60999        }
61000
61001        function readInt(radix, len) {
61002          var start = tokPos,
61003              total = 0;
61004
61005          for (var i = 0, e = len == null ? Infinity : len; i < e; ++i) {
61006            var code = input.charCodeAt(tokPos),
61007                val;
61008            if (code >= 97) val = code - 97 + 10;else if (code >= 65) val = code - 65 + 10;else if (code >= 48 && code <= 57) val = code - 48;else val = Infinity;
61009            if (val >= radix) break;
61010            ++tokPos;
61011            total = total * radix + val;
61012          }
61013
61014          if (tokPos === start || len != null && tokPos - start !== len) return null;
61015          return total;
61016        }
61017
61018        function readHexNumber() {
61019          tokPos += 2;
61020          var val = readInt(16);
61021          if (val == null) raise(tokStart + 2, "Expected hexadecimal number");
61022          if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number");
61023          return finishToken(_num, val);
61024        }
61025
61026        function readNumber(startsWithDot) {
61027          var start = tokPos,
61028              isFloat = false,
61029              octal = input.charCodeAt(tokPos) === 48;
61030          if (!startsWithDot && readInt(10) === null) raise(start, "Invalid number");
61031
61032          if (input.charCodeAt(tokPos) === 46) {
61033            ++tokPos;
61034            readInt(10);
61035            isFloat = true;
61036          }
61037
61038          var next = input.charCodeAt(tokPos);
61039
61040          if (next === 69 || next === 101) {
61041            next = input.charCodeAt(++tokPos);
61042            if (next === 43 || next === 45) ++tokPos;
61043            if (readInt(10) === null) raise(start, "Invalid number");
61044            isFloat = true;
61045          }
61046
61047          if (isIdentifierStart(input.charCodeAt(tokPos))) raise(tokPos, "Identifier directly after number");
61048          var str = input.slice(start, tokPos),
61049              val;
61050          if (isFloat) val = parseFloat(str);else if (!octal || str.length === 1) val = parseInt(str, 10);else if (/[89]/.test(str) || strict) raise(start, "Invalid number");else val = parseInt(str, 8);
61051          return finishToken(_num, val);
61052        }
61053
61054        function readString(quote) {
61055          tokPos++;
61056          var out = "";
61057
61058          for (;;) {
61059            if (tokPos >= inputLen) raise(tokStart, "Unterminated string constant");
61060            var ch = input.charCodeAt(tokPos);
61061
61062            if (ch === quote) {
61063              ++tokPos;
61064              return finishToken(_string, out);
61065            }
61066
61067            if (ch === 92) {
61068              ch = input.charCodeAt(++tokPos);
61069              var octal = /^[0-7]+/.exec(input.slice(tokPos, tokPos + 3));
61070              if (octal) octal = octal[0];
61071
61072              while (octal && parseInt(octal, 8) > 255) {
61073                octal = octal.slice(0, -1);
61074              }
61075
61076              if (octal === "0") octal = null;
61077              ++tokPos;
61078
61079              if (octal) {
61080                if (strict) raise(tokPos - 2, "Octal literal in strict mode");
61081                out += String.fromCharCode(parseInt(octal, 8));
61082                tokPos += octal.length - 1;
61083              } else {
61084                switch (ch) {
61085                  case 110:
61086                    out += "\n";
61087                    break;
61088
61089                  case 114:
61090                    out += "\r";
61091                    break;
61092
61093                  case 120:
61094                    out += String.fromCharCode(readHexChar(2));
61095                    break;
61096
61097                  case 117:
61098                    out += String.fromCharCode(readHexChar(4));
61099                    break;
61100
61101                  case 85:
61102                    out += String.fromCharCode(readHexChar(8));
61103                    break;
61104
61105                  case 116:
61106                    out += "\t";
61107                    break;
61108
61109                  case 98:
61110                    out += "\b";
61111                    break;
61112
61113                  case 118:
61114                    out += "\x0B";
61115                    break;
61116
61117                  case 102:
61118                    out += "\f";
61119                    break;
61120
61121                  case 48:
61122                    out += "\0";
61123                    break;
61124
61125                  case 13:
61126                    if (input.charCodeAt(tokPos) === 10) ++tokPos;
61127
61128                  case 10:
61129                    if (options.locations) {
61130                      tokLineStart = tokPos;
61131                      ++tokCurLine;
61132                    }
61133
61134                    break;
61135
61136                  default:
61137                    out += String.fromCharCode(ch);
61138                    break;
61139                }
61140              }
61141            } else {
61142              if (ch === 13 || ch === 10 || ch === 8232 || ch === 8233) raise(tokStart, "Unterminated string constant");
61143              out += String.fromCharCode(ch);
61144              ++tokPos;
61145            }
61146          }
61147        }
61148
61149        function readHexChar(len) {
61150          var n = readInt(16, len);
61151          if (n === null) raise(tokStart, "Bad character escape sequence");
61152          return n;
61153        }
61154
61155        var containsEsc;
61156
61157        function readWord1() {
61158          containsEsc = false;
61159          var word,
61160              first = true,
61161              start = tokPos;
61162
61163          for (;;) {
61164            var ch = input.charCodeAt(tokPos);
61165
61166            if (isIdentifierChar(ch)) {
61167              if (containsEsc) word += input.charAt(tokPos);
61168              ++tokPos;
61169            } else if (ch === 92) {
61170              if (!containsEsc) word = input.slice(start, tokPos);
61171              containsEsc = true;
61172              if (input.charCodeAt(++tokPos) != 117) raise(tokPos, "Expecting Unicode escape sequence \\uXXXX");
61173              ++tokPos;
61174              var esc = readHexChar(4);
61175              var escStr = String.fromCharCode(esc);
61176              if (!escStr) raise(tokPos - 1, "Invalid Unicode escape");
61177              if (!(first ? isIdentifierStart(esc) : isIdentifierChar(esc))) raise(tokPos - 4, "Invalid Unicode escape");
61178              word += escStr;
61179            } else {
61180              break;
61181            }
61182
61183            first = false;
61184          }
61185
61186          return containsEsc ? word : input.slice(start, tokPos);
61187        }
61188
61189        function readWord() {
61190          var word = readWord1();
61191          var type = _name;
61192          if (!containsEsc && isKeyword(word)) type = keywordTypes[word];
61193          return finishToken(type, word);
61194        }
61195
61196        function next() {
61197          lastStart = tokStart;
61198          lastEnd = tokEnd;
61199          lastEndLoc = tokEndLoc;
61200          readToken();
61201        }
61202
61203        function setStrict(strct) {
61204          strict = strct;
61205          tokPos = tokStart;
61206
61207          if (options.locations) {
61208            while (tokPos < tokLineStart) {
61209              tokLineStart = input.lastIndexOf("\n", tokLineStart - 2) + 1;
61210              --tokCurLine;
61211            }
61212          }
61213
61214          skipSpace();
61215          readToken();
61216        }
61217
61218        function node_t() {
61219          this.type = null;
61220          this.start = tokStart;
61221          this.end = null;
61222        }
61223
61224        function node_loc_t() {
61225          this.start = tokStartLoc;
61226          this.end = null;
61227          if (sourceFile !== null) this.source = sourceFile;
61228        }
61229
61230        function startNode() {
61231          var node = new node_t();
61232          if (options.locations) node.loc = new node_loc_t();
61233          if (options.directSourceFile) node.sourceFile = options.directSourceFile;
61234          if (options.ranges) node.range = [tokStart, 0];
61235          return node;
61236        }
61237
61238        function startNodeFrom(other) {
61239          var node = new node_t();
61240          node.start = other.start;
61241
61242          if (options.locations) {
61243            node.loc = new node_loc_t();
61244            node.loc.start = other.loc.start;
61245          }
61246
61247          if (options.ranges) node.range = [other.range[0], 0];
61248          return node;
61249        }
61250
61251        function finishNode(node, type) {
61252          node.type = type;
61253          node.end = lastEnd;
61254          if (options.locations) node.loc.end = lastEndLoc;
61255          if (options.ranges) node.range[1] = lastEnd;
61256          return node;
61257        }
61258
61259        function isUseStrict(stmt) {
61260          return options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && stmt.expression.value === "use strict";
61261        }
61262
61263        function eat(type) {
61264          if (tokType === type) {
61265            next();
61266            return true;
61267          }
61268        }
61269
61270        function canInsertSemicolon() {
61271          return !options.strictSemicolons && (tokType === _eof || tokType === _braceR || newline.test(input.slice(lastEnd, tokStart)));
61272        }
61273
61274        function semicolon() {
61275          if (!eat(_semi) && !canInsertSemicolon()) unexpected();
61276        }
61277
61278        function expect(type) {
61279          if (tokType === type) next();else unexpected();
61280        }
61281
61282        function unexpected() {
61283          raise(tokStart, "Unexpected token");
61284        }
61285
61286        function checkLVal(expr) {
61287          if (expr.type !== "Identifier" && expr.type !== "MemberExpression") raise(expr.start, "Assigning to rvalue");
61288          if (strict && expr.type === "Identifier" && isStrictBadIdWord(expr.name)) raise(expr.start, "Assigning to " + expr.name + " in strict mode");
61289        }
61290
61291        function parseTopLevel(program) {
61292          lastStart = lastEnd = tokPos;
61293          if (options.locations) lastEndLoc = new line_loc_t();
61294          inFunction = strict = null;
61295          labels = [];
61296          readToken();
61297          var node = program || startNode(),
61298              first = true;
61299          if (!program) node.body = [];
61300
61301          while (tokType !== _eof) {
61302            var stmt = parseStatement();
61303            node.body.push(stmt);
61304            if (first && isUseStrict(stmt)) setStrict(true);
61305            first = false;
61306          }
61307
61308          return finishNode(node, "Program");
61309        }
61310
61311        var loopLabel = {
61312          kind: "loop"
61313        },
61314            switchLabel = {
61315          kind: "switch"
61316        };
61317
61318        function parseStatement() {
61319          if (tokType === _slash || tokType === _assign && tokVal == "/=") readToken(true);
61320          var starttype = tokType,
61321              node = startNode();
61322
61323          switch (starttype) {
61324            case _break:
61325            case _continue:
61326              next();
61327              var isBreak = starttype === _break;
61328              if (eat(_semi) || canInsertSemicolon()) node.label = null;else if (tokType !== _name) unexpected();else {
61329                node.label = parseIdent();
61330                semicolon();
61331              }
61332
61333              for (var i = 0; i < labels.length; ++i) {
61334                var lab = labels[i];
61335
61336                if (node.label == null || lab.name === node.label.name) {
61337                  if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
61338                  if (node.label && isBreak) break;
61339                }
61340              }
61341
61342              if (i === labels.length) raise(node.start, "Unsyntactic " + starttype.keyword);
61343              return finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
61344
61345            case _debugger:
61346              next();
61347              semicolon();
61348              return finishNode(node, "DebuggerStatement");
61349
61350            case _do:
61351              next();
61352              labels.push(loopLabel);
61353              node.body = parseStatement();
61354              labels.pop();
61355              expect(_while);
61356              node.test = parseParenExpression();
61357              semicolon();
61358              return finishNode(node, "DoWhileStatement");
61359
61360            case _for:
61361              next();
61362              labels.push(loopLabel);
61363              expect(_parenL);
61364              if (tokType === _semi) return parseFor(node, null);
61365
61366              if (tokType === _var) {
61367                var init = startNode();
61368                next();
61369                parseVar(init, true);
61370                finishNode(init, "VariableDeclaration");
61371                if (init.declarations.length === 1 && eat(_in)) return parseForIn(node, init);
61372                return parseFor(node, init);
61373              }
61374
61375              var init = parseExpression(false, true);
61376
61377              if (eat(_in)) {
61378                checkLVal(init);
61379                return parseForIn(node, init);
61380              }
61381
61382              return parseFor(node, init);
61383
61384            case _function:
61385              next();
61386              return parseFunction(node, true);
61387
61388            case _if:
61389              next();
61390              node.test = parseParenExpression();
61391              node.consequent = parseStatement();
61392              node.alternate = eat(_else) ? parseStatement() : null;
61393              return finishNode(node, "IfStatement");
61394
61395            case _return:
61396              if (!inFunction && !options.allowReturnOutsideFunction) raise(tokStart, "'return' outside of function");
61397              next();
61398              if (eat(_semi) || canInsertSemicolon()) node.argument = null;else {
61399                node.argument = parseExpression();
61400                semicolon();
61401              }
61402              return finishNode(node, "ReturnStatement");
61403
61404            case _switch:
61405              next();
61406              node.discriminant = parseParenExpression();
61407              node.cases = [];
61408              expect(_braceL);
61409              labels.push(switchLabel);
61410
61411              for (var cur, sawDefault; tokType != _braceR;) {
61412                if (tokType === _case || tokType === _default) {
61413                  var isCase = tokType === _case;
61414                  if (cur) finishNode(cur, "SwitchCase");
61415                  node.cases.push(cur = startNode());
61416                  cur.consequent = [];
61417                  next();
61418                  if (isCase) cur.test = parseExpression();else {
61419                    if (sawDefault) raise(lastStart, "Multiple default clauses");
61420                    sawDefault = true;
61421                    cur.test = null;
61422                  }
61423                  expect(_colon);
61424                } else {
61425                  if (!cur) unexpected();
61426                  cur.consequent.push(parseStatement());
61427                }
61428              }
61429
61430              if (cur) finishNode(cur, "SwitchCase");
61431              next();
61432              labels.pop();
61433              return finishNode(node, "SwitchStatement");
61434
61435            case _throw:
61436              next();
61437              if (newline.test(input.slice(lastEnd, tokStart))) raise(lastEnd, "Illegal newline after throw");
61438              node.argument = parseExpression();
61439              semicolon();
61440              return finishNode(node, "ThrowStatement");
61441
61442            case _try:
61443              next();
61444              node.block = parseBlock();
61445              node.handler = null;
61446
61447              if (tokType === _catch) {
61448                var clause = startNode();
61449                next();
61450                expect(_parenL);
61451                clause.param = parseIdent();
61452                if (strict && isStrictBadIdWord(clause.param.name)) raise(clause.param.start, "Binding " + clause.param.name + " in strict mode");
61453                expect(_parenR);
61454                clause.guard = null;
61455                clause.body = parseBlock();
61456                node.handler = finishNode(clause, "CatchClause");
61457              }
61458
61459              node.guardedHandlers = empty;
61460              node.finalizer = eat(_finally) ? parseBlock() : null;
61461              if (!node.handler && !node.finalizer) raise(node.start, "Missing catch or finally clause");
61462              return finishNode(node, "TryStatement");
61463
61464            case _var:
61465              next();
61466              parseVar(node);
61467              semicolon();
61468              return finishNode(node, "VariableDeclaration");
61469
61470            case _while:
61471              next();
61472              node.test = parseParenExpression();
61473              labels.push(loopLabel);
61474              node.body = parseStatement();
61475              labels.pop();
61476              return finishNode(node, "WhileStatement");
61477
61478            case _with:
61479              if (strict) raise(tokStart, "'with' in strict mode");
61480              next();
61481              node.object = parseParenExpression();
61482              node.body = parseStatement();
61483              return finishNode(node, "WithStatement");
61484
61485            case _braceL:
61486              return parseBlock();
61487
61488            case _semi:
61489              next();
61490              return finishNode(node, "EmptyStatement");
61491
61492            default:
61493              var maybeName = tokVal,
61494                  expr = parseExpression();
61495
61496              if (starttype === _name && expr.type === "Identifier" && eat(_colon)) {
61497                for (var i = 0; i < labels.length; ++i) {
61498                  if (labels[i].name === maybeName) raise(expr.start, "Label '" + maybeName + "' is already declared");
61499                }
61500
61501                var kind = tokType.isLoop ? "loop" : tokType === _switch ? "switch" : null;
61502                labels.push({
61503                  name: maybeName,
61504                  kind: kind
61505                });
61506                node.body = parseStatement();
61507                labels.pop();
61508                node.label = expr;
61509                return finishNode(node, "LabeledStatement");
61510              } else {
61511                node.expression = expr;
61512                semicolon();
61513                return finishNode(node, "ExpressionStatement");
61514              }
61515
61516          }
61517        }
61518
61519        function parseParenExpression() {
61520          expect(_parenL);
61521          var val = parseExpression();
61522          expect(_parenR);
61523          return val;
61524        }
61525
61526        function parseBlock(allowStrict) {
61527          var node = startNode(),
61528              first = true,
61529              strict = false,
61530              oldStrict;
61531          node.body = [];
61532          expect(_braceL);
61533
61534          while (!eat(_braceR)) {
61535            var stmt = parseStatement();
61536            node.body.push(stmt);
61537
61538            if (first && allowStrict && isUseStrict(stmt)) {
61539              oldStrict = strict;
61540              setStrict(strict = true);
61541            }
61542
61543            first = false;
61544          }
61545
61546          if (strict && !oldStrict) setStrict(false);
61547          return finishNode(node, "BlockStatement");
61548        }
61549
61550        function parseFor(node, init) {
61551          node.init = init;
61552          expect(_semi);
61553          node.test = tokType === _semi ? null : parseExpression();
61554          expect(_semi);
61555          node.update = tokType === _parenR ? null : parseExpression();
61556          expect(_parenR);
61557          node.body = parseStatement();
61558          labels.pop();
61559          return finishNode(node, "ForStatement");
61560        }
61561
61562        function parseForIn(node, init) {
61563          node.left = init;
61564          node.right = parseExpression();
61565          expect(_parenR);
61566          node.body = parseStatement();
61567          labels.pop();
61568          return finishNode(node, "ForInStatement");
61569        }
61570
61571        function parseVar(node, noIn) {
61572          node.declarations = [];
61573          node.kind = "var";
61574
61575          for (;;) {
61576            var decl = startNode();
61577            decl.id = parseIdent();
61578            if (strict && isStrictBadIdWord(decl.id.name)) raise(decl.id.start, "Binding " + decl.id.name + " in strict mode");
61579            decl.init = eat(_eq) ? parseExpression(true, noIn) : null;
61580            node.declarations.push(finishNode(decl, "VariableDeclarator"));
61581            if (!eat(_comma)) break;
61582          }
61583
61584          return node;
61585        }
61586
61587        function parseExpression(noComma, noIn) {
61588          var expr = parseMaybeAssign(noIn);
61589
61590          if (!noComma && tokType === _comma) {
61591            var node = startNodeFrom(expr);
61592            node.expressions = [expr];
61593
61594            while (eat(_comma)) {
61595              node.expressions.push(parseMaybeAssign(noIn));
61596            }
61597
61598            return finishNode(node, "SequenceExpression");
61599          }
61600
61601          return expr;
61602        }
61603
61604        function parseMaybeAssign(noIn) {
61605          var left = parseMaybeConditional(noIn);
61606
61607          if (tokType.isAssign) {
61608            var node = startNodeFrom(left);
61609            node.operator = tokVal;
61610            node.left = left;
61611            next();
61612            node.right = parseMaybeAssign(noIn);
61613            checkLVal(left);
61614            return finishNode(node, "AssignmentExpression");
61615          }
61616
61617          return left;
61618        }
61619
61620        function parseMaybeConditional(noIn) {
61621          var expr = parseExprOps(noIn);
61622
61623          if (eat(_question)) {
61624            var node = startNodeFrom(expr);
61625            node.test = expr;
61626            node.consequent = parseExpression(true);
61627            expect(_colon);
61628            node.alternate = parseExpression(true, noIn);
61629            return finishNode(node, "ConditionalExpression");
61630          }
61631
61632          return expr;
61633        }
61634
61635        function parseExprOps(noIn) {
61636          return parseExprOp(parseMaybeUnary(), -1, noIn);
61637        }
61638
61639        function parseExprOp(left, minPrec, noIn) {
61640          var prec = tokType.binop;
61641
61642          if (prec != null && (!noIn || tokType !== _in)) {
61643            if (prec > minPrec) {
61644              var node = startNodeFrom(left);
61645              node.left = left;
61646              node.operator = tokVal;
61647              var op = tokType;
61648              next();
61649              node.right = parseExprOp(parseMaybeUnary(), prec, noIn);
61650              var exprNode = finishNode(node, op === _logicalOR || op === _logicalAND ? "LogicalExpression" : "BinaryExpression");
61651              return parseExprOp(exprNode, minPrec, noIn);
61652            }
61653          }
61654
61655          return left;
61656        }
61657
61658        function parseMaybeUnary() {
61659          if (tokType.prefix) {
61660            var node = startNode(),
61661                update = tokType.isUpdate;
61662            node.operator = tokVal;
61663            node.prefix = true;
61664            tokRegexpAllowed = true;
61665            next();
61666            node.argument = parseMaybeUnary();
61667            if (update) checkLVal(node.argument);else if (strict && node.operator === "delete" && node.argument.type === "Identifier") raise(node.start, "Deleting local variable in strict mode");
61668            return finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
61669          }
61670
61671          var expr = parseExprSubscripts();
61672
61673          while (tokType.postfix && !canInsertSemicolon()) {
61674            var node = startNodeFrom(expr);
61675            node.operator = tokVal;
61676            node.prefix = false;
61677            node.argument = expr;
61678            checkLVal(expr);
61679            next();
61680            expr = finishNode(node, "UpdateExpression");
61681          }
61682
61683          return expr;
61684        }
61685
61686        function parseExprSubscripts() {
61687          return parseSubscripts(parseExprAtom());
61688        }
61689
61690        function parseSubscripts(base, noCalls) {
61691          if (eat(_dot)) {
61692            var node = startNodeFrom(base);
61693            node.object = base;
61694            node.property = parseIdent(true);
61695            node.computed = false;
61696            return parseSubscripts(finishNode(node, "MemberExpression"), noCalls);
61697          } else if (eat(_bracketL)) {
61698            var node = startNodeFrom(base);
61699            node.object = base;
61700            node.property = parseExpression();
61701            node.computed = true;
61702            expect(_bracketR);
61703            return parseSubscripts(finishNode(node, "MemberExpression"), noCalls);
61704          } else if (!noCalls && eat(_parenL)) {
61705            var node = startNodeFrom(base);
61706            node.callee = base;
61707            node.arguments = parseExprList(_parenR, false);
61708            return parseSubscripts(finishNode(node, "CallExpression"), noCalls);
61709          } else return base;
61710        }
61711
61712        function parseExprAtom() {
61713          switch (tokType) {
61714            case _this:
61715              var node = startNode();
61716              next();
61717              return finishNode(node, "ThisExpression");
61718
61719            case _name:
61720              return parseIdent();
61721
61722            case _num:
61723            case _string:
61724            case _regexp:
61725              var node = startNode();
61726              node.value = tokVal;
61727              node.raw = input.slice(tokStart, tokEnd);
61728              next();
61729              return finishNode(node, "Literal");
61730
61731            case _null:
61732            case _true:
61733            case _false:
61734              var node = startNode();
61735              node.value = tokType.atomValue;
61736              node.raw = tokType.keyword;
61737              next();
61738              return finishNode(node, "Literal");
61739
61740            case _parenL:
61741              var tokStartLoc1 = tokStartLoc,
61742                  tokStart1 = tokStart;
61743              next();
61744              var val = parseExpression();
61745              val.start = tokStart1;
61746              val.end = tokEnd;
61747
61748              if (options.locations) {
61749                val.loc.start = tokStartLoc1;
61750                val.loc.end = tokEndLoc;
61751              }
61752
61753              if (options.ranges) val.range = [tokStart1, tokEnd];
61754              expect(_parenR);
61755              return val;
61756
61757            case _bracketL:
61758              var node = startNode();
61759              next();
61760              node.elements = parseExprList(_bracketR, true, true);
61761              return finishNode(node, "ArrayExpression");
61762
61763            case _braceL:
61764              return parseObj();
61765
61766            case _function:
61767              var node = startNode();
61768              next();
61769              return parseFunction(node, false);
61770
61771            case _new:
61772              return parseNew();
61773
61774            default:
61775              unexpected();
61776          }
61777        }
61778
61779        function parseNew() {
61780          var node = startNode();
61781          next();
61782          node.callee = parseSubscripts(parseExprAtom(), true);
61783          if (eat(_parenL)) node.arguments = parseExprList(_parenR, false);else node.arguments = empty;
61784          return finishNode(node, "NewExpression");
61785        }
61786
61787        function parseObj() {
61788          var node = startNode(),
61789              first = true,
61790              sawGetSet = false;
61791          node.properties = [];
61792          next();
61793
61794          while (!eat(_braceR)) {
61795            if (!first) {
61796              expect(_comma);
61797              if (options.allowTrailingCommas && eat(_braceR)) break;
61798            } else first = false;
61799
61800            var prop = {
61801              key: parsePropertyName()
61802            },
61803                isGetSet = false,
61804                kind;
61805
61806            if (eat(_colon)) {
61807              prop.value = parseExpression(true);
61808              kind = prop.kind = "init";
61809            } else if (options.ecmaVersion >= 5 && prop.key.type === "Identifier" && (prop.key.name === "get" || prop.key.name === "set")) {
61810              isGetSet = sawGetSet = true;
61811              kind = prop.kind = prop.key.name;
61812              prop.key = parsePropertyName();
61813              if (tokType !== _parenL) unexpected();
61814              prop.value = parseFunction(startNode(), false);
61815            } else unexpected();
61816
61817            if (prop.key.type === "Identifier" && (strict || sawGetSet)) {
61818              for (var i = 0; i < node.properties.length; ++i) {
61819                var other = node.properties[i];
61820
61821                if (other.key.name === prop.key.name) {
61822                  var conflict = kind == other.kind || isGetSet && other.kind === "init" || kind === "init" && (other.kind === "get" || other.kind === "set");
61823                  if (conflict && !strict && kind === "init" && other.kind === "init") conflict = false;
61824                  if (conflict) raise(prop.key.start, "Redefinition of property");
61825                }
61826              }
61827            }
61828
61829            node.properties.push(prop);
61830          }
61831
61832          return finishNode(node, "ObjectExpression");
61833        }
61834
61835        function parsePropertyName() {
61836          if (tokType === _num || tokType === _string) return parseExprAtom();
61837          return parseIdent(true);
61838        }
61839
61840        function parseFunction(node, isStatement) {
61841          if (tokType === _name) node.id = parseIdent();else if (isStatement) unexpected();else node.id = null;
61842          node.params = [];
61843          var first = true;
61844          expect(_parenL);
61845
61846          while (!eat(_parenR)) {
61847            if (!first) expect(_comma);else first = false;
61848            node.params.push(parseIdent());
61849          }
61850
61851          var oldInFunc = inFunction,
61852              oldLabels = labels;
61853          inFunction = true;
61854          labels = [];
61855          node.body = parseBlock(true);
61856          inFunction = oldInFunc;
61857          labels = oldLabels;
61858
61859          if (strict || node.body.body.length && isUseStrict(node.body.body[0])) {
61860            for (var i = node.id ? -1 : 0; i < node.params.length; ++i) {
61861              var id = i < 0 ? node.id : node.params[i];
61862              if (isStrictReservedWord(id.name) || isStrictBadIdWord(id.name)) raise(id.start, "Defining '" + id.name + "' in strict mode");
61863              if (i >= 0) for (var j = 0; j < i; ++j) {
61864                if (id.name === node.params[j].name) raise(id.start, "Argument name clash in strict mode");
61865              }
61866            }
61867          }
61868
61869          return finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
61870        }
61871
61872        function parseExprList(close, allowTrailingComma, allowEmpty) {
61873          var elts = [],
61874              first = true;
61875
61876          while (!eat(close)) {
61877            if (!first) {
61878              expect(_comma);
61879              if (allowTrailingComma && options.allowTrailingCommas && eat(close)) break;
61880            } else first = false;
61881
61882            if (allowEmpty && tokType === _comma) elts.push(null);else elts.push(parseExpression(true));
61883          }
61884
61885          return elts;
61886        }
61887
61888        function parseIdent(liberal) {
61889          var node = startNode();
61890          if (liberal && options.forbidReserved == "everywhere") liberal = false;
61891
61892          if (tokType === _name) {
61893            if (!liberal && (options.forbidReserved && (options.ecmaVersion === 3 ? isReservedWord3 : isReservedWord5)(tokVal) || strict && isStrictReservedWord(tokVal)) && input.slice(tokStart, tokEnd).indexOf("\\") == -1) raise(tokStart, "The keyword '" + tokVal + "' is reserved");
61894            node.name = tokVal;
61895          } else if (liberal && tokType.keyword) {
61896            node.name = tokType.keyword;
61897          } else {
61898            unexpected();
61899          }
61900
61901          tokRegexpAllowed = false;
61902          next();
61903          return finishNode(node, "Identifier");
61904        }
61905      });
61906
61907      if (!acorn.version) acorn = null;
61908    }
61909
61910    function parse(code, options) {
61911      return (global.acorn || acorn).parse(code, options);
61912    }
61913
61914    var binaryOperators = {
61915      '+': '__add',
61916      '-': '__subtract',
61917      '*': '__multiply',
61918      '/': '__divide',
61919      '%': '__modulo',
61920      '==': '__equals',
61921      '!=': '__equals'
61922    };
61923    var unaryOperators = {
61924      '-': '__negate',
61925      '+': '__self'
61926    };
61927    var fields = Base.each(['add', 'subtract', 'multiply', 'divide', 'modulo', 'equals', 'negate'], function (name) {
61928      this['__' + name] = '#' + name;
61929    }, {
61930      __self: function __self() {
61931        return this;
61932      }
61933    });
61934    Point.inject(fields);
61935    Size.inject(fields);
61936    Color.inject(fields);
61937
61938    function __$__(left, operator, right) {
61939      var handler = binaryOperators[operator];
61940
61941      if (left && left[handler]) {
61942        var res = left[handler](right);
61943        return operator === '!=' ? !res : res;
61944      }
61945
61946      switch (operator) {
61947        case '+':
61948          return left + right;
61949
61950        case '-':
61951          return left - right;
61952
61953        case '*':
61954          return left * right;
61955
61956        case '/':
61957          return left / right;
61958
61959        case '%':
61960          return left % right;
61961
61962        case '==':
61963          return left == right;
61964
61965        case '!=':
61966          return left != right;
61967      }
61968    }
61969
61970    function $__(operator, value) {
61971      var handler = unaryOperators[operator];
61972      if (value && value[handler]) return value[handler]();
61973
61974      switch (operator) {
61975        case '+':
61976          return +value;
61977
61978        case '-':
61979          return -value;
61980      }
61981    }
61982
61983    function compile(code, options) {
61984      if (!code) return '';
61985      options = options || {};
61986      var insertions = [];
61987
61988      function getOffset(offset) {
61989        for (var i = 0, l = insertions.length; i < l; i++) {
61990          var insertion = insertions[i];
61991          if (insertion[0] >= offset) break;
61992          offset += insertion[1];
61993        }
61994
61995        return offset;
61996      }
61997
61998      function getCode(node) {
61999        return code.substring(getOffset(node.range[0]), getOffset(node.range[1]));
62000      }
62001
62002      function getBetween(left, right) {
62003        return code.substring(getOffset(left.range[1]), getOffset(right.range[0]));
62004      }
62005
62006      function replaceCode(node, str) {
62007        var start = getOffset(node.range[0]),
62008            end = getOffset(node.range[1]),
62009            insert = 0;
62010
62011        for (var i = insertions.length - 1; i >= 0; i--) {
62012          if (start > insertions[i][0]) {
62013            insert = i + 1;
62014            break;
62015          }
62016        }
62017
62018        insertions.splice(insert, 0, [start, str.length - end + start]);
62019        code = code.substring(0, start) + str + code.substring(end);
62020      }
62021
62022      function walkAST(node, parent) {
62023        if (!node) return;
62024
62025        for (var key in node) {
62026          if (key === 'range' || key === 'loc') continue;
62027          var value = node[key];
62028
62029          if (Array.isArray(value)) {
62030            for (var i = 0, l = value.length; i < l; i++) {
62031              walkAST(value[i], node);
62032            }
62033          } else if (value && _typeof(value) === 'object') {
62034            walkAST(value, node);
62035          }
62036        }
62037
62038        switch (node.type) {
62039          case 'UnaryExpression':
62040            if (node.operator in unaryOperators && node.argument.type !== 'Literal') {
62041              var arg = getCode(node.argument);
62042              replaceCode(node, '$__("' + node.operator + '", ' + arg + ')');
62043            }
62044
62045            break;
62046
62047          case 'BinaryExpression':
62048            if (node.operator in binaryOperators && node.left.type !== 'Literal') {
62049              var left = getCode(node.left),
62050                  right = getCode(node.right),
62051                  between = getBetween(node.left, node.right),
62052                  operator = node.operator;
62053              replaceCode(node, '__$__(' + left + ',' + between.replace(new RegExp('\\' + operator), '"' + operator + '"') + ', ' + right + ')');
62054            }
62055
62056            break;
62057
62058          case 'UpdateExpression':
62059          case 'AssignmentExpression':
62060            var parentType = parent && parent.type;
62061
62062            if (!(parentType === 'ForStatement' || parentType === 'BinaryExpression' && /^[=!<>]/.test(parent.operator) || parentType === 'MemberExpression' && parent.computed)) {
62063              if (node.type === 'UpdateExpression') {
62064                var arg = getCode(node.argument),
62065                    exp = '__$__(' + arg + ', "' + node.operator[0] + '", 1)',
62066                    str = arg + ' = ' + exp;
62067
62068                if (node.prefix) {
62069                  str = '(' + str + ')';
62070                } else if (parentType === 'AssignmentExpression' || parentType === 'VariableDeclarator' || parentType === 'BinaryExpression') {
62071                  if (getCode(parent.left || parent.id) === arg) str = exp;
62072                  str = arg + '; ' + str;
62073                }
62074
62075                replaceCode(node, str);
62076              } else {
62077                if (/^.=$/.test(node.operator) && node.left.type !== 'Literal') {
62078                  var left = getCode(node.left),
62079                      right = getCode(node.right),
62080                      exp = left + ' = __$__(' + left + ', "' + node.operator[0] + '", ' + right + ')';
62081                  replaceCode(node, /^\(.*\)$/.test(getCode(node)) ? '(' + exp + ')' : exp);
62082                }
62083              }
62084            }
62085
62086            break;
62087
62088          case 'ExportDefaultDeclaration':
62089            replaceCode({
62090              range: [node.start, node.declaration.start]
62091            }, 'module.exports = ');
62092            break;
62093
62094          case 'ExportNamedDeclaration':
62095            var declaration = node.declaration;
62096            var specifiers = node.specifiers;
62097
62098            if (declaration) {
62099              var declarations = declaration.declarations;
62100
62101              if (declarations) {
62102                declarations.forEach(function (dec) {
62103                  replaceCode(dec, 'module.exports.' + getCode(dec));
62104                });
62105                replaceCode({
62106                  range: [node.start, declaration.start + declaration.kind.length]
62107                }, '');
62108              }
62109            } else if (specifiers) {
62110              var exports = specifiers.map(function (specifier) {
62111                var name = getCode(specifier);
62112                return 'module.exports.' + name + ' = ' + name + '; ';
62113              }).join('');
62114
62115              if (exports) {
62116                replaceCode(node, exports);
62117              }
62118            }
62119
62120            break;
62121        }
62122      }
62123
62124      function encodeVLQ(value) {
62125        var res = '',
62126            base64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
62127        value = (Math.abs(value) << 1) + (value < 0 ? 1 : 0);
62128
62129        while (value || !res) {
62130          var next = value & 32 - 1;
62131          value >>= 5;
62132          if (value) next |= 32;
62133          res += base64[next];
62134        }
62135
62136        return res;
62137      }
62138
62139      var url = options.url || '',
62140          agent = paper.agent,
62141          version = agent.versionNumber,
62142          offsetCode = false,
62143          sourceMaps = options.sourceMaps,
62144          source = options.source || code,
62145          lineBreaks = /\r\n|\n|\r/mg,
62146          offset = options.offset || 0,
62147          map;
62148
62149      if (sourceMaps && (agent.chrome && version >= 30 || agent.webkit && version >= 537.76 || agent.firefox && version >= 23 || agent.node)) {
62150        if (agent.node) {
62151          offset -= 2;
62152        } else if (window && url && !window.location.href.indexOf(url)) {
62153          var html = document.getElementsByTagName('html')[0].innerHTML;
62154          offset = html.substr(0, html.indexOf(code) + 1).match(lineBreaks).length + 1;
62155        }
62156
62157        offsetCode = offset > 0 && !(agent.chrome && version >= 36 || agent.safari && version >= 600 || agent.firefox && version >= 40 || agent.node);
62158        var mappings = ['AA' + encodeVLQ(offsetCode ? 0 : offset) + 'A'];
62159        mappings.length = (code.match(lineBreaks) || []).length + 1 + (offsetCode ? offset : 0);
62160        map = {
62161          version: 3,
62162          file: url,
62163          names: [],
62164          mappings: mappings.join(';AACA'),
62165          sourceRoot: '',
62166          sources: [url],
62167          sourcesContent: [source]
62168        };
62169      }
62170
62171      walkAST(parse(code, {
62172        ranges: true,
62173        preserveParens: true,
62174        sourceType: 'module'
62175      }));
62176
62177      if (map) {
62178        if (offsetCode) {
62179          code = new Array(offset + 1).join('\n') + code;
62180        }
62181
62182        if (/^(inline|both)$/.test(sourceMaps)) {// code += "\n
62183          // 		+ self.btoa(unescape(encodeURIComponent(
62184          // 			JSON.stringify(map))));
62185        }
62186
62187        code += "\n//# sourceURL=" + (url || 'paperscript');
62188      }
62189
62190      return {
62191        url: url,
62192        source: source,
62193        code: code,
62194        map: map
62195      };
62196    }
62197
62198    function execute(code, scope, options) {
62199      paper = scope;
62200      var view = scope.getView(),
62201          tool = /\btool\.\w+|\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/.test(code) && !/\bnew\s+Tool\b/.test(code) ? new Tool() : null,
62202          toolHandlers = tool ? tool._events : [],
62203          handlers = ['onFrame', 'onResize'].concat(toolHandlers),
62204          params = [],
62205          args = [],
62206          func,
62207          compiled = _typeof(code) === 'object' ? code : compile(code, options);
62208      code = compiled.code;
62209
62210      function expose(scope, hidden) {
62211        for (var key in scope) {
62212          if ((hidden || !/^_/.test(key)) && new RegExp('([\\b\\s\\W]|^)' + key.replace(/\$/g, '\\$') + '\\b').test(code)) {
62213            params.push(key);
62214            args.push(scope[key]);
62215          }
62216        }
62217      }
62218
62219      expose({
62220        __$__: __$__,
62221        $__: $__,
62222        paper: scope,
62223        tool: tool
62224      }, true);
62225      expose(scope);
62226      code = 'var module = { exports: {} }; ' + code;
62227      var exports = Base.each(handlers, function (key) {
62228        if (new RegExp('\\s+' + key + '\\b').test(code)) {
62229          params.push(key);
62230          this.push('module.exports.' + key + ' = ' + key + ';');
62231        }
62232      }, []).join('\n');
62233
62234      if (exports) {
62235        code += '\n' + exports;
62236      }
62237
62238      code += '\nreturn module.exports;';
62239      var agent = paper.agent;
62240
62241      if (document && (agent.chrome || agent.firefox && agent.versionNumber < 40)) {
62242        var script = document.createElement('script'),
62243            head = document.head || document.getElementsByTagName('head')[0];
62244        if (agent.firefox) code = '\n' + code;
62245        script.appendChild(document.createTextNode('document.__paperscript__ = function(' + params + ') {' + code + '\n}'));
62246        head.appendChild(script);
62247        func = document.__paperscript__;
62248        delete document.__paperscript__;
62249        head.removeChild(script);
62250      } else {
62251        func = Function(params, code);
62252      }
62253
62254      var exports = func && func.apply(scope, args);
62255      var obj = exports || {};
62256      Base.each(toolHandlers, function (key) {
62257        var value = obj[key];
62258        if (value) tool[key] = value;
62259      });
62260
62261      if (view) {
62262        if (obj.onResize) view.setOnResize(obj.onResize);
62263        view.emit('resize', {
62264          size: view.size,
62265          delta: new Point()
62266        });
62267        if (obj.onFrame) view.setOnFrame(obj.onFrame);
62268        view.requestUpdate();
62269      }
62270
62271      return exports;
62272    }
62273
62274    function loadScript(script) {
62275      if (/^text\/(?:x-|)paperscript$/.test(script.type) && PaperScope.getAttribute(script, 'ignore') !== 'true') {
62276        var canvasId = PaperScope.getAttribute(script, 'canvas'),
62277            canvas = document.getElementById(canvasId),
62278            src = script.src || script.getAttribute('data-src'),
62279            async = PaperScope.hasAttribute(script, 'async'),
62280            scopeAttribute = 'data-paper-scope';
62281        if (!canvas) throw new Error('Unable to find canvas with id "' + canvasId + '"');
62282        var scope = PaperScope.get(canvas.getAttribute(scopeAttribute)) || new PaperScope().setup(canvas);
62283        canvas.setAttribute(scopeAttribute, scope._id);
62284
62285        if (src) {
62286          Http.request({
62287            url: src,
62288            async: async,
62289            mimeType: 'text/plain',
62290            onLoad: function onLoad(code) {
62291              execute(code, scope, src);
62292            }
62293          });
62294        } else {
62295          execute(script.innerHTML, scope, script.baseURI);
62296        }
62297
62298        script.setAttribute('data-paper-ignore', 'true');
62299        return scope;
62300      }
62301    }
62302
62303    function loadAll() {
62304      Base.each(document && document.getElementsByTagName('script'), loadScript);
62305    }
62306
62307    function load(script) {
62308      return script ? loadScript(script) : loadAll();
62309    }
62310
62311    if (window) {
62312      if (document.readyState === 'complete') {
62313        setTimeout(loadAll);
62314      } else {
62315        DomEvent.add(window, {
62316          load: loadAll
62317        });
62318      }
62319    }
62320
62321    return {
62322      compile: compile,
62323      execute: execute,
62324      load: load,
62325      parse: parse,
62326      calculateBinary: __$__,
62327      calculateUnary: $__
62328    };
62329  }.call(this);
62330
62331  var paper = new (PaperScope.inject(Base.exports, {
62332    Base: Base,
62333    Numerical: Numerical,
62334    Key: Key,
62335    DomEvent: DomEvent,
62336    DomElement: DomElement,
62337    document: document,
62338    window: window,
62339    Symbol: SymbolDefinition,
62340    PlacedSymbol: SymbolItem
62341  }))();
62342
62343  if (paper.agent.node) {
62344    require('./node/extend.js')(paper);
62345  }
62346
62347  if (typeof define === 'function' && define.amd) {
62348    define('paper', paper);
62349  } else if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === 'object' && module) {
62350    module.exports = paper;
62351  }
62352
62353  return paper;
62354}.call(this, (typeof self === "undefined" ? "undefined" : _typeof(self)) === 'object' ? self : null);
62355},{"./node/self.js":"node_modules/parcel-bundler/src/builtins/_empty.js","acorn":"node_modules/acorn/dist/acorn.mjs","./node/extend.js":"node_modules/parcel-bundler/src/builtins/_empty.js","process":"node_modules/process/browser.js"}],"node_modules/dat.gui/build/dat.gui.module.js":[function(require,module,exports) {
62356"use strict";
62357
62358Object.defineProperty(exports, "__esModule", {
62359  value: true
62360});
vendor: 57,216 bytes, lines 62361-64251
62361exports.default = exports.GUI = exports.gui = exports.dom = exports.controllers = exports.color = void 0;
62362
62363/**
62364 * dat-gui JavaScript Controller Library
62365 * http://code.google.com/p/dat-gui
62366 *
62367 * Copyright 2011 Data Arts Team, Google Creative Lab
62368 *
62369 * Licensed under the Apache License, Version 2.0 (the "License");
62370 * you may not use this file except in compliance with the License.
62371 * You may obtain a copy of the License at
62372 *
62373 * http://www.apache.org/licenses/LICENSE-2.0
62374 */
62375function ___$insertStyle(css) {
62376  if (!css) {
62377    return;
62378  }
62379
62380  if (typeof window === 'undefined') {
62381    return;
62382  }
62383
62384  var style = document.createElement('style');
62385  style.setAttribute('type', 'text/css');
62386  style.innerHTML = css;
62387  document.head.appendChild(style);
62388  return css;
62389}
62390
62391function colorToString(color, forceCSSHex) {
62392  var colorFormat = color.__state.conversionName.toString();
62393
62394  var r = Math.round(color.r);
62395  var g = Math.round(color.g);
62396  var b = Math.round(color.b);
62397  var a = color.a;
62398  var h = Math.round(color.h);
62399  var s = color.s.toFixed(1);
62400  var v = color.v.toFixed(1);
62401
62402  if (forceCSSHex || colorFormat === 'THREE_CHAR_HEX' || colorFormat === 'SIX_CHAR_HEX') {
62403    var str = color.hex.toString(16);
62404
62405    while (str.length < 6) {
62406      str = '0' + str;
62407    }
62408
62409    return '#' + str;
62410  } else if (colorFormat === 'CSS_RGB') {
62411    return 'rgb(' + r + ',' + g + ',' + b + ')';
62412  } else if (colorFormat === 'CSS_RGBA') {
62413    return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
62414  } else if (colorFormat === 'HEX') {
62415    return '0x' + color.hex.toString(16);
62416  } else if (colorFormat === 'RGB_ARRAY') {
62417    return '[' + r + ',' + g + ',' + b + ']';
62418  } else if (colorFormat === 'RGBA_ARRAY') {
62419    return '[' + r + ',' + g + ',' + b + ',' + a + ']';
62420  } else if (colorFormat === 'RGB_OBJ') {
62421    return '{r:' + r + ',g:' + g + ',b:' + b + '}';
62422  } else if (colorFormat === 'RGBA_OBJ') {
62423    return '{r:' + r + ',g:' + g + ',b:' + b + ',a:' + a + '}';
62424  } else if (colorFormat === 'HSV_OBJ') {
62425    return '{h:' + h + ',s:' + s + ',v:' + v + '}';
62426  } else if (colorFormat === 'HSVA_OBJ') {
62427    return '{h:' + h + ',s:' + s + ',v:' + v + ',a:' + a + '}';
62428  }
62429
62430  return 'unknown format';
62431}
62432
62433var ARR_EACH = Array.prototype.forEach;
62434var ARR_SLICE = Array.prototype.slice;
62435var Common = {
62436  BREAK: {},
62437  extend: function extend(target) {
62438    this.each(ARR_SLICE.call(arguments, 1), function (obj) {
62439      var keys = this.isObject(obj) ? Object.keys(obj) : [];
62440      keys.forEach(function (key) {
62441        if (!this.isUndefined(obj[key])) {
62442          target[key] = obj[key];
62443        }
62444      }.bind(this));
62445    }, this);
62446    return target;
62447  },
62448  defaults: function defaults(target) {
62449    this.each(ARR_SLICE.call(arguments, 1), function (obj) {
62450      var keys = this.isObject(obj) ? Object.keys(obj) : [];
62451      keys.forEach(function (key) {
62452        if (this.isUndefined(target[key])) {
62453          target[key] = obj[key];
62454        }
62455      }.bind(this));
62456    }, this);
62457    return target;
62458  },
62459  compose: function compose() {
62460    var toCall = ARR_SLICE.call(arguments);
62461    return function () {
62462      var args = ARR_SLICE.call(arguments);
62463
62464      for (var i = toCall.length - 1; i >= 0; i--) {
62465        args = [toCall[i].apply(this, args)];
62466      }
62467
62468      return args[0];
62469    };
62470  },
62471  each: function each(obj, itr, scope) {
62472    if (!obj) {
62473      return;
62474    }
62475
62476    if (ARR_EACH && obj.forEach && obj.forEach === ARR_EACH) {
62477      obj.forEach(itr, scope);
62478    } else if (obj.length === obj.length + 0) {
62479      var key = void 0;
62480      var l = void 0;
62481
62482      for (key = 0, l = obj.length; key < l; key++) {
62483        if (key in obj && itr.call(scope, obj[key], key) === this.BREAK) {
62484          return;
62485        }
62486      }
62487    } else {
62488      for (var _key in obj) {
62489        if (itr.call(scope, obj[_key], _key) === this.BREAK) {
62490          return;
62491        }
62492      }
62493    }
62494  },
62495  defer: function defer(fnc) {
62496    setTimeout(fnc, 0);
62497  },
62498  debounce: function debounce(func, threshold, callImmediately) {
62499    var timeout = void 0;
62500    return function () {
62501      var obj = this;
62502      var args = arguments;
62503
62504      function delayed() {
62505        timeout = null;
62506        if (!callImmediately) func.apply(obj, args);
62507      }
62508
62509      var callNow = callImmediately || !timeout;
62510      clearTimeout(timeout);
62511      timeout = setTimeout(delayed, threshold);
62512
62513      if (callNow) {
62514        func.apply(obj, args);
62515      }
62516    };
62517  },
62518  toArray: function toArray(obj) {
62519    if (obj.toArray) return obj.toArray();
62520    return ARR_SLICE.call(obj);
62521  },
62522  isUndefined: function isUndefined(obj) {
62523    return obj === undefined;
62524  },
62525  isNull: function isNull(obj) {
62526    return obj === null;
62527  },
62528  isNaN: function (_isNaN) {
62529    function isNaN(_x) {
62530      return _isNaN.apply(this, arguments);
62531    }
62532
62533    isNaN.toString = function () {
62534      return _isNaN.toString();
62535    };
62536
62537    return isNaN;
62538  }(function (obj) {
62539    return isNaN(obj);
62540  }),
62541  isArray: Array.isArray || function (obj) {
62542    return obj.constructor === Array;
62543  },
62544  isObject: function isObject(obj) {
62545    return obj === Object(obj);
62546  },
62547  isNumber: function isNumber(obj) {
62548    return obj === obj + 0;
62549  },
62550  isString: function isString(obj) {
62551    return obj === obj + '';
62552  },
62553  isBoolean: function isBoolean(obj) {
62554    return obj === false || obj === true;
62555  },
62556  isFunction: function isFunction(obj) {
62557    return Object.prototype.toString.call(obj) === '[object Function]';
62558  }
62559};
62560var INTERPRETATIONS = [{
62561  litmus: Common.isString,
62562  conversions: {
62563    THREE_CHAR_HEX: {
62564      read: function read(original) {
62565        var test = original.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);
62566
62567        if (test === null) {
62568          return false;
62569        }
62570
62571        return {
62572          space: 'HEX',
62573          hex: parseInt('0x' + test[1].toString() + test[1].toString() + test[2].toString() + test[2].toString() + test[3].toString() + test[3].toString(), 0)
62574        };
62575      },
62576      write: colorToString
62577    },
62578    SIX_CHAR_HEX: {
62579      read: function read(original) {
62580        var test = original.match(/^#([A-F0-9]{6})$/i);
62581
62582        if (test === null) {
62583          return false;
62584        }
62585
62586        return {
62587          space: 'HEX',
62588          hex: parseInt('0x' + test[1].toString(), 0)
62589        };
62590      },
62591      write: colorToString
62592    },
62593    CSS_RGB: {
62594      read: function read(original) {
62595        var test = original.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);
62596
62597        if (test === null) {
62598          return false;
62599        }
62600
62601        return {
62602          space: 'RGB',
62603          r: parseFloat(test[1]),
62604          g: parseFloat(test[2]),
62605          b: parseFloat(test[3])
62606        };
62607      },
62608      write: colorToString
62609    },
62610    CSS_RGBA: {
62611      read: function read(original) {
62612        var test = original.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);
62613
62614        if (test === null) {
62615          return false;
62616        }
62617
62618        return {
62619          space: 'RGB',
62620          r: parseFloat(test[1]),
62621          g: parseFloat(test[2]),
62622          b: parseFloat(test[3]),
62623          a: parseFloat(test[4])
62624        };
62625      },
62626      write: colorToString
62627    }
62628  }
62629}, {
62630  litmus: Common.isNumber,
62631  conversions: {
62632    HEX: {
62633      read: function read(original) {
62634        return {
62635          space: 'HEX',
62636          hex: original,
62637          conversionName: 'HEX'
62638        };
62639      },
62640      write: function write(color) {
62641        return color.hex;
62642      }
62643    }
62644  }
62645}, {
62646  litmus: Common.isArray,
62647  conversions: {
62648    RGB_ARRAY: {
62649      read: function read(original) {
62650        if (original.length !== 3) {
62651          return false;
62652        }
62653
62654        return {
62655          space: 'RGB',
62656          r: original[0],
62657          g: original[1],
62658          b: original[2]
62659        };
62660      },
62661      write: function write(color) {
62662        return [color.r, color.g, color.b];
62663      }
62664    },
62665    RGBA_ARRAY: {
62666      read: function read(original) {
62667        if (original.length !== 4) return false;
62668        return {
62669          space: 'RGB',
62670          r: original[0],
62671          g: original[1],
62672          b: original[2],
62673          a: original[3]
62674        };
62675      },
62676      write: function write(color) {
62677        return [color.r, color.g, color.b, color.a];
62678      }
62679    }
62680  }
62681}, {
62682  litmus: Common.isObject,
62683  conversions: {
62684    RGBA_OBJ: {
62685      read: function read(original) {
62686        if (Common.isNumber(original.r) && Common.isNumber(original.g) && Common.isNumber(original.b) && Common.isNumber(original.a)) {
62687          return {
62688            space: 'RGB',
62689            r: original.r,
62690            g: original.g,
62691            b: original.b,
62692            a: original.a
62693          };
62694        }
62695
62696        return false;
62697      },
62698      write: function write(color) {
62699        return {
62700          r: color.r,
62701          g: color.g,
62702          b: color.b,
62703          a: color.a
62704        };
62705      }
62706    },
62707    RGB_OBJ: {
62708      read: function read(original) {
62709        if (Common.isNumber(original.r) && Common.isNumber(original.g) && Common.isNumber(original.b)) {
62710          return {
62711            space: 'RGB',
62712            r: original.r,
62713            g: original.g,
62714            b: original.b
62715          };
62716        }
62717
62718        return false;
62719      },
62720      write: function write(color) {
62721        return {
62722          r: color.r,
62723          g: color.g,
62724          b: color.b
62725        };
62726      }
62727    },
62728    HSVA_OBJ: {
62729      read: function read(original) {
62730        if (Common.isNumber(original.h) && Common.isNumber(original.s) && Common.isNumber(original.v) && Common.isNumber(original.a)) {
62731          return {
62732            space: 'HSV',
62733            h: original.h,
62734            s: original.s,
62735            v: original.v,
62736            a: original.a
62737          };
62738        }
62739
62740        return false;
62741      },
62742      write: function write(color) {
62743        return {
62744          h: color.h,
62745          s: color.s,
62746          v: color.v,
62747          a: color.a
62748        };
62749      }
62750    },
62751    HSV_OBJ: {
62752      read: function read(original) {
62753        if (Common.isNumber(original.h) && Common.isNumber(original.s) && Common.isNumber(original.v)) {
62754          return {
62755            space: 'HSV',
62756            h: original.h,
62757            s: original.s,
62758            v: original.v
62759          };
62760        }
62761
62762        return false;
62763      },
62764      write: function write(color) {
62765        return {
62766          h: color.h,
62767          s: color.s,
62768          v: color.v
62769        };
62770      }
62771    }
62772  }
62773}];
62774var result = void 0;
62775var toReturn = void 0;
62776
62777var interpret = function interpret() {
62778  toReturn = false;
62779  var original = arguments.length > 1 ? Common.toArray(arguments) : arguments[0];
62780  Common.each(INTERPRETATIONS, function (family) {
62781    if (family.litmus(original)) {
62782      Common.each(family.conversions, function (conversion, conversionName) {
62783        result = conversion.read(original);
62784
62785        if (toReturn === false && result !== false) {
62786          toReturn = result;
62787          result.conversionName = conversionName;
62788          result.conversion = conversion;
62789          return Common.BREAK;
62790        }
62791      });
62792      return Common.BREAK;
62793    }
62794  });
62795  return toReturn;
62796};
62797
62798var tmpComponent = void 0;
62799var ColorMath = {
62800  hsv_to_rgb: function hsv_to_rgb(h, s, v) {
62801    var hi = Math.floor(h / 60) % 6;
62802    var f = h / 60 - Math.floor(h / 60);
62803    var p = v * (1.0 - s);
62804    var q = v * (1.0 - f * s);
62805    var t = v * (1.0 - (1.0 - f) * s);
62806    var c = [[v, t, p], [q, v, p], [p, v, t], [p, q, v], [t, p, v], [v, p, q]][hi];
62807    return {
62808      r: c[0] * 255,
62809      g: c[1] * 255,
62810      b: c[2] * 255
62811    };
62812  },
62813  rgb_to_hsv: function rgb_to_hsv(r, g, b) {
62814    var min = Math.min(r, g, b);
62815    var max = Math.max(r, g, b);
62816    var delta = max - min;
62817    var h = void 0;
62818    var s = void 0;
62819
62820    if (max !== 0) {
62821      s = delta / max;
62822    } else {
62823      return {
62824        h: NaN,
62825        s: 0,
62826        v: 0
62827      };
62828    }
62829
62830    if (r === max) {
62831      h = (g - b) / delta;
62832    } else if (g === max) {
62833      h = 2 + (b - r) / delta;
62834    } else {
62835      h = 4 + (r - g) / delta;
62836    }
62837
62838    h /= 6;
62839
62840    if (h < 0) {
62841      h += 1;
62842    }
62843
62844    return {
62845      h: h * 360,
62846      s: s,
62847      v: max / 255
62848    };
62849  },
62850  rgb_to_hex: function rgb_to_hex(r, g, b) {
62851    var hex = this.hex_with_component(0, 2, r);
62852    hex = this.hex_with_component(hex, 1, g);
62853    hex = this.hex_with_component(hex, 0, b);
62854    return hex;
62855  },
62856  component_from_hex: function component_from_hex(hex, componentIndex) {
62857    return hex >> componentIndex * 8 & 0xFF;
62858  },
62859  hex_with_component: function hex_with_component(hex, componentIndex, value) {
62860    return value << (tmpComponent = componentIndex * 8) | hex & ~(0xFF << tmpComponent);
62861  }
62862};
62863
62864var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
62865  return typeof obj;
62866} : function (obj) {
62867  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
62868};
62869
62870var classCallCheck = function (instance, Constructor) {
62871  if (!(instance instanceof Constructor)) {
62872    throw new TypeError("Cannot call a class as a function");
62873  }
62874};
62875
62876var createClass = function () {
62877  function defineProperties(target, props) {
62878    for (var i = 0; i < props.length; i++) {
62879      var descriptor = props[i];
62880      descriptor.enumerable = descriptor.enumerable || false;
62881      descriptor.configurable = true;
62882      if ("value" in descriptor) descriptor.writable = true;
62883      Object.defineProperty(target, descriptor.key, descriptor);
62884    }
62885  }
62886
62887  return function (Constructor, protoProps, staticProps) {
62888    if (protoProps) defineProperties(Constructor.prototype, protoProps);
62889    if (staticProps) defineProperties(Constructor, staticProps);
62890    return Constructor;
62891  };
62892}();
62893
62894var get = function get(object, property, receiver) {
62895  if (object === null) object = Function.prototype;
62896  var desc = Object.getOwnPropertyDescriptor(object, property);
62897
62898  if (desc === undefined) {
62899    var parent = Object.getPrototypeOf(object);
62900
62901    if (parent === null) {
62902      return undefined;
62903    } else {
62904      return get(parent, property, receiver);
62905    }
62906  } else if ("value" in desc) {
62907    return desc.value;
62908  } else {
62909    var getter = desc.get;
62910
62911    if (getter === undefined) {
62912      return undefined;
62913    }
62914
62915    return getter.call(receiver);
62916  }
62917};
62918
62919var inherits = function (subClass, superClass) {
62920  if (typeof superClass !== "function" && superClass !== null) {
62921    throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
62922  }
62923
62924  subClass.prototype = Object.create(superClass && superClass.prototype, {
62925    constructor: {
62926      value: subClass,
62927      enumerable: false,
62928      writable: true,
62929      configurable: true
62930    }
62931  });
62932  if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
62933};
62934
62935var possibleConstructorReturn = function (self, call) {
62936  if (!self) {
62937    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
62938  }
62939
62940  return call && (typeof call === "object" || typeof call === "function") ? call : self;
62941};
62942
62943var Color = function () {
62944  function Color() {
62945    classCallCheck(this, Color);
62946    this.__state = interpret.apply(this, arguments);
62947
62948    if (this.__state === false) {
62949      throw new Error('Failed to interpret color arguments');
62950    }
62951
62952    this.__state.a = this.__state.a || 1;
62953  }
62954
62955  createClass(Color, [{
62956    key: 'toString',
62957    value: function toString() {
62958      return colorToString(this);
62959    }
62960  }, {
62961    key: 'toHexString',
62962    value: function toHexString() {
62963      return colorToString(this, true);
62964    }
62965  }, {
62966    key: 'toOriginal',
62967    value: function toOriginal() {
62968      return this.__state.conversion.write(this);
62969    }
62970  }]);
62971  return Color;
62972}();
62973
62974function defineRGBComponent(target, component, componentHexIndex) {
62975  Object.defineProperty(target, component, {
62976    get: function get$$1() {
62977      if (this.__state.space === 'RGB') {
62978        return this.__state[component];
62979      }
62980
62981      Color.recalculateRGB(this, component, componentHexIndex);
62982      return this.__state[component];
62983    },
62984    set: function set$$1(v) {
62985      if (this.__state.space !== 'RGB') {
62986        Color.recalculateRGB(this, component, componentHexIndex);
62987        this.__state.space = 'RGB';
62988      }
62989
62990      this.__state[component] = v;
62991    }
62992  });
62993}
62994
62995function defineHSVComponent(target, component) {
62996  Object.defineProperty(target, component, {
62997    get: function get$$1() {
62998      if (this.__state.space === 'HSV') {
62999        return this.__state[component];
63000      }
63001
63002      Color.recalculateHSV(this);
63003      return this.__state[component];
63004    },
63005    set: function set$$1(v) {
63006      if (this.__state.space !== 'HSV') {
63007        Color.recalculateHSV(this);
63008        this.__state.space = 'HSV';
63009      }
63010
63011      this.__state[component] = v;
63012    }
63013  });
63014}
63015
63016Color.recalculateRGB = function (color, component, componentHexIndex) {
63017  if (color.__state.space === 'HEX') {
63018    color.__state[component] = ColorMath.component_from_hex(color.__state.hex, componentHexIndex);
63019  } else if (color.__state.space === 'HSV') {
63020    Common.extend(color.__state, ColorMath.hsv_to_rgb(color.__state.h, color.__state.s, color.__state.v));
63021  } else {
63022    throw new Error('Corrupted color state');
63023  }
63024};
63025
63026Color.recalculateHSV = function (color) {
63027  var result = ColorMath.rgb_to_hsv(color.r, color.g, color.b);
63028  Common.extend(color.__state, {
63029    s: result.s,
63030    v: result.v
63031  });
63032
63033  if (!Common.isNaN(result.h)) {
63034    color.__state.h = result.h;
63035  } else if (Common.isUndefined(color.__state.h)) {
63036    color.__state.h = 0;
63037  }
63038};
63039
63040Color.COMPONENTS = ['r', 'g', 'b', 'h', 's', 'v', 'hex', 'a'];
63041defineRGBComponent(Color.prototype, 'r', 2);
63042defineRGBComponent(Color.prototype, 'g', 1);
63043defineRGBComponent(Color.prototype, 'b', 0);
63044defineHSVComponent(Color.prototype, 'h');
63045defineHSVComponent(Color.prototype, 's');
63046defineHSVComponent(Color.prototype, 'v');
63047Object.defineProperty(Color.prototype, 'a', {
63048  get: function get$$1() {
63049    return this.__state.a;
63050  },
63051  set: function set$$1(v) {
63052    this.__state.a = v;
63053  }
63054});
63055Object.defineProperty(Color.prototype, 'hex', {
63056  get: function get$$1() {
63057    if (!this.__state.space !== 'HEX') {
63058      this.__state.hex = ColorMath.rgb_to_hex(this.r, this.g, this.b);
63059    }
63060
63061    return this.__state.hex;
63062  },
63063  set: function set$$1(v) {
63064    this.__state.space = 'HEX';
63065    this.__state.hex = v;
63066  }
63067});
63068
63069var Controller = function () {
63070  function Controller(object, property) {
63071    classCallCheck(this, Controller);
63072    this.initialValue = object[property];
63073    this.domElement = document.createElement('div');
63074    this.object = object;
63075    this.property = property;
63076    this.__onChange = undefined;
63077    this.__onFinishChange = undefined;
63078  }
63079
63080  createClass(Controller, [{
63081    key: 'onChange',
63082    value: function onChange(fnc) {
63083      this.__onChange = fnc;
63084      return this;
63085    }
63086  }, {
63087    key: 'onFinishChange',
63088    value: function onFinishChange(fnc) {
63089      this.__onFinishChange = fnc;
63090      return this;
63091    }
63092  }, {
63093    key: 'setValue',
63094    value: function setValue(newValue) {
63095      this.object[this.property] = newValue;
63096
63097      if (this.__onChange) {
63098        this.__onChange.call(this, newValue);
63099      }
63100
63101      this.updateDisplay();
63102      return this;
63103    }
63104  }, {
63105    key: 'getValue',
63106    value: function getValue() {
63107      return this.object[this.property];
63108    }
63109  }, {
63110    key: 'updateDisplay',
63111    value: function updateDisplay() {
63112      return this;
63113    }
63114  }, {
63115    key: 'isModified',
63116    value: function isModified() {
63117      return this.initialValue !== this.getValue();
63118    }
63119  }]);
63120  return Controller;
63121}();
63122
63123var EVENT_MAP = {
63124  HTMLEvents: ['change'],
63125  MouseEvents: ['click', 'mousemove', 'mousedown', 'mouseup', 'mouseover'],
63126  KeyboardEvents: ['keydown']
63127};
63128var EVENT_MAP_INV = {};
63129Common.each(EVENT_MAP, function (v, k) {
63130  Common.each(v, function (e) {
63131    EVENT_MAP_INV[e] = k;
63132  });
63133});
63134var CSS_VALUE_PIXELS = /(\d+(\.\d+)?)px/;
63135
63136function cssValueToPixels(val) {
63137  if (val === '0' || Common.isUndefined(val)) {
63138    return 0;
63139  }
63140
63141  var match = val.match(CSS_VALUE_PIXELS);
63142
63143  if (!Common.isNull(match)) {
63144    return parseFloat(match[1]);
63145  }
63146
63147  return 0;
63148}
63149
63150var dom = {
63151  makeSelectable: function makeSelectable(elem, selectable) {
63152    if (elem === undefined || elem.style === undefined) return;
63153    elem.onselectstart = selectable ? function () {
63154      return false;
63155    } : function () {};
63156    elem.style.MozUserSelect = selectable ? 'auto' : 'none';
63157    elem.style.KhtmlUserSelect = selectable ? 'auto' : 'none';
63158    elem.unselectable = selectable ? 'on' : 'off';
63159  },
63160  makeFullscreen: function makeFullscreen(elem, hor, vert) {
63161    var vertical = vert;
63162    var horizontal = hor;
63163
63164    if (Common.isUndefined(horizontal)) {
63165      horizontal = true;
63166    }
63167
63168    if (Common.isUndefined(vertical)) {
63169      vertical = true;
63170    }
63171
63172    elem.style.position = 'absolute';
63173
63174    if (horizontal) {
63175      elem.style.left = 0;
63176      elem.style.right = 0;
63177    }
63178
63179    if (vertical) {
63180      elem.style.top = 0;
63181      elem.style.bottom = 0;
63182    }
63183  },
63184  fakeEvent: function fakeEvent(elem, eventType, pars, aux) {
63185    var params = pars || {};
63186    var className = EVENT_MAP_INV[eventType];
63187
63188    if (!className) {
63189      throw new Error('Event type ' + eventType + ' not supported.');
63190    }
63191
63192    var evt = document.createEvent(className);
63193
63194    switch (className) {
63195      case 'MouseEvents':
63196        {
63197          var clientX = params.x || params.clientX || 0;
63198          var clientY = params.y || params.clientY || 0;
63199          evt.initMouseEvent(eventType, params.bubbles || false, params.cancelable || true, window, params.clickCount || 1, 0, 0, clientX, clientY, false, false, false, false, 0, null);
63200          break;
63201        }
63202
63203      case 'KeyboardEvents':
63204        {
63205          var init = evt.initKeyboardEvent || evt.initKeyEvent;
63206          Common.defaults(params, {
63207            cancelable: true,
63208            ctrlKey: false,
63209            altKey: false,
63210            shiftKey: false,
63211            metaKey: false,
63212            keyCode: undefined,
63213            charCode: undefined
63214          });
63215          init(eventType, params.bubbles || false, params.cancelable, window, params.ctrlKey, params.altKey, params.shiftKey, params.metaKey, params.keyCode, params.charCode);
63216          break;
63217        }
63218
63219      default:
63220        {
63221          evt.initEvent(eventType, params.bubbles || false, params.cancelable || true);
63222          break;
63223        }
63224    }
63225
63226    Common.defaults(evt, aux);
63227    elem.dispatchEvent(evt);
63228  },
63229  bind: function bind(elem, event, func, newBool) {
63230    var bool = newBool || false;
63231
63232    if (elem.addEventListener) {
63233      elem.addEventListener(event, func, bool);
63234    } else if (elem.attachEvent) {
63235      elem.attachEvent('on' + event, func);
63236    }
63237
63238    return dom;
63239  },
63240  unbind: function unbind(elem, event, func, newBool) {
63241    var bool = newBool || false;
63242
63243    if (elem.removeEventListener) {
63244      elem.removeEventListener(event, func, bool);
63245    } else if (elem.detachEvent) {
63246      elem.detachEvent('on' + event, func);
63247    }
63248
63249    return dom;
63250  },
63251  addClass: function addClass(elem, className) {
63252    if (elem.className === undefined) {
63253      elem.className = className;
63254    } else if (elem.className !== className) {
63255      var classes = elem.className.split(/ +/);
63256
63257      if (classes.indexOf(className) === -1) {
63258        classes.push(className);
63259        elem.className = classes.join(' ').replace(/^\s+/, '').replace(/\s+$/, '');
63260      }
63261    }
63262
63263    return dom;
63264  },
63265  removeClass: function removeClass(elem, className) {
63266    if (className) {
63267      if (elem.className === className) {
63268        elem.removeAttribute('class');
63269      } else {
63270        var classes = elem.className.split(/ +/);
63271        var index = classes.indexOf(className);
63272
63273        if (index !== -1) {
63274          classes.splice(index, 1);
63275          elem.className = classes.join(' ');
63276        }
63277      }
63278    } else {
63279      elem.className = undefined;
63280    }
63281
63282    return dom;
63283  },
63284  hasClass: function hasClass(elem, className) {
63285    return new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)').test(elem.className) || false;
63286  },
63287  getWidth: function getWidth(elem) {
63288    var style = getComputedStyle(elem);
63289    return cssValueToPixels(style['border-left-width']) + cssValueToPixels(style['border-right-width']) + cssValueToPixels(style['padding-left']) + cssValueToPixels(style['padding-right']) + cssValueToPixels(style.width);
63290  },
63291  getHeight: function getHeight(elem) {
63292    var style = getComputedStyle(elem);
63293    return cssValueToPixels(style['border-top-width']) + cssValueToPixels(style['border-bottom-width']) + cssValueToPixels(style['padding-top']) + cssValueToPixels(style['padding-bottom']) + cssValueToPixels(style.height);
63294  },
63295  getOffset: function getOffset(el) {
63296    var elem = el;
63297    var offset = {
63298      left: 0,
63299      top: 0
63300    };
63301
63302    if (elem.offsetParent) {
63303      do {
63304        offset.left += elem.offsetLeft;
63305        offset.top += elem.offsetTop;
63306        elem = elem.offsetParent;
63307      } while (elem);
63308    }
63309
63310    return offset;
63311  },
63312  isActive: function isActive(elem) {
63313    return elem === document.activeElement && (elem.type || elem.href);
63314  }
63315};
63316
63317var BooleanController = function (_Controller) {
63318  inherits(BooleanController, _Controller);
63319
63320  function BooleanController(object, property) {
63321    classCallCheck(this, BooleanController);
63322
63323    var _this2 = possibleConstructorReturn(this, (BooleanController.__proto__ || Object.getPrototypeOf(BooleanController)).call(this, object, property));
63324
63325    var _this = _this2;
63326    _this2.__prev = _this2.getValue();
63327    _this2.__checkbox = document.createElement('input');
63328
63329    _this2.__checkbox.setAttribute('type', 'checkbox');
63330
63331    function onChange() {
63332      _this.setValue(!_this.__prev);
63333    }
63334
63335    dom.bind(_this2.__checkbox, 'change', onChange, false);
63336
63337    _this2.domElement.appendChild(_this2.__checkbox);
63338
63339    _this2.updateDisplay();
63340
63341    return _this2;
63342  }
63343
63344  createClass(BooleanController, [{
63345    key: 'setValue',
63346    value: function setValue(v) {
63347      var toReturn = get(BooleanController.prototype.__proto__ || Object.getPrototypeOf(BooleanController.prototype), 'setValue', this).call(this, v);
63348
63349      if (this.__onFinishChange) {
63350        this.__onFinishChange.call(this, this.getValue());
63351      }
63352
63353      this.__prev = this.getValue();
63354      return toReturn;
63355    }
63356  }, {
63357    key: 'updateDisplay',
63358    value: function updateDisplay() {
63359      if (this.getValue() === true) {
63360        this.__checkbox.setAttribute('checked', 'checked');
63361
63362        this.__checkbox.checked = true;
63363        this.__prev = true;
63364      } else {
63365        this.__checkbox.checked = false;
63366        this.__prev = false;
63367      }
63368
63369      return get(BooleanController.prototype.__proto__ || Object.getPrototypeOf(BooleanController.prototype), 'updateDisplay', this).call(this);
63370    }
63371  }]);
63372  return BooleanController;
63373}(Controller);
63374
63375var OptionController = function (_Controller) {
63376  inherits(OptionController, _Controller);
63377
63378  function OptionController(object, property, opts) {
63379    classCallCheck(this, OptionController);
63380
63381    var _this2 = possibleConstructorReturn(this, (OptionController.__proto__ || Object.getPrototypeOf(OptionController)).call(this, object, property));
63382
63383    var options = opts;
63384    var _this = _this2;
63385    _this2.__select = document.createElement('select');
63386
63387    if (Common.isArray(options)) {
63388      var map = {};
63389      Common.each(options, function (element) {
63390        map[element] = element;
63391      });
63392      options = map;
63393    }
63394
63395    Common.each(options, function (value, key) {
63396      var opt = document.createElement('option');
63397      opt.innerHTML = key;
63398      opt.setAttribute('value', value);
63399
63400      _this.__select.appendChild(opt);
63401    });
63402
63403    _this2.updateDisplay();
63404
63405    dom.bind(_this2.__select, 'change', function () {
63406      var desiredValue = this.options[this.selectedIndex].value;
63407
63408      _this.setValue(desiredValue);
63409    });
63410
63411    _this2.domElement.appendChild(_this2.__select);
63412
63413    return _this2;
63414  }
63415
63416  createClass(OptionController, [{
63417    key: 'setValue',
63418    value: function setValue(v) {
63419      var toReturn = get(OptionController.prototype.__proto__ || Object.getPrototypeOf(OptionController.prototype), 'setValue', this).call(this, v);
63420
63421      if (this.__onFinishChange) {
63422        this.__onFinishChange.call(this, this.getValue());
63423      }
63424
63425      return toReturn;
63426    }
63427  }, {
63428    key: 'updateDisplay',
63429    value: function updateDisplay() {
63430      if (dom.isActive(this.__select)) return this;
63431      this.__select.value = this.getValue();
63432      return get(OptionController.prototype.__proto__ || Object.getPrototypeOf(OptionController.prototype), 'updateDisplay', this).call(this);
63433    }
63434  }]);
63435  return OptionController;
63436}(Controller);
63437
63438var StringController = function (_Controller) {
63439  inherits(StringController, _Controller);
63440
63441  function StringController(object, property) {
63442    classCallCheck(this, StringController);
63443
63444    var _this2 = possibleConstructorReturn(this, (StringController.__proto__ || Object.getPrototypeOf(StringController)).call(this, object, property));
63445
63446    var _this = _this2;
63447
63448    function onChange() {
63449      _this.setValue(_this.__input.value);
63450    }
63451
63452    function onBlur() {
63453      if (_this.__onFinishChange) {
63454        _this.__onFinishChange.call(_this, _this.getValue());
63455      }
63456    }
63457
63458    _this2.__input = document.createElement('input');
63459
63460    _this2.__input.setAttribute('type', 'text');
63461
63462    dom.bind(_this2.__input, 'keyup', onChange);
63463    dom.bind(_this2.__input, 'change', onChange);
63464    dom.bind(_this2.__input, 'blur', onBlur);
63465    dom.bind(_this2.__input, 'keydown', function (e) {
63466      if (e.keyCode === 13) {
63467        this.blur();
63468      }
63469    });
63470
63471    _this2.updateDisplay();
63472
63473    _this2.domElement.appendChild(_this2.__input);
63474
63475    return _this2;
63476  }
63477
63478  createClass(StringController, [{
63479    key: 'updateDisplay',
63480    value: function updateDisplay() {
63481      if (!dom.isActive(this.__input)) {
63482        this.__input.value = this.getValue();
63483      }
63484
63485      return get(StringController.prototype.__proto__ || Object.getPrototypeOf(StringController.prototype), 'updateDisplay', this).call(this);
63486    }
63487  }]);
63488  return StringController;
63489}(Controller);
63490
63491function numDecimals(x) {
63492  var _x = x.toString();
63493
63494  if (_x.indexOf('.') > -1) {
63495    return _x.length - _x.indexOf('.') - 1;
63496  }
63497
63498  return 0;
63499}
63500
63501var NumberController = function (_Controller) {
63502  inherits(NumberController, _Controller);
63503
63504  function NumberController(object, property, params) {
63505    classCallCheck(this, NumberController);
63506
63507    var _this = possibleConstructorReturn(this, (NumberController.__proto__ || Object.getPrototypeOf(NumberController)).call(this, object, property));
63508
63509    var _params = params || {};
63510
63511    _this.__min = _params.min;
63512    _this.__max = _params.max;
63513    _this.__step = _params.step;
63514
63515    if (Common.isUndefined(_this.__step)) {
63516      if (_this.initialValue === 0) {
63517        _this.__impliedStep = 1;
63518      } else {
63519        _this.__impliedStep = Math.pow(10, Math.floor(Math.log(Math.abs(_this.initialValue)) / Math.LN10)) / 10;
63520      }
63521    } else {
63522      _this.__impliedStep = _this.__step;
63523    }
63524
63525    _this.__precision = numDecimals(_this.__impliedStep);
63526    return _this;
63527  }
63528
63529  createClass(NumberController, [{
63530    key: 'setValue',
63531    value: function setValue(v) {
63532      var _v = v;
63533
63534      if (this.__min !== undefined && _v < this.__min) {
63535        _v = this.__min;
63536      } else if (this.__max !== undefined && _v > this.__max) {
63537        _v = this.__max;
63538      }
63539
63540      if (this.__step !== undefined && _v % this.__step !== 0) {
63541        _v = Math.round(_v / this.__step) * this.__step;
63542      }
63543
63544      return get(NumberController.prototype.__proto__ || Object.getPrototypeOf(NumberController.prototype), 'setValue', this).call(this, _v);
63545    }
63546  }, {
63547    key: 'min',
63548    value: function min(minValue) {
63549      this.__min = minValue;
63550      return this;
63551    }
63552  }, {
63553    key: 'max',
63554    value: function max(maxValue) {
63555      this.__max = maxValue;
63556      return this;
63557    }
63558  }, {
63559    key: 'step',
63560    value: function step(stepValue) {
63561      this.__step = stepValue;
63562      this.__impliedStep = stepValue;
63563      this.__precision = numDecimals(stepValue);
63564      return this;
63565    }
63566  }]);
63567  return NumberController;
63568}(Controller);
63569
63570function roundToDecimal(value, decimals) {
63571  var tenTo = Math.pow(10, decimals);
63572  return Math.round(value * tenTo) / tenTo;
63573}
63574
63575var NumberControllerBox = function (_NumberController) {
63576  inherits(NumberControllerBox, _NumberController);
63577
63578  function NumberControllerBox(object, property, params) {
63579    classCallCheck(this, NumberControllerBox);
63580
63581    var _this2 = possibleConstructorReturn(this, (NumberControllerBox.__proto__ || Object.getPrototypeOf(NumberControllerBox)).call(this, object, property, params));
63582
63583    _this2.__truncationSuspended = false;
63584    var _this = _this2;
63585    var prevY = void 0;
63586
63587    function onChange() {
63588      var attempted = parseFloat(_this.__input.value);
63589
63590      if (!Common.isNaN(attempted)) {
63591        _this.setValue(attempted);
63592      }
63593    }
63594
63595    function onFinish() {
63596      if (_this.__onFinishChange) {
63597        _this.__onFinishChange.call(_this, _this.getValue());
63598      }
63599    }
63600
63601    function onBlur() {
63602      onFinish();
63603    }
63604
63605    function onMouseDrag(e) {
63606      var diff = prevY - e.clientY;
63607
63608      _this.setValue(_this.getValue() + diff * _this.__impliedStep);
63609
63610      prevY = e.clientY;
63611    }
63612
63613    function onMouseUp() {
63614      dom.unbind(window, 'mousemove', onMouseDrag);
63615      dom.unbind(window, 'mouseup', onMouseUp);
63616      onFinish();
63617    }
63618
63619    function onMouseDown(e) {
63620      dom.bind(window, 'mousemove', onMouseDrag);
63621      dom.bind(window, 'mouseup', onMouseUp);
63622      prevY = e.clientY;
63623    }
63624
63625    _this2.__input = document.createElement('input');
63626
63627    _this2.__input.setAttribute('type', 'text');
63628
63629    dom.bind(_this2.__input, 'change', onChange);
63630    dom.bind(_this2.__input, 'blur', onBlur);
63631    dom.bind(_this2.__input, 'mousedown', onMouseDown);
63632    dom.bind(_this2.__input, 'keydown', function (e) {
63633      if (e.keyCode === 13) {
63634        _this.__truncationSuspended = true;
63635        this.blur();
63636        _this.__truncationSuspended = false;
63637        onFinish();
63638      }
63639    });
63640
63641    _this2.updateDisplay();
63642
63643    _this2.domElement.appendChild(_this2.__input);
63644
63645    return _this2;
63646  }
63647
63648  createClass(NumberControllerBox, [{
63649    key: 'updateDisplay',
63650    value: function updateDisplay() {
63651      this.__input.value = this.__truncationSuspended ? this.getValue() : roundToDecimal(this.getValue(), this.__precision);
63652      return get(NumberControllerBox.prototype.__proto__ || Object.getPrototypeOf(NumberControllerBox.prototype), 'updateDisplay', this).call(this);
63653    }
63654  }]);
63655  return NumberControllerBox;
63656}(NumberController);
63657
63658function map(v, i1, i2, o1, o2) {
63659  return o1 + (o2 - o1) * ((v - i1) / (i2 - i1));
63660}
63661
63662var NumberControllerSlider = function (_NumberController) {
63663  inherits(NumberControllerSlider, _NumberController);
63664
63665  function NumberControllerSlider(object, property, min, max, step) {
63666    classCallCheck(this, NumberControllerSlider);
63667
63668    var _this2 = possibleConstructorReturn(this, (NumberControllerSlider.__proto__ || Object.getPrototypeOf(NumberControllerSlider)).call(this, object, property, {
63669      min: min,
63670      max: max,
63671      step: step
63672    }));
63673
63674    var _this = _this2;
63675    _this2.__background = document.createElement('div');
63676    _this2.__foreground = document.createElement('div');
63677    dom.bind(_this2.__background, 'mousedown', onMouseDown);
63678    dom.bind(_this2.__background, 'touchstart', onTouchStart);
63679    dom.addClass(_this2.__background, 'slider');
63680    dom.addClass(_this2.__foreground, 'slider-fg');
63681
63682    function onMouseDown(e) {
63683      document.activeElement.blur();
63684      dom.bind(window, 'mousemove', onMouseDrag);
63685      dom.bind(window, 'mouseup', onMouseUp);
63686      onMouseDrag(e);
63687    }
63688
63689    function onMouseDrag(e) {
63690      e.preventDefault();
63691
63692      var bgRect = _this.__background.getBoundingClientRect();
63693
63694      _this.setValue(map(e.clientX, bgRect.left, bgRect.right, _this.__min, _this.__max));
63695
63696      return false;
63697    }
63698
63699    function onMouseUp() {
63700      dom.unbind(window, 'mousemove', onMouseDrag);
63701      dom.unbind(window, 'mouseup', onMouseUp);
63702
63703      if (_this.__onFinishChange) {
63704        _this.__onFinishChange.call(_this, _this.getValue());
63705      }
63706    }
63707
63708    function onTouchStart(e) {
63709      if (e.touches.length !== 1) {
63710        return;
63711      }
63712
63713      dom.bind(window, 'touchmove', onTouchMove);
63714      dom.bind(window, 'touchend', onTouchEnd);
63715      onTouchMove(e);
63716    }
63717
63718    function onTouchMove(e) {
63719      var clientX = e.touches[0].clientX;
63720
63721      var bgRect = _this.__background.getBoundingClientRect();
63722
63723      _this.setValue(map(clientX, bgRect.left, bgRect.right, _this.__min, _this.__max));
63724    }
63725
63726    function onTouchEnd() {
63727      dom.unbind(window, 'touchmove', onTouchMove);
63728      dom.unbind(window, 'touchend', onTouchEnd);
63729
63730      if (_this.__onFinishChange) {
63731        _this.__onFinishChange.call(_this, _this.getValue());
63732      }
63733    }
63734
63735    _this2.updateDisplay();
63736
63737    _this2.__background.appendChild(_this2.__foreground);
63738
63739    _this2.domElement.appendChild(_this2.__background);
63740
63741    return _this2;
63742  }
63743
63744  createClass(NumberControllerSlider, [{
63745    key: 'updateDisplay',
63746    value: function updateDisplay() {
63747      var pct = (this.getValue() - this.__min) / (this.__max - this.__min);
63748
63749      this.__foreground.style.width = pct * 100 + '%';
63750      return get(NumberControllerSlider.prototype.__proto__ || Object.getPrototypeOf(NumberControllerSlider.prototype), 'updateDisplay', this).call(this);
63751    }
63752  }]);
63753  return NumberControllerSlider;
63754}(NumberController);
63755
63756var FunctionController = function (_Controller) {
63757  inherits(FunctionController, _Controller);
63758
63759  function FunctionController(object, property, text) {
63760    classCallCheck(this, FunctionController);
63761
63762    var _this2 = possibleConstructorReturn(this, (FunctionController.__proto__ || Object.getPrototypeOf(FunctionController)).call(this, object, property));
63763
63764    var _this = _this2;
63765    _this2.__button = document.createElement('div');
63766    _this2.__button.innerHTML = text === undefined ? 'Fire' : text;
63767    dom.bind(_this2.__button, 'click', function (e) {
63768      e.preventDefault();
63769
63770      _this.fire();
63771
63772      return false;
63773    });
63774    dom.addClass(_this2.__button, 'button');
63775
63776    _this2.domElement.appendChild(_this2.__button);
63777
63778    return _this2;
63779  }
63780
63781  createClass(FunctionController, [{
63782    key: 'fire',
63783    value: function fire() {
63784      if (this.__onChange) {
63785        this.__onChange.call(this);
63786      }
63787
63788      this.getValue().call(this.object);
63789
63790      if (this.__onFinishChange) {
63791        this.__onFinishChange.call(this, this.getValue());
63792      }
63793    }
63794  }]);
63795  return FunctionController;
63796}(Controller);
63797
63798var ColorController = function (_Controller) {
63799  inherits(ColorController, _Controller);
63800
63801  function ColorController(object, property) {
63802    classCallCheck(this, ColorController);
63803
63804    var _this2 = possibleConstructorReturn(this, (ColorController.__proto__ || Object.getPrototypeOf(ColorController)).call(this, object, property));
63805
63806    _this2.__color = new Color(_this2.getValue());
63807    _this2.__temp = new Color(0);
63808    var _this = _this2;
63809    _this2.domElement = document.createElement('div');
63810    dom.makeSelectable(_this2.domElement, false);
63811    _this2.__selector = document.createElement('div');
63812    _this2.__selector.className = 'selector';
63813    _this2.__saturation_field = document.createElement('div');
63814    _this2.__saturation_field.className = 'saturation-field';
63815    _this2.__field_knob = document.createElement('div');
63816    _this2.__field_knob.className = 'field-knob';
63817    _this2.__field_knob_border = '2px solid ';
63818    _this2.__hue_knob = document.createElement('div');
63819    _this2.__hue_knob.className = 'hue-knob';
63820    _this2.__hue_field = document.createElement('div');
63821    _this2.__hue_field.className = 'hue-field';
63822    _this2.__input = document.createElement('input');
63823    _this2.__input.type = 'text';
63824    _this2.__input_textShadow = '0 1px 1px ';
63825    dom.bind(_this2.__input, 'keydown', function (e) {
63826      if (e.keyCode === 13) {
63827        onBlur.call(this);
63828      }
63829    });
63830    dom.bind(_this2.__input, 'blur', onBlur);
63831    dom.bind(_this2.__selector, 'mousedown', function () {
63832      dom.addClass(this, 'drag').bind(window, 'mouseup', function () {
63833        dom.removeClass(_this.__selector, 'drag');
63834      });
63835    });
63836    dom.bind(_this2.__selector, 'touchstart', function () {
63837      dom.addClass(this, 'drag').bind(window, 'touchend', function () {
63838        dom.removeClass(_this.__selector, 'drag');
63839      });
63840    });
63841    var valueField = document.createElement('div');
63842    Common.extend(_this2.__selector.style, {
63843      width: '122px',
63844      height: '102px',
63845      padding: '3px',
63846      backgroundColor: '#222',
63847      boxShadow: '0px 1px 3px rgba(0,0,0,0.3)'
63848    });
63849    Common.extend(_this2.__field_knob.style, {
63850      position: 'absolute',
63851      width: '12px',
63852      height: '12px',
63853      border: _this2.__field_knob_border + (_this2.__color.v < 0.5 ? '#fff' : '#000'),
63854      boxShadow: '0px 1px 3px rgba(0,0,0,0.5)',
63855      borderRadius: '12px',
63856      zIndex: 1
63857    });
63858    Common.extend(_this2.__hue_knob.style, {
63859      position: 'absolute',
63860      width: '15px',
63861      height: '2px',
63862      borderRight: '4px solid #fff',
63863      zIndex: 1
63864    });
63865    Common.extend(_this2.__saturation_field.style, {
63866      width: '100px',
63867      height: '100px',
63868      border: '1px solid #555',
63869      marginRight: '3px',
63870      display: 'inline-block',
63871      cursor: 'pointer'
63872    });
63873    Common.extend(valueField.style, {
63874      width: '100%',
63875      height: '100%',
63876      background: 'none'
63877    });
63878    linearGradient(valueField, 'top', 'rgba(0,0,0,0)', '#000');
63879    Common.extend(_this2.__hue_field.style, {
63880      width: '15px',
63881      height: '100px',
63882      border: '1px solid #555',
63883      cursor: 'ns-resize',
63884      position: 'absolute',
63885      top: '3px',
63886      right: '3px'
63887    });
63888    hueGradient(_this2.__hue_field);
63889    Common.extend(_this2.__input.style, {
63890      outline: 'none',
63891      textAlign: 'center',
63892      color: '#fff',
63893      border: 0,
63894      fontWeight: 'bold',
63895      textShadow: _this2.__input_textShadow + 'rgba(0,0,0,0.7)'
63896    });
63897    dom.bind(_this2.__saturation_field, 'mousedown', fieldDown);
63898    dom.bind(_this2.__saturation_field, 'touchstart', fieldDown);
63899    dom.bind(_this2.__field_knob, 'mousedown', fieldDown);
63900    dom.bind(_this2.__field_knob, 'touchstart', fieldDown);
63901    dom.bind(_this2.__hue_field, 'mousedown', fieldDownH);
63902    dom.bind(_this2.__hue_field, 'touchstart', fieldDownH);
63903
63904    function fieldDown(e) {
63905      setSV(e);
63906      dom.bind(window, 'mousemove', setSV);
63907      dom.bind(window, 'touchmove', setSV);
63908      dom.bind(window, 'mouseup', fieldUpSV);
63909      dom.bind(window, 'touchend', fieldUpSV);
63910    }
63911
63912    function fieldDownH(e) {
63913      setH(e);
63914      dom.bind(window, 'mousemove', setH);
63915      dom.bind(window, 'touchmove', setH);
63916      dom.bind(window, 'mouseup', fieldUpH);
63917      dom.bind(window, 'touchend', fieldUpH);
63918    }
63919
63920    function fieldUpSV() {
63921      dom.unbind(window, 'mousemove', setSV);
63922      dom.unbind(window, 'touchmove', setSV);
63923      dom.unbind(window, 'mouseup', fieldUpSV);
63924      dom.unbind(window, 'touchend', fieldUpSV);
63925      onFinish();
63926    }
63927
63928    function fieldUpH() {
63929      dom.unbind(window, 'mousemove', setH);
63930      dom.unbind(window, 'touchmove', setH);
63931      dom.unbind(window, 'mouseup', fieldUpH);
63932      dom.unbind(window, 'touchend', fieldUpH);
63933      onFinish();
63934    }
63935
63936    function onBlur() {
63937      var i = interpret(this.value);
63938
63939      if (i !== false) {
63940        _this.__color.__state = i;
63941
63942        _this.setValue(_this.__color.toOriginal());
63943      } else {
63944        this.value = _this.__color.toString();
63945      }
63946    }
63947
63948    function onFinish() {
63949      if (_this.__onFinishChange) {
63950        _this.__onFinishChange.call(_this, _this.__color.toOriginal());
63951      }
63952    }
63953
63954    _this2.__saturation_field.appendChild(valueField);
63955
63956    _this2.__selector.appendChild(_this2.__field_knob);
63957
63958    _this2.__selector.appendChild(_this2.__saturation_field);
63959
63960    _this2.__selector.appendChild(_this2.__hue_field);
63961
63962    _this2.__hue_field.appendChild(_this2.__hue_knob);
63963
63964    _this2.domElement.appendChild(_this2.__input);
63965
63966    _this2.domElement.appendChild(_this2.__selector);
63967
63968    _this2.updateDisplay();
63969
63970    function setSV(e) {
63971      if (e.type.indexOf('touch') === -1) {
63972        e.preventDefault();
63973      }
63974
63975      var fieldRect = _this.__saturation_field.getBoundingClientRect();
63976
63977      var _ref = e.touches && e.touches[0] || e,
63978          clientX = _ref.clientX,
63979          clientY = _ref.clientY;
63980
63981      var s = (clientX - fieldRect.left) / (fieldRect.right - fieldRect.left);
63982      var v = 1 - (clientY - fieldRect.top) / (fieldRect.bottom - fieldRect.top);
63983
63984      if (v > 1) {
63985        v = 1;
63986      } else if (v < 0) {
63987        v = 0;
63988      }
63989
63990      if (s > 1) {
63991        s = 1;
63992      } else if (s < 0) {
63993        s = 0;
63994      }
63995
63996      _this.__color.v = v;
63997      _this.__color.s = s;
63998
63999      _this.setValue(_this.__color.toOriginal());
64000
64001      return false;
64002    }
64003
64004    function setH(e) {
64005      if (e.type.indexOf('touch') === -1) {
64006        e.preventDefault();
64007      }
64008
64009      var fieldRect = _this.__hue_field.getBoundingClientRect();
64010
64011      var _ref2 = e.touches && e.touches[0] || e,
64012          clientY = _ref2.clientY;
64013
64014      var h = 1 - (clientY - fieldRect.top) / (fieldRect.bottom - fieldRect.top);
64015
64016      if (h > 1) {
64017        h = 1;
64018      } else if (h < 0) {
64019        h = 0;
64020      }
64021
64022      _this.__color.h = h * 360;
64023
64024      _this.setValue(_this.__color.toOriginal());
64025
64026      return false;
64027    }
64028
64029    return _this2;
64030  }
64031
64032  createClass(ColorController, [{
64033    key: 'updateDisplay',
64034    value: function updateDisplay() {
64035      var i = interpret(this.getValue());
64036
64037      if (i !== false) {
64038        var mismatch = false;
64039        Common.each(Color.COMPONENTS, function (component) {
64040          if (!Common.isUndefined(i[component]) && !Common.isUndefined(this.__color.__state[component]) && i[component] !== this.__color.__state[component]) {
64041            mismatch = true;
64042            return {};
64043          }
64044        }, this);
64045
64046        if (mismatch) {
64047          Common.extend(this.__color.__state, i);
64048        }
64049      }
64050
64051      Common.extend(this.__temp.__state, this.__color.__state);
64052      this.__temp.a = 1;
64053      var flip = this.__color.v < 0.5 || this.__color.s > 0.5 ? 255 : 0;
64054
64055      var _flip = 255 - flip;
64056
64057      Common.extend(this.__field_knob.style, {
64058        marginLeft: 100 * this.__color.s - 7 + 'px',
64059        marginTop: 100 * (1 - this.__color.v) - 7 + 'px',
64060        backgroundColor: this.__temp.toHexString(),
64061        border: this.__field_knob_border + 'rgb(' + flip + ',' + flip + ',' + flip + ')'
64062      });
64063      this.__hue_knob.style.marginTop = (1 - this.__color.h / 360) * 100 + 'px';
64064      this.__temp.s = 1;
64065      this.__temp.v = 1;
64066      linearGradient(this.__saturation_field, 'left', '#fff', this.__temp.toHexString());
64067      this.__input.value = this.__color.toString();
64068      Common.extend(this.__input.style, {
64069        backgroundColor: this.__color.toHexString(),
64070        color: 'rgb(' + flip + ',' + flip + ',' + flip + ')',
64071        textShadow: this.__input_textShadow + 'rgba(' + _flip + ',' + _flip + ',' + _flip + ',.7)'
64072      });
64073    }
64074  }]);
64075  return ColorController;
64076}(Controller);
64077
64078var vendors = ['-moz-', '-o-', '-webkit-', '-ms-', ''];
64079
64080function linearGradient(elem, x, a, b) {
64081  elem.style.background = '';
64082  Common.each(vendors, function (vendor) {
64083    elem.style.cssText += 'background: ' + vendor + 'linear-gradient(' + x + ', ' + a + ' 0%, ' + b + ' 100%); ';
64084  });
64085}
64086
64087function hueGradient(elem) {
64088  elem.style.background = '';
64089  elem.style.cssText += 'background: -moz-linear-gradient(top,  #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);';
64090  elem.style.cssText += 'background: -webkit-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';
64091  elem.style.cssText += 'background: -o-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';
64092  elem.style.cssText += 'background: -ms-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';
64093  elem.style.cssText += 'background: linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);';
64094}
64095
64096var css = {
64097  load: function load(url, indoc) {
64098    var doc = indoc || document;
64099    var link = doc.createElement('link');
64100    link.type = 'text/css';
64101    link.rel = 'stylesheet';
64102    link.href = url;
64103    doc.getElementsByTagName('head')[0].appendChild(link);
64104  },
64105  inject: function inject(cssContent, indoc) {
64106    var doc = indoc || document;
64107    var injected = document.createElement('style');
64108    injected.type = 'text/css';
64109    injected.innerHTML = cssContent;
64110    var head = doc.getElementsByTagName('head')[0];
64111
64112    try {
64113      head.appendChild(injected);
64114    } catch (e) {}
64115  }
64116};
64117var saveDialogContents = "<div id=\"dg-save\" class=\"dg dialogue\">\n\n  Here's the new load parameter for your <code>GUI</code>'s constructor:\n\n  <textarea id=\"dg-new-constructor\"></textarea>\n\n  <div id=\"dg-save-locally\">\n\n    <input id=\"dg-local-storage\" type=\"checkbox\"/> Automatically save\n    values to <code>localStorage</code> on exit.\n\n    <div id=\"dg-local-explain\">The values saved to <code>localStorage</code> will\n      override those passed to <code>dat.GUI</code>'s constructor. This makes it\n      easier to work incrementally, but <code>localStorage</code> is fragile,\n      and your friends may not see the same values you do.\n\n    </div>\n\n  </div>\n\n</div>";
64118
64119var ControllerFactory = function ControllerFactory(object, property) {
64120  var initialValue = object[property];
64121
64122  if (Common.isArray(arguments[2]) || Common.isObject(arguments[2])) {
64123    return new OptionController(object, property, arguments[2]);
64124  }
64125
64126  if (Common.isNumber(initialValue)) {
64127    if (Common.isNumber(arguments[2]) && Common.isNumber(arguments[3])) {
64128      if (Common.isNumber(arguments[4])) {
64129        return new NumberControllerSlider(object, property, arguments[2], arguments[3], arguments[4]);
64130      }
64131
64132      return new NumberControllerSlider(object, property, arguments[2], arguments[3]);
64133    }
64134
64135    if (Common.isNumber(arguments[4])) {
64136      return new NumberControllerBox(object, property, {
64137        min: arguments[2],
64138        max: arguments[3],
64139        step: arguments[4]
64140      });
64141    }
64142
64143    return new NumberControllerBox(object, property, {
64144      min: arguments[2],
64145      max: arguments[3]
64146    });
64147  }
64148
64149  if (Common.isString(initialValue)) {
64150    return new StringController(object, property);
64151  }
64152
64153  if (Common.isFunction(initialValue)) {
64154    return new FunctionController(object, property, '');
64155  }
64156
64157  if (Common.isBoolean(initialValue)) {
64158    return new BooleanController(object, property);
64159  }
64160
64161  return null;
64162};
64163
64164function requestAnimationFrame(callback) {
64165  setTimeout(callback, 1000 / 60);
64166}
64167
64168var requestAnimationFrame$1 = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || requestAnimationFrame;
64169
64170var CenteredDiv = function () {
64171  function CenteredDiv() {
64172    classCallCheck(this, CenteredDiv);
64173    this.backgroundElement = document.createElement('div');
64174    Common.extend(this.backgroundElement.style, {
64175      backgroundColor: 'rgba(0,0,0,0.8)',
64176      top: 0,
64177      left: 0,
64178      display: 'none',
64179      zIndex: '1000',
64180      opacity: 0,
64181      WebkitTransition: 'opacity 0.2s linear',
64182      transition: 'opacity 0.2s linear'
64183    });
64184    dom.makeFullscreen(this.backgroundElement);
64185    this.backgroundElement.style.position = 'fixed';
64186    this.domElement = document.createElement('div');
64187    Common.extend(this.domElement.style, {
64188      position: 'fixed',
64189      display: 'none',
64190      zIndex: '1001',
64191      opacity: 0,
64192      WebkitTransition: '-webkit-transform 0.2s ease-out, opacity 0.2s linear',
64193      transition: 'transform 0.2s ease-out, opacity 0.2s linear'
64194    });
64195    document.body.appendChild(this.backgroundElement);
64196    document.body.appendChild(this.domElement);
64197
64198    var _this = this;
64199
64200    dom.bind(this.backgroundElement, 'click', function () {
64201      _this.hide();
64202    });
64203  }
64204
64205  createClass(CenteredDiv, [{
64206    key: 'show',
64207    value: function show() {
64208      var _this = this;
64209
64210      this.backgroundElement.style.display = 'block';
64211      this.domElement.style.display = 'block';
64212      this.domElement.style.opacity = 0;
64213      this.domElement.style.webkitTransform = 'scale(1.1)';
64214      this.layout();
64215      Common.defer(function () {
64216        _this.backgroundElement.style.opacity = 1;
64217        _this.domElement.style.opacity = 1;
64218        _this.domElement.style.webkitTransform = 'scale(1)';
64219      });
64220    }
64221  }, {
64222    key: 'hide',
64223    value: function hide() {
64224      var _this = this;
64225
64226      var hide = function hide() {
64227        _this.domElement.style.display = 'none';
64228        _this.backgroundElement.style.display = 'none';
64229        dom.unbind(_this.domElement, 'webkitTransitionEnd', hide);
64230        dom.unbind(_this.domElement, 'transitionend', hide);
64231        dom.unbind(_this.domElement, 'oTransitionEnd', hide);
64232      };
64233
64234      dom.bind(this.domElement, 'webkitTransitionEnd', hide);
64235      dom.bind(this.domElement, 'transitionend', hide);
64236      dom.bind(this.domElement, 'oTransitionEnd', hide);
64237      this.backgroundElement.style.opacity = 0;
64238      this.domElement.style.opacity = 0;
64239      this.domElement.style.webkitTransform = 'scale(1.1)';
64240    }
64241  }, {
64242    key: 'layout',
64243    value: function layout() {
64244      this.domElement.style.left = window.innerWidth / 2 - dom.getWidth(this.domElement) / 2 + 'px';
64245      this.domElement.style.top = window.innerHeight / 2 - dom.getHeight(this.domElement) / 2 + 'px';
64246    }
64247  }]);
64248  return CenteredDiv;
64249}();
64250
64251var styleSheet = ___$insertStyle(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;
64251font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");
64252
64253css.inject(styleSheet);
64254var CSS_NAMESPACE = 'dg';
64255var HIDE_KEY_CODE = 72;
64256var CLOSE_BUTTON_HEIGHT = 20;
64257var DEFAULT_DEFAULT_PRESET_NAME = 'Default';
64258
64259var SUPPORTS_LOCAL_STORAGE = function () {
64260  try {
64261    return !!window.localStorage;
64262  } catch (e) {
64263    return false;
64264  }
64265}();
64266
64267var SAVE_DIALOGUE = void 0;
64268var autoPlaceVirgin = true;
64269var autoPlaceContainer = void 0;
64270var hide = false;
vendor: 24,669 bytes, lines 64271-65157
64271var hideableGuis = [];
64272
64273var GUI = function GUI(pars) {
64274  var _this = this;
64275
64276  var params = pars || {};
64277  this.domElement = document.createElement('div');
64278  this.__ul = document.createElement('ul');
64279  this.domElement.appendChild(this.__ul);
64280  dom.addClass(this.domElement, CSS_NAMESPACE);
64281  this.__folders = {};
64282  this.__controllers = [];
64283  this.__rememberedObjects = [];
64284  this.__rememberedObjectIndecesToControllers = [];
64285  this.__listening = [];
64286  params = Common.defaults(params, {
64287    closeOnTop: false,
64288    autoPlace: true,
64289    width: GUI.DEFAULT_WIDTH
64290  });
64291  params = Common.defaults(params, {
64292    resizable: params.autoPlace,
64293    hideable: params.autoPlace
64294  });
64295
64296  if (!Common.isUndefined(params.load)) {
64297    if (params.preset) {
64298      params.load.preset = params.preset;
64299    }
64300  } else {
64301    params.load = {
64302      preset: DEFAULT_DEFAULT_PRESET_NAME
64303    };
64304  }
64305
64306  if (Common.isUndefined(params.parent) && params.hideable) {
64307    hideableGuis.push(this);
64308  }
64309
64310  params.resizable = Common.isUndefined(params.parent) && params.resizable;
64311
64312  if (params.autoPlace && Common.isUndefined(params.scrollable)) {
64313    params.scrollable = true;
64314  }
64315
64316  var useLocalStorage = SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(this, 'isLocal')) === 'true';
64317  var saveToLocalStorage = void 0;
64318  var titleRow = void 0;
64319  Object.defineProperties(this, {
64320    parent: {
64321      get: function get$$1() {
64322        return params.parent;
64323      }
64324    },
64325    scrollable: {
64326      get: function get$$1() {
64327        return params.scrollable;
64328      }
64329    },
64330    autoPlace: {
64331      get: function get$$1() {
64332        return params.autoPlace;
64333      }
64334    },
64335    closeOnTop: {
64336      get: function get$$1() {
64337        return params.closeOnTop;
64338      }
64339    },
64340    preset: {
64341      get: function get$$1() {
64342        if (_this.parent) {
64343          return _this.getRoot().preset;
64344        }
64345
64346        return params.load.preset;
64347      },
64348      set: function set$$1(v) {
64349        if (_this.parent) {
64350          _this.getRoot().preset = v;
64351        } else {
64352          params.load.preset = v;
64353        }
64354
64355        setPresetSelectIndex(this);
64356
64357        _this.revert();
64358      }
64359    },
64360    width: {
64361      get: function get$$1() {
64362        return params.width;
64363      },
64364      set: function set$$1(v) {
64365        params.width = v;
64366        setWidth(_this, v);
64367      }
64368    },
64369    name: {
64370      get: function get$$1() {
64371        return params.name;
64372      },
64373      set: function set$$1(v) {
64374        params.name = v;
64375
64376        if (titleRow) {
64377          titleRow.innerHTML = params.name;
64378        }
64379      }
64380    },
64381    closed: {
64382      get: function get$$1() {
64383        return params.closed;
64384      },
64385      set: function set$$1(v) {
64386        params.closed = v;
64387
64388        if (params.closed) {
64389          dom.addClass(_this.__ul, GUI.CLASS_CLOSED);
64390        } else {
64391          dom.removeClass(_this.__ul, GUI.CLASS_CLOSED);
64392        }
64393
64394        this.onResize();
64395
64396        if (_this.__closeButton) {
64397          _this.__closeButton.innerHTML = v ? GUI.TEXT_OPEN : GUI.TEXT_CLOSED;
64398        }
64399      }
64400    },
64401    load: {
64402      get: function get$$1() {
64403        return params.load;
64404      }
64405    },
64406    useLocalStorage: {
64407      get: function get$$1() {
64408        return useLocalStorage;
64409      },
64410      set: function set$$1(bool) {
64411        if (SUPPORTS_LOCAL_STORAGE) {
64412          useLocalStorage = bool;
64413
64414          if (bool) {
64415            dom.bind(window, 'unload', saveToLocalStorage);
64416          } else {
64417            dom.unbind(window, 'unload', saveToLocalStorage);
64418          }
64419
64420          localStorage.setItem(getLocalStorageHash(_this, 'isLocal'), bool);
64421        }
64422      }
64423    }
64424  });
64425
64426  if (Common.isUndefined(params.parent)) {
64427    this.closed = params.closed || false;
64428    dom.addClass(this.domElement, GUI.CLASS_MAIN);
64429    dom.makeSelectable(this.domElement, false);
64430
64431    if (SUPPORTS_LOCAL_STORAGE) {
64432      if (useLocalStorage) {
64433        _this.useLocalStorage = true;
64434        var savedGui = localStorage.getItem(getLocalStorageHash(this, 'gui'));
64435
64436        if (savedGui) {
64437          params.load = JSON.parse(savedGui);
64438        }
64439      }
64440    }
64441
64442    this.__closeButton = document.createElement('div');
64443    this.__closeButton.innerHTML = GUI.TEXT_CLOSED;
64444    dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_BUTTON);
64445
64446    if (params.closeOnTop) {
64447      dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_TOP);
64448      this.domElement.insertBefore(this.__closeButton, this.domElement.childNodes[0]);
64449    } else {
64450      dom.addClass(this.__closeButton, GUI.CLASS_CLOSE_BOTTOM);
64451      this.domElement.appendChild(this.__closeButton);
64452    }
64453
64454    dom.bind(this.__closeButton, 'click', function () {
64455      _this.closed = !_this.closed;
64456    });
64457  } else {
64458    if (params.closed === undefined) {
64459      params.closed = true;
64460    }
64461
64462    var titleRowName = document.createTextNode(params.name);
64463    dom.addClass(titleRowName, 'controller-name');
64464    titleRow = addRow(_this, titleRowName);
64465
64466    var onClickTitle = function onClickTitle(e) {
64467      e.preventDefault();
64468      _this.closed = !_this.closed;
64469      return false;
64470    };
64471
64472    dom.addClass(this.__ul, GUI.CLASS_CLOSED);
64473    dom.addClass(titleRow, 'title');
64474    dom.bind(titleRow, 'click', onClickTitle);
64475
64476    if (!params.closed) {
64477      this.closed = false;
64478    }
64479  }
64480
64481  if (params.autoPlace) {
64482    if (Common.isUndefined(params.parent)) {
64483      if (autoPlaceVirgin) {
64484        autoPlaceContainer = document.createElement('div');
64485        dom.addClass(autoPlaceContainer, CSS_NAMESPACE);
64486        dom.addClass(autoPlaceContainer, GUI.CLASS_AUTO_PLACE_CONTAINER);
64487        document.body.appendChild(autoPlaceContainer);
64488        autoPlaceVirgin = false;
64489      }
64490
64491      autoPlaceContainer.appendChild(this.domElement);
64492      dom.addClass(this.domElement, GUI.CLASS_AUTO_PLACE);
64493    }
64494
64495    if (!this.parent) {
64496      setWidth(_this, params.width);
64497    }
64498  }
64499
64500  this.__resizeHandler = function () {
64501    _this.onResizeDebounced();
64502  };
64503
64504  dom.bind(window, 'resize', this.__resizeHandler);
64505  dom.bind(this.__ul, 'webkitTransitionEnd', this.__resizeHandler);
64506  dom.bind(this.__ul, 'transitionend', this.__resizeHandler);
64507  dom.bind(this.__ul, 'oTransitionEnd', this.__resizeHandler);
64508  this.onResize();
64509
64510  if (params.resizable) {
64511    addResizeHandle(this);
64512  }
64513
64514  saveToLocalStorage = function saveToLocalStorage() {
64515    if (SUPPORTS_LOCAL_STORAGE && localStorage.getItem(getLocalStorageHash(_this, 'isLocal')) === 'true') {
64516      localStorage.setItem(getLocalStorageHash(_this, 'gui'), JSON.stringify(_this.getSaveObject()));
64517    }
64518  };
64519
64520  this.saveToLocalStorageIfPossible = saveToLocalStorage;
64521
64522  function resetWidth() {
64523    var root = _this.getRoot();
64524
64525    root.width += 1;
64526    Common.defer(function () {
64527      root.width -= 1;
64528    });
64529  }
64530
64531  if (!params.parent) {
64532    resetWidth();
64533  }
64534};
64535
64536GUI.toggleHide = function () {
64537  hide = !hide;
64538  Common.each(hideableGuis, function (gui) {
64539    gui.domElement.style.display = hide ? 'none' : '';
64540  });
64541};
64542
64543GUI.CLASS_AUTO_PLACE = 'a';
64544GUI.CLASS_AUTO_PLACE_CONTAINER = 'ac';
64545GUI.CLASS_MAIN = 'main';
64546GUI.CLASS_CONTROLLER_ROW = 'cr';
64547GUI.CLASS_TOO_TALL = 'taller-than-window';
64548GUI.CLASS_CLOSED = 'closed';
64549GUI.CLASS_CLOSE_BUTTON = 'close-button';
64550GUI.CLASS_CLOSE_TOP = 'close-top';
64551GUI.CLASS_CLOSE_BOTTOM = 'close-bottom';
64552GUI.CLASS_DRAG = 'drag';
64553GUI.DEFAULT_WIDTH = 245;
64554GUI.TEXT_CLOSED = 'Close Controls';
64555GUI.TEXT_OPEN = 'Open Controls';
64556
64557GUI._keydownHandler = function (e) {
64558  if (document.activeElement.type !== 'text' && (e.which === HIDE_KEY_CODE || e.keyCode === HIDE_KEY_CODE)) {
64559    GUI.toggleHide();
64560  }
64561};
64562
64563dom.bind(window, 'keydown', GUI._keydownHandler, false);
64564Common.extend(GUI.prototype, {
64565  add: function add(object, property) {
64566    return _add(this, object, property, {
64567      factoryArgs: Array.prototype.slice.call(arguments, 2)
64568    });
64569  },
64570  addColor: function addColor(object, property) {
64571    return _add(this, object, property, {
64572      color: true
64573    });
64574  },
64575  remove: function remove(controller) {
64576    this.__ul.removeChild(controller.__li);
64577
64578    this.__controllers.splice(this.__controllers.indexOf(controller), 1);
64579
64580    var _this = this;
64581
64582    Common.defer(function () {
64583      _this.onResize();
64584    });
64585  },
64586  destroy: function destroy() {
64587    if (this.parent) {
64588      throw new Error('Only the root GUI should be removed with .destroy(). ' + 'For subfolders, use gui.removeFolder(folder) instead.');
64589    }
64590
64591    if (this.autoPlace) {
64592      autoPlaceContainer.removeChild(this.domElement);
64593    }
64594
64595    var _this = this;
64596
64597    Common.each(this.__folders, function (subfolder) {
64598      _this.removeFolder(subfolder);
64599    });
64600    dom.unbind(window, 'keydown', GUI._keydownHandler, false);
64601    removeListeners(this);
64602  },
64603  addFolder: function addFolder(name) {
64604    if (this.__folders[name] !== undefined) {
64605      throw new Error('You already have a folder in this GUI by the' + ' name "' + name + '"');
64606    }
64607
64608    var newGuiParams = {
64609      name: name,
64610      parent: this
64611    };
64612    newGuiParams.autoPlace = this.autoPlace;
64613
64614    if (this.load && this.load.folders && this.load.folders[name]) {
64615      newGuiParams.closed = this.load.folders[name].closed;
64616      newGuiParams.load = this.load.folders[name];
64617    }
64618
64619    var gui = new GUI(newGuiParams);
64620    this.__folders[name] = gui;
64621    var li = addRow(this, gui.domElement);
64622    dom.addClass(li, 'folder');
64623    return gui;
64624  },
64625  removeFolder: function removeFolder(folder) {
64626    this.__ul.removeChild(folder.domElement.parentElement);
64627
64628    delete this.__folders[folder.name];
64629
64630    if (this.load && this.load.folders && this.load.folders[folder.name]) {
64631      delete this.load.folders[folder.name];
64632    }
64633
64634    removeListeners(folder);
64635
64636    var _this = this;
64637
64638    Common.each(folder.__folders, function (subfolder) {
64639      folder.removeFolder(subfolder);
64640    });
64641    Common.defer(function () {
64642      _this.onResize();
64643    });
64644  },
64645  open: function open() {
64646    this.closed = false;
64647  },
64648  close: function close() {
64649    this.closed = true;
64650  },
64651  hide: function hide() {
64652    this.domElement.style.display = 'none';
64653  },
64654  show: function show() {
64655    this.domElement.style.display = '';
64656  },
64657  onResize: function onResize() {
64658    var root = this.getRoot();
64659
64660    if (root.scrollable) {
64661      var top = dom.getOffset(root.__ul).top;
64662      var h = 0;
64663      Common.each(root.__ul.childNodes, function (node) {
64664        if (!(root.autoPlace && node === root.__save_row)) {
64665          h += dom.getHeight(node);
64666        }
64667      });
64668
64669      if (window.innerHeight - top - CLOSE_BUTTON_HEIGHT < h) {
64670        dom.addClass(root.domElement, GUI.CLASS_TOO_TALL);
64671        root.__ul.style.height = window.innerHeight - top - CLOSE_BUTTON_HEIGHT + 'px';
64672      } else {
64673        dom.removeClass(root.domElement, GUI.CLASS_TOO_TALL);
64674        root.__ul.style.height = 'auto';
64675      }
64676    }
64677
64678    if (root.__resize_handle) {
64679      Common.defer(function () {
64680        root.__resize_handle.style.height = root.__ul.offsetHeight + 'px';
64681      });
64682    }
64683
64684    if (root.__closeButton) {
64685      root.__closeButton.style.width = root.width + 'px';
64686    }
64687  },
64688  onResizeDebounced: Common.debounce(function () {
64689    this.onResize();
64690  }, 50),
64691  remember: function remember() {
64692    if (Common.isUndefined(SAVE_DIALOGUE)) {
64693      SAVE_DIALOGUE = new CenteredDiv();
64694      SAVE_DIALOGUE.domElement.innerHTML = saveDialogContents;
64695    }
64696
64697    if (this.parent) {
64698      throw new Error('You can only call remember on a top level GUI.');
64699    }
64700
64701    var _this = this;
64702
64703    Common.each(Array.prototype.slice.call(arguments), function (object) {
64704      if (_this.__rememberedObjects.length === 0) {
64705        addSaveMenu(_this);
64706      }
64707
64708      if (_this.__rememberedObjects.indexOf(object) === -1) {
64709        _this.__rememberedObjects.push(object);
64710      }
64711    });
64712
64713    if (this.autoPlace) {
64714      setWidth(this, this.width);
64715    }
64716  },
64717  getRoot: function getRoot() {
64718    var gui = this;
64719
64720    while (gui.parent) {
64721      gui = gui.parent;
64722    }
64723
64724    return gui;
64725  },
64726  getSaveObject: function getSaveObject() {
64727    var toReturn = this.load;
64728    toReturn.closed = this.closed;
64729
64730    if (this.__rememberedObjects.length > 0) {
64731      toReturn.preset = this.preset;
64732
64733      if (!toReturn.remembered) {
64734        toReturn.remembered = {};
64735      }
64736
64737      toReturn.remembered[this.preset] = getCurrentPreset(this);
64738    }
64739
64740    toReturn.folders = {};
64741    Common.each(this.__folders, function (element, key) {
64742      toReturn.folders[key] = element.getSaveObject();
64743    });
64744    return toReturn;
64745  },
64746  save: function save() {
64747    if (!this.load.remembered) {
64748      this.load.remembered = {};
64749    }
64750
64751    this.load.remembered[this.preset] = getCurrentPreset(this);
64752    markPresetModified(this, false);
64753    this.saveToLocalStorageIfPossible();
64754  },
64755  saveAs: function saveAs(presetName) {
64756    if (!this.load.remembered) {
64757      this.load.remembered = {};
64758      this.load.remembered[DEFAULT_DEFAULT_PRESET_NAME] = getCurrentPreset(this, true);
64759    }
64760
64761    this.load.remembered[presetName] = getCurrentPreset(this);
64762    this.preset = presetName;
64763    addPresetOption(this, presetName, true);
64764    this.saveToLocalStorageIfPossible();
64765  },
64766  revert: function revert(gui) {
64767    Common.each(this.__controllers, function (controller) {
64768      if (!this.getRoot().load.remembered) {
64769        controller.setValue(controller.initialValue);
64770      } else {
64771        recallSavedValue(gui || this.getRoot(), controller);
64772      }
64773
64774      if (controller.__onFinishChange) {
64775        controller.__onFinishChange.call(controller, controller.getValue());
64776      }
64777    }, this);
64778    Common.each(this.__folders, function (folder) {
64779      folder.revert(folder);
64780    });
64781
64782    if (!gui) {
64783      markPresetModified(this.getRoot(), false);
64784    }
64785  },
64786  listen: function listen(controller) {
64787    var init = this.__listening.length === 0;
64788
64789    this.__listening.push(controller);
64790
64791    if (init) {
64792      updateDisplays(this.__listening);
64793    }
64794  },
64795  updateDisplay: function updateDisplay() {
64796    Common.each(this.__controllers, function (controller) {
64797      controller.updateDisplay();
64798    });
64799    Common.each(this.__folders, function (folder) {
64800      folder.updateDisplay();
64801    });
64802  }
64803});
64804
64805function addRow(gui, newDom, liBefore) {
64806  var li = document.createElement('li');
64807
64808  if (newDom) {
64809    li.appendChild(newDom);
64810  }
64811
64812  if (liBefore) {
64813    gui.__ul.insertBefore(li, liBefore);
64814  } else {
64815    gui.__ul.appendChild(li);
64816  }
64817
64818  gui.onResize();
64819  return li;
64820}
64821
64822function removeListeners(gui) {
64823  dom.unbind(window, 'resize', gui.__resizeHandler);
64824
64825  if (gui.saveToLocalStorageIfPossible) {
64826    dom.unbind(window, 'unload', gui.saveToLocalStorageIfPossible);
64827  }
64828}
64829
64830function markPresetModified(gui, modified) {
64831  var opt = gui.__preset_select[gui.__preset_select.selectedIndex];
64832
64833  if (modified) {
64834    opt.innerHTML = opt.value + '*';
64835  } else {
64836    opt.innerHTML = opt.value;
64837  }
64838}
64839
64840function augmentController(gui, li, controller) {
64841  controller.__li = li;
64842  controller.__gui = gui;
64843  Common.extend(controller, {
64844    options: function options(_options) {
64845      if (arguments.length > 1) {
64846        var nextSibling = controller.__li.nextElementSibling;
64847        controller.remove();
64848        return _add(gui, controller.object, controller.property, {
64849          before: nextSibling,
64850          factoryArgs: [Common.toArray(arguments)]
64851        });
64852      }
64853
64854      if (Common.isArray(_options) || Common.isObject(_options)) {
64855        var _nextSibling = controller.__li.nextElementSibling;
64856        controller.remove();
64857        return _add(gui, controller.object, controller.property, {
64858          before: _nextSibling,
64859          factoryArgs: [_options]
64860        });
64861      }
64862    },
64863    name: function name(_name) {
64864      controller.__li.firstElementChild.firstElementChild.innerHTML = _name;
64865      return controller;
64866    },
64867    listen: function listen() {
64868      controller.__gui.listen(controller);
64869
64870      return controller;
64871    },
64872    remove: function remove() {
64873      controller.__gui.remove(controller);
64874
64875      return controller;
64876    }
64877  });
64878
64879  if (controller instanceof NumberControllerSlider) {
64880    var box = new NumberControllerBox(controller.object, controller.property, {
64881      min: controller.__min,
64882      max: controller.__max,
64883      step: controller.__step
64884    });
64885    Common.each(['updateDisplay', 'onChange', 'onFinishChange', 'step', 'min', 'max'], function (method) {
64886      var pc = controller[method];
64887      var pb = box[method];
64888
64889      controller[method] = box[method] = function () {
64890        var args = Array.prototype.slice.call(arguments);
64891        pb.apply(box, args);
64892        return pc.apply(controller, args);
64893      };
64894    });
64895    dom.addClass(li, 'has-slider');
64896    controller.domElement.insertBefore(box.domElement, controller.domElement.firstElementChild);
64897  } else if (controller instanceof NumberControllerBox) {
64898    var r = function r(returned) {
64899      if (Common.isNumber(controller.__min) && Common.isNumber(controller.__max)) {
64900        var oldName = controller.__li.firstElementChild.firstElementChild.innerHTML;
64901        var wasListening = controller.__gui.__listening.indexOf(controller) > -1;
64902        controller.remove();
64903
64904        var newController = _add(gui, controller.object, controller.property, {
64905          before: controller.__li.nextElementSibling,
64906          factoryArgs: [controller.__min, controller.__max, controller.__step]
64907        });
64908
64909        newController.name(oldName);
64910        if (wasListening) newController.listen();
64911        return newController;
64912      }
64913
64914      return returned;
64915    };
64916
64917    controller.min = Common.compose(r, controller.min);
64918    controller.max = Common.compose(r, controller.max);
64919  } else if (controller instanceof BooleanController) {
64920    dom.bind(li, 'click', function () {
64921      dom.fakeEvent(controller.__checkbox, 'click');
64922    });
64923    dom.bind(controller.__checkbox, 'click', function (e) {
64924      e.stopPropagation();
64925    });
64926  } else if (controller instanceof FunctionController) {
64927    dom.bind(li, 'click', function () {
64928      dom.fakeEvent(controller.__button, 'click');
64929    });
64930    dom.bind(li, 'mouseover', function () {
64931      dom.addClass(controller.__button, 'hover');
64932    });
64933    dom.bind(li, 'mouseout', function () {
64934      dom.removeClass(controller.__button, 'hover');
64935    });
64936  } else if (controller instanceof ColorController) {
64937    dom.addClass(li, 'color');
64938    controller.updateDisplay = Common.compose(function (val) {
64939      li.style.borderLeftColor = controller.__color.toString();
64940      return val;
64941    }, controller.updateDisplay);
64942    controller.updateDisplay();
64943  }
64944
64945  controller.setValue = Common.compose(function (val) {
64946    if (gui.getRoot().__preset_select && controller.isModified()) {
64947      markPresetModified(gui.getRoot(), true);
64948    }
64949
64950    return val;
64951  }, controller.setValue);
64952}
64953
64954function recallSavedValue(gui, controller) {
64955  var root = gui.getRoot();
64956
64957  var matchedIndex = root.__rememberedObjects.indexOf(controller.object);
64958
64959  if (matchedIndex !== -1) {
64960    var controllerMap = root.__rememberedObjectIndecesToControllers[matchedIndex];
64961
64962    if (controllerMap === undefined) {
64963      controllerMap = {};
64964      root.__rememberedObjectIndecesToControllers[matchedIndex] = controllerMap;
64965    }
64966
64967    controllerMap[controller.property] = controller;
64968
64969    if (root.load && root.load.remembered) {
64970      var presetMap = root.load.remembered;
64971      var preset = void 0;
64972
64973      if (presetMap[gui.preset]) {
64974        preset = presetMap[gui.preset];
64975      } else if (presetMap[DEFAULT_DEFAULT_PRESET_NAME]) {
64976        preset = presetMap[DEFAULT_DEFAULT_PRESET_NAME];
64977      } else {
64978        return;
64979      }
64980
64981      if (preset[matchedIndex] && preset[matchedIndex][controller.property] !== undefined) {
64982        var value = preset[matchedIndex][controller.property];
64983        controller.initialValue = value;
64984        controller.setValue(value);
64985      }
64986    }
64987  }
64988}
64989
64990function _add(gui, object, property, params) {
64991  if (object[property] === undefined) {
64992    throw new Error('Object "' + object + '" has no property "' + property + '"');
64993  }
64994
64995  var controller = void 0;
64996
64997  if (params.color) {
64998    controller = new ColorController(object, property);
64999  } else {
65000    var factoryArgs = [object, property].concat(params.factoryArgs);
65001    controller = ControllerFactory.apply(gui, factoryArgs);
65002  }
65003
65004  if (params.before instanceof Controller) {
65005    params.before = params.before.__li;
65006  }
65007
65008  recallSavedValue(gui, controller);
65009  dom.addClass(controller.domElement, 'c');
65010  var name = document.createElement('span');
65011  dom.addClass(name, 'property-name');
65012  name.innerHTML = controller.property;
65013  var container = document.createElement('div');
65014  container.appendChild(name);
65015  container.appendChild(controller.domElement);
65016  var li = addRow(gui, container, params.before);
65017  dom.addClass(li, GUI.CLASS_CONTROLLER_ROW);
65018
65019  if (controller instanceof ColorController) {
65020    dom.addClass(li, 'color');
65021  } else {
65022    dom.addClass(li, _typeof(controller.getValue()));
65023  }
65024
65025  augmentController(gui, li, controller);
65026
65027  gui.__controllers.push(controller);
65028
65029  return controller;
65030}
65031
65032function getLocalStorageHash(gui, key) {
65033  return document.location.href + '.' + key;
65034}
65035
65036function addPresetOption(gui, name, setSelected) {
65037  var opt = document.createElement('option');
65038  opt.innerHTML = name;
65039  opt.value = name;
65040
65041  gui.__preset_select.appendChild(opt);
65042
65043  if (setSelected) {
65044    gui.__preset_select.selectedIndex = gui.__preset_select.length - 1;
65045  }
65046}
65047
65048function showHideExplain(gui, explain) {
65049  explain.style.display = gui.useLocalStorage ? 'block' : 'none';
65050}
65051
65052function addSaveMenu(gui) {
65053  var div = gui.__save_row = document.createElement('li');
65054  dom.addClass(gui.domElement, 'has-save');
65055
65056  gui.__ul.insertBefore(div, gui.__ul.firstChild);
65057
65058  dom.addClass(div, 'save-row');
65059  var gears = document.createElement('span');
65060  gears.innerHTML = '&nbsp;';
65061  dom.addClass(gears, 'button gears');
65062  var button = document.createElement('span');
65063  button.innerHTML = 'Save';
65064  dom.addClass(button, 'button');
65065  dom.addClass(button, 'save');
65066  var button2 = document.createElement('span');
65067  button2.innerHTML = 'New';
65068  dom.addClass(button2, 'button');
65069  dom.addClass(button2, 'save-as');
65070  var button3 = document.createElement('span');
65071  button3.innerHTML = 'Revert';
65072  dom.addClass(button3, 'button');
65073  dom.addClass(button3, 'revert');
65074  var select = gui.__preset_select = document.createElement('select');
65075
65076  if (gui.load && gui.load.remembered) {
65077    Common.each(gui.load.remembered, function (value, key) {
65078      addPresetOption(gui, key, key === gui.preset);
65079    });
65080  } else {
65081    addPresetOption(gui, DEFAULT_DEFAULT_PRESET_NAME, false);
65082  }
65083
65084  dom.bind(select, 'change', function () {
65085    for (var index = 0; index < gui.__preset_select.length; index++) {
65086      gui.__preset_select[index].innerHTML = gui.__preset_select[index].value;
65087    }
65088
65089    gui.preset = this.value;
65090  });
65091  div.appendChild(select);
65092  div.appendChild(gears);
65093  div.appendChild(button);
65094  div.appendChild(button2);
65095  div.appendChild(button3);
65096
65097  if (SUPPORTS_LOCAL_STORAGE) {
65098    var explain = document.getElementById('dg-local-explain');
65099    var localStorageCheckBox = document.getElementById('dg-local-storage');
65100    var saveLocally = document.getElementById('dg-save-locally');
65101    saveLocally.style.display = 'block';
65102
65103    if (localStorage.getItem(getLocalStorageHash(gui, 'isLocal')) === 'true') {
65104      localStorageCheckBox.setAttribute('checked', 'checked');
65105    }
65106
65107    showHideExplain(gui, explain);
65108    dom.bind(localStorageCheckBox, 'change', function () {
65109      gui.useLocalStorage = !gui.useLocalStorage;
65110      showHideExplain(gui, explain);
65111    });
65112  }
65113
65114  var newConstructorTextArea = document.getElementById('dg-new-constructor');
65115  dom.bind(newConstructorTextArea, 'keydown', function (e) {
65116    if (e.metaKey && (e.which === 67 || e.keyCode === 67)) {
65117      SAVE_DIALOGUE.hide();
65118    }
65119  });
65120  dom.bind(gears, 'click', function () {
65121    newConstructorTextArea.innerHTML = JSON.stringify(gui.getSaveObject(), undefined, 2);
65122    SAVE_DIALOGUE.show();
65123    newConstructorTextArea.focus();
65124    newConstructorTextArea.select();
65125  });
65126  dom.bind(button, 'click', function () {
65127    gui.save();
65128  });
65129  dom.bind(button2, 'click', function () {
65130    var presetName = prompt('Enter a new preset name.');
65131
65132    if (presetName) {
65133      gui.saveAs(presetName);
65134    }
65135  });
65136  dom.bind(button3, 'click', function () {
65137    gui.revert();
65138  });
65139}
65140
65141function addResizeHandle(gui) {
65142  var pmouseX = void 0;
65143  gui.__resize_handle = document.createElement('div');
65144  Common.extend(gui.__resize_handle.style, {
65145    width: '6px',
65146    marginLeft: '-3px',
65147    height: '200px',
65148    cursor: 'ew-resize',
65149    position: 'absolute'
65150  });
65151
65152  function drag(e) {
65153    e.preventDefault();
65154    gui.width += pmouseX - e.clientX;
65155    gui.onResize();
65156    pmouseX = e.clientX;
65157    return false;
65158  }
65159
65160  function dragStop() {
65161    dom.removeClass(gui.__closeButton, GUI.CLASS_DRAG);
65162    dom.unbind(window, 'mousemove', drag);
65163    dom.unbind(window, 'mouseup', dragStop);
65164  }
65165
65166  function dragStart(e) {
65167    e.preventDefault();
65168    pmouseX = e.clientX;
65169    dom.addClass(gui.__closeButton, GUI.CLASS_DRAG);
65170    dom.bind(window, 'mousemove', drag);
65171    dom.bind(window, 'mouseup', dragStop);
65172    return false;
65173  }
65174
65175  dom.bind(gui.__resize_handle, 'mousedown', dragStart);
65176  dom.bind(gui.__closeButton, 'mousedown', dragStart);
65177  gui.domElement.insertBefore(gui.__resize_handle, gui.domElement.firstElementChild);
65178}
65179
65180function setWidth(gui, w) {
65181  gui.domElement.style.width = w + 'px';
65182
65183  if (gui.__save_row && gui.autoPlace) {
65184    gui.__save_row.style.width = w + 'px';
65185  }
65186
65187  if (gui.__closeButton) {
65188    gui.__closeButton.style.width = w + 'px';
65189  }
65190}
65191
65192function getCurrentPreset(gui, useInitialValues) {
65193  var toReturn = {};
65194  Common.each(gui.__rememberedObjects, function (val, index) {
65195    var savedValues = {};
65196    var controllerMap = gui.__rememberedObjectIndecesToControllers[index];
65197    Common.each(controllerMap, function (controller, property) {
65198      savedValues[property] = useInitialValues ? controller.initialValue : controller.getValue();
65199    });
65200    toReturn[index] = savedValues;
65201  });
65202  return toReturn;
65203}
65204
65205function setPresetSelectIndex(gui) {
65206  for (var index = 0; index < gui.__preset_select.length; index++) {
65207    if (gui.__preset_select[index].value === gui.preset) {
65208      gui.__preset_select.selectedIndex = index;
65209    }
65210  }
65211}
65212
65213function updateDisplays(controllerArray) {
65214  if (controllerArray.length !== 0) {
65215    requestAnimationFrame$1.call(window, function () {
65216      updateDisplays(controllerArray);
65217    });
65218  }
65219
65220  Common.each(controllerArray, function (c) {
65221    c.updateDisplay();
65222  });
65223}
65224
65225var color = {
65226  Color: Color,
65227  math: ColorMath,
65228  interpret: interpret
65229};
65230exports.color = color;
65231var controllers = {
65232  Controller: Controller,
65233  BooleanController: BooleanController,
65234  OptionController: OptionController,
65235  StringController: StringController,
65236  NumberController: NumberController,
65237  NumberControllerBox: NumberControllerBox,
65238  NumberControllerSlider: NumberControllerSlider,
65239  FunctionController: FunctionController,
65240  ColorController: ColorController
65241};
65242exports.controllers = controllers;
65243var dom$1 = {
65244  dom: dom
65245};
65246exports.dom = dom$1;
65247var gui = {
65248  GUI: GUI
65249};
65250exports.gui = gui;
65251var GUI$1 = GUI;
65252exports.GUI = GUI$1;
65253var index = {
65254  color: color,
65255  controllers: controllers,
65256  dom: dom$1,
65257  gui: gui,
65258  GUI: GUI$1
65259};
65260var _default = index;
65261exports.default = _default;
65262},{}],"node_modules/stats.js/build/stats.min.js":[function(require,module,exports) {
65263var define;
65264// stats.js - http://github.com/mrdoob/stats.js
65265(function(f,e){"object"===typeof exports&&"undefined"!==typeof module?module.exports=e():"function"===typeof define&&define.amd?define(e):f.Stats=e()})(this,function(){var f=function(){function e(a){c.appendChild(a.dom);return a}function u(a){for(var d=0;d<c.children.length;d++)c.children[d].style.display=d===a?"block":"none";l=a}var l=0,c=document.createElement("div");c.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000";c.addEventListener("click",function(a){a.preventDefault();
65266u(++l%c.children.length)},!1);var k=(performance||Date).now(),g=k,a=0,r=e(new f.Panel("FPS","#0ff","#002")),h=e(new f.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var t=e(new f.Panel("MB","#f08","#201"));u(0);return{REVISION:16,dom:c,addPanel:e,showPanel:u,begin:function(){k=(performance||Date).now()},end:function(){a++;var c=(performance||Date).now();h.update(c-k,200);if(c>g+1E3&&(r.update(1E3*a/(c-g),100),g=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/
652671048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){k=this.end()},domElement:c,setMode:u}};f.Panel=function(e,f,l){var c=Infinity,k=0,g=Math.round,a=g(window.devicePixelRatio||1),r=80*a,h=48*a,t=3*a,v=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=h;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,h);b.fillStyle=f;b.fillText(e,t,v);
65268b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(h,w){c=Math.min(c,h);k=Math.max(k,h);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=f;b.fillText(g(h)+" "+e+" ("+g(c)+"-"+g(k)+")",t,v);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,g((1-h/w)*p))}}};return f});
65269
65270},{}],"node_modules/core-js/modules/_global.js":[function(require,module,exports) {
65271
65272// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
65273var global = module.exports = typeof window != 'undefined' && window.Math == Math
65274  ? window : typeof self != 'undefined' && self.Math == Math ? self
65275  // eslint-disable-next-line no-new-func
65276  : Function('return this')();
65277if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
65278
65279},{}],"node_modules/core-js/modules/_has.js":[function(require,module,exports) {
65280var hasOwnProperty = {}.hasOwnProperty;
65281module.exports = function (it, key) {
65282  return hasOwnProperty.call(it, key);
65283};
65284
65285},{}],"node_modules/core-js/modules/_fails.js":[function(require,module,exports) {
65286module.exports = function (exec) {
65287  try {
65288    return !!exec();
65289  } catch (e) {
65290    return true;
65291  }
65292};
65293
65294},{}],"node_modules/core-js/modules/_descriptors.js":[function(require,module,exports) {
65295// Thank's IE8 for his funny defineProperty
65296module.exports = !require('./_fails')(function () {
65297  return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
65298});
65299
65300}
vendor: 4,645 bytes, lines 65300-65390
65300,{"./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/_core.js":[function(require,module,exports) {
65301var core = module.exports = { version: '2.6.11' };
65302if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
65303
65304},{}],"node_modules/core-js/modules/_is-object.js":[function(require,module,exports) {
65305module.exports = function (it) {
65306  return typeof it === 'object' ? it !== null : typeof it === 'function';
65307};
65308
65309},{}],"node_modules/core-js/modules/_an-object.js":[function(require,module,exports) {
65310var isObject = require('./_is-object');
65311module.exports = function (it) {
65312  if (!isObject(it)) throw TypeError(it + ' is not an object!');
65313  return it;
65314};
65315
65316},{"./_is-object":"node_modules/core-js/modules/_is-object.js"}],"node_modules/core-js/modules/_dom-create.js":[function(require,module,exports) {
65317var isObject = require('./_is-object');
65318var document = require('./_global').document;
65319// typeof document.createElement is 'object' in old IE
65320var is = isObject(document) && isObject(document.createElement);
65321module.exports = function (it) {
65322  return is ? document.createElement(it) : {};
65323};
65324
65325},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/_ie8-dom-define.js":[function(require,module,exports) {
65326module.exports = !require('./_descriptors') && !require('./_fails')(function () {
65327  return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;
65328});
65329
65330},{"./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_fails":"node_modules/core-js/modules/_fails.js","./_dom-create":"node_modules/core-js/modules/_dom-create.js"}],"node_modules/core-js/modules/_to-primitive.js":[function(require,module,exports) {
65331// 7.1.1 ToPrimitive(input [, PreferredType])
65332var isObject = require('./_is-object');
65333// instead of the ES6 spec version, we didn't implement @@toPrimitive case
65334// and the second argument - flag - preferred type is a string
65335module.exports = function (it, S) {
65336  if (!isObject(it)) return it;
65337  var fn, val;
65338  if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
65339  if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
65340  if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
65341  throw TypeError("Can't convert object to primitive value");
65342};
65343
65344},{"./_is-object":"node_modules/core-js/modules/_is-object.js"}],"node_modules/core-js/modules/_object-dp.js":[function(require,module,exports) {
65345var anObject = require('./_an-object');
65346var IE8_DOM_DEFINE = require('./_ie8-dom-define');
65347var toPrimitive = require('./_to-primitive');
65348var dP = Object.defineProperty;
65349
65350exports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {
65351  anObject(O);
65352  P = toPrimitive(P, true);
65353  anObject(Attributes);
65354  if (IE8_DOM_DEFINE) try {
65355    return dP(O, P, Attributes);
65356  } catch (e) { /* empty */ }
65357  if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
65358  if ('value' in Attributes) O[P] = Attributes.value;
65359  return O;
65360};
65361
65362},{"./_an-object":"node_modules/core-js/modules/_an-object.js","./_ie8-dom-define":"node_modules/core-js/modules/_ie8-dom-define.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js"}],"node_modules/core-js/modules/_property-desc.js":[function(require,module,exports) {
65363module.exports = function (bitmap, value) {
65364  return {
65365    enumerable: !(bitmap & 1),
65366    configurable: !(bitmap & 2),
65367    writable: !(bitmap & 4),
65368    value: value
65369  };
65370};
65371
65372},{}],"node_modules/core-js/modules/_hide.js":[function(require,module,exports) {
65373var dP = require('./_object-dp');
65374var createDesc = require('./_property-desc');
65375module.exports = require('./_descriptors') ? function (object, key, value) {
65376  return dP.f(object, key, createDesc(1, value));
65377} : function (object, key, value) {
65378  object[key] = value;
65379  return object;
65380};
65381
65382},{"./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_property-desc":"node_modules/core-js/modules/_property-desc.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js"}],"node_modules/core-js/modules/_uid.js":[function(require,module,exports) {
65383var id = 0;
65384var px = Math.random();
65385module.exports = function (key) {
65386  return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
65387};
65388
65389},{}],"node_modules/core-js/modules/_library.js":[function(require,module,exports) {
65390module.exports = false;
65391
65392},{}],"node_modules/core-js/modules/_shared.js":[function(require,module,exports) {
65393
65394var core = require('./_core');
65395var global = require('./_global');
65396var SHARED = '__core-js_shared__';
65397var store = global[SHARED] || (global[SHARED] = {});
65398
65399(module.exports = function (key, value) {
65400  return store[key] || (store[key] = value !== undefined ? value : {});
65401})('versions', []).push({
65402  version: core.version,
65403  mode: require('./_library') ? 'pure' : 'global',
65404  copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
65405});
65406
65407},{"./_core":"node_modules/core-js/modules/_core.js","./_global":"node_modules/core-js/modules/_global.js","./_library":"node_modules/core-js/modules/_library.js"}],"node_modules/core-js/modules/_function-to-string.js":[function(require,module,exports) {
65408module.exports = require('./_shared')('native-function-to-string', Function.toString);
65409
65410},{"./_shared":"node_modules/core-js/modules/_shared.js"}],"node_modules/core-js/modules/_redefine.js":[function(require,module,exports) {
65411
65412var global = require('./_global');
65413var hide = require('./_hide');
65414var has = require('./_has');
65415var SRC = require('./_uid')('src');
65416var $toString = require('./_function-to-string');
65417var TO_STRING = 'toString';
65418var TPL = ('' + $toString).split(TO_STRING);
65419
65420require('./_core').inspectSource = function (it) {
65421  return $toString.call(it);
65422};
65423
65424(module.exports = function (O, key, val, safe) {
65425  var isFunction = typeof val == 'function';
65426  if (isFunction) has(val, 'name') || hide(val, 'name', key);
65427  if (O[key] === val) return;
65428  if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key)));
65429  if (O === global) {
65430    O[key] = val;
65431  } else if (!safe) {
65432    delete O[key];
65433    hide(O, key, val);
65434  } else if (O[key]) {
65435    O[key] = val;
65436  } else {
65437    hide(O, key, val);
65438  }
65439// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
65440})(Function.prototype, TO_STRING, function toString() {
65441  return typeof this == 'function' && this[SRC] || $toString.call(this);
65442});
65443
65444},{"./_global":"node_modules/core-js/modules/_global.js","./_hide":"node_modules/core-js/modules/_hide.js","./_has":"node_modules/core-js/modules/_has.js","./_uid":"node_modules/core-js/modules/_uid.js","./_function-to-string":"node_modules/core-js/modules/_function-to-string.js","./_core":"node_modules/core-js/modules/_core.js"}],"node_modules/core-js/modules/_a-function.js":[function(require,module,exports) {
65445module.exports = function (it) {
65446  if (typeof it != 'function') throw TypeError(it + ' is not a function!');
65447  return it;
65448};
65449
65450},{}],"node_modules/core-js/modules/_ctx.js":[function(require,module,exports) {
65451// optional / simple context binding
65452var aFunction = require('./_a-function');
65453module.exports = function (fn, that, length) {
65454  aFunction(fn);
65455  if (that === undefined) return fn;
65456  switch (length) {
65457    case 1: return function (a) {
65458      return fn.call(that, a);
65459    };
65460    case 2: return function (a, b) {
65461      return fn.call(that, a, b);
65462    };
65463    case 3: return function (a, b, c) {
65464      return fn.call(that, a, b, c);
65465    };
65466  }
65467  return function (/* ...args */) {
65468    return fn.apply(that, arguments);
65469  };
65470};
65471
65472},{"./_a-function":"node_modules/core-js/modules/_a-function.js"}],"node_modules/core-js/modules/_export.js":[function(require,module,exports) {
65473
65474var global = require('./_global');
65475var core = require('./_core');
65476var hide = require('./_hide');
65477var redefine = require('./_redefine');
65478var ctx = require('./_ctx');
65479var PROTOTYPE = 'prototype';
65480
65481var $export = function (type, name, source) {
65482  var IS_FORCED = type & $export.F;
65483  var IS_GLOBAL = type & $export.G;
65484  var IS_STATIC = type & $export.S;
65485  var IS_PROTO = type & $export.P;
65486  var IS_BIND = type & $export.B;
65487  var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE];
65488  var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
65489  var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
65490  var key, own, out, exp;
65491  if (IS_GLOBAL) source = name;
65492  for (key in source) {
65493    // contains in native
65494    own = !IS_FORCED && target && target[key] !== undefined;
65495    // export native or passed
65496    out = (own ? target : source)[key];
65497    // bind timers to global for call from export context
65498    exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
65499    // extend global
65500    if (target) redefine(target, key, out, type & $export.U);
65501    // export
65502    if (exports[key] != out) hide(exports, key, exp);
65503    if (IS_PROTO && expProto[key] != out) expProto[key] = out;
65504  }
65505};
65506global.core = core;
65507// type bitmap
65508$export.F = 1;   // forced
65509$export.G = 2;   // global
65510$export.S = 4;   // static
65511$export.P = 8;   // proto
65512$export.B = 16;  // bind
65513$export.W = 32;  // wrap
65514$export.U = 64;  // safe
65515$export.R = 128; // real proto method for `library`
65516module.exports = $export;
65517
65518},{"./_global":"node_modules/core-js/modules/_global.js","./_core":"node_modules/core-js/modules/_core.js","./_hide":"node_modules/core-js/modules/_hide.js","./_redefine":"node_modules/core-js/modules/_redefine.js","./_ctx":"node_modules/core-js/modules/_ctx.js"}],"node_modules/core-js/modules/_meta.js":[function(require,module,exports) {
65519var META = require('./_uid')('meta');
65520var isObject = require('./_is-object');
65521var has = require('./_has');
65522var setDesc = require('./_object-dp').f;
65523var id = 0;
65524var isExtensible = Object.isExtensible || function () {
65525  return true;
65526};
65527var FREEZE = !require('./_fails')(function () {
65528  return isExtensible(Object.preventExtensions({}));
65529});
65530var setMeta = function (it) {
65531  setDesc(it, META, { value: {
65532    i: 'O' + ++id, // object ID
65533    w: {}          // weak collections IDs
65534  } });
65535};
65536var fastKey = function (it, create) {
65537  // return primitive with prefix
65538  if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
65539  if (!has(it, META)) {
65540    // can't set metadata to uncaught frozen object
65541    if (!isExtensible(it)) return 'F';
65542    // not necessary to add metadata
65543    if (!create) return 'E';
65544    // add missing metadata
65545    setMeta(it);
65546  // return object ID
65547  } return it[META].i;
65548};
65549var getWeak = function (it, create) {
65550  if (!has(it, META)) {
65551    // can't set metadata to uncaught frozen object
65552    if (!isExtensible(it)) return true;
65553    // not necessary to add metadata
65554    if (!create) return false;
65555    // add missing metadata
65556    setMeta(it);
65557  // return hash weak collections IDs
65558  } return it[META].w;
65559};
65560// add metadata on freeze-family methods calling
65561var onFreeze = function (it) {
65562  if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it);
65563  return it;
65564};
65565var meta = module.exports = {
65566  KEY: META,
65567  NEED: false,
65568  fastKey: fastKey,
65569  getWeak: getWeak,
65570  onFreeze: onFreeze
65571};
65572
65573},{"./_uid":"node_modules/core-js/modules/_uid.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_has":"node_modules/core-js/modules/_has.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/_wks.js":[function(require,module,exports) {
65574var store = require('./_shared')('wks');
65575var uid = require('./_uid');
65576var Symbol = require('./_global').Symbol;
65577var USE_SYMBOL = typeof Symbol == 'function';
65578
65579var $exports = module.exports = function (name) {
65580  return store[name] || (store[name] =
65581    USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
65582};
65583
65584$exports.store = store;
65585
65586},{"./_shared":"node_modules/core-js/modules/_shared.js","./_uid":"node_modules/core-js/modules/_uid.js","./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/_set-to-string-tag.js":[function(require,module,exports) {
65587var def = require('./_object-dp').f;
65588var has = require('./_has');
65589var TAG = require('./_wks')('toStringTag');
65590
65591module.exports = function (it, tag, stat) {
65592  if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
65593};
65594
65595},{"./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_has":"node_modules/core-js/modules/_has.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/_wks-ext.js":[function(require,module,exports) {
65596exports.f = require('./_wks');
65597
65598},{"./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/_wks-define.js":[function(require,module,exports) {
65599
65600var global = require('./_global');
65601var core = require('./_core');
65602var LIBRARY = require('./_library');
65603var wksExt = require('./_wks-ext');
65604var defineProperty = require('./_object-dp').f;
65605module.exports = function (name) {
65606  var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
65607  if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
65608};
65609
65610},{"./_global":"node_modules/core-js/modules/_global.js","./_core":"node_modules/core-js/modules/_core.js","./_library":"node_modules/core-js/modules/_library.js","./_wks-ext":"node_modules/core-js/modules/_wks-ext.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js"}],"node_modules/core-js/modules/_cof.js":[function(require,module,exports) {
65611var toString = {}.toString;
65612
65613module.exports = function (it) {
65614  return toString.call(it).slice(8, -1);
65615};
65616
65617},{}],"node_modules/core-js/modules/_iobject.js":[function(require,module,exports) {
65618// fallback for non-array-like ES3 and non-enumerable old V8 strings
65619var cof = require('./_cof');
65620// eslint-disable-next-line no-prototype-builtins
65621module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
65622  return cof(it) == 'String' ? it.split('') : Object(it);
65623};
65624
65625},{"./_cof":"node_modules/core-js/modules/_cof.js"}],"node_modules/core-js/modules/_defined.js":[function(require,module,exports) {
65626// 7.2.1 RequireObjectCoercible(argument)
65627module.exports = function (it) {
65628  if (it == undefined) throw TypeError("Can't call method on  " + it);
65629  return it;
65630};
65631
65632},{}],"node_modules/core-js/modules/_to-iobject.js":[function(require,module,exports) {
65633// to indexed object, toObject with fallback for non-array-like ES3 strings
65634var IObject = require('./_iobject');
65635var defined = require('./_defined');
65636module.exports = function (it) {
65637  return IObject(defined(it));
65638};
65639
65640},{"./_iobject":"node_modules/core-js/modules/_iobject.js","./_defined":"node_modules/core-js/modules/_defined.js"}],"node_modules/core-js/modules/_to-integer.js":[function(require,module,exports) {
65641// 7.1.4 ToInteger
65642var ceil = Math.ceil;
65643var floor = Math.floor;
65644module.exports = function (it) {
65645  return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
65646};
65647
65648},{}],"node_modules/core-js/modules/_to-length.js":[function(require,module,exports) {
65649// 7.1.15 ToLength
65650var toInteger = require('./_to-integer');
65651var min = Math.min;
65652module.exports = function (it) {
65653  return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
65654};
65655
65656},{"./_to-integer":"node_modules/core-js/modules/_to-integer.js"}],"node_modules/core-js/modules/_to-absolute-index.js":[function(require,module,exports) {
65657var toInteger = require('./_to-integer');
65658var max = Math.max;
65659var min = Math.min;
65660module.exports = function (index, length) {
65661  index = toInteger(index);
65662  return index < 0 ? max(index + length, 0) : min(index, length);
65663};
65664
65665},{"./_to-integer":"node_modules/core-js/modules/_to-integer.js"}],"node_modules/core-js/modules/_array-includes.js":[function(require,module,exports) {
65666// false -> Array#indexOf
65667// true  -> Array#includes
65668var toIObject = require('./_to-iobject');
65669var toLength = require('./_to-length');
65670var toAbsoluteIndex = require('./_to-absolute-index');
65671module.exports = function (IS_INCLUDES) {
65672  return function ($this, el, fromIndex) {
65673    var O = toIObject($this);
65674    var length = toLength(O.length);
65675    var index = toAbsoluteIndex(fromIndex, length);
65676    var value;
65677    // Array#includes uses SameValueZero equality algorithm
65678    // eslint-disable-next-line no-self-compare
65679    if (IS_INCLUDES && el != el) while (length > index) {
65680      value = O[index++];
65681      // eslint-disable-next-line no-self-compare
65682      if (value != value) return true;
65683    // Array#indexOf ignores holes, Array#includes - not
65684    } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
65685      if (O[index] === el) return IS_INCLUDES || index || 0;
65686    } return !IS_INCLUDES && -1;
65687  };
65688};
65689
65690},{"./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_to-absolute-index":"node_modules/core-js/modules/_to-absolute-index.js"}],"node_modules/core-js/modules/_shared-key.js":[function(require,module,exports) {
65691var shared = require('./_shared')('keys');
65692var uid = require('./_uid');
65693module.exports = function (key) {
65694  return shared[key] || (shared[key] = uid(key));
65695};
65696
65697},{"./_shared":"node_modules/core-js/modules/_shared.js","./_uid":"node_modules/core-js/modules/_uid.js"}],"node_modules/core-js/modules/_object-keys-internal.js":[function(require,module,exports) {
65698var has = require('./_has');
65699var toIObject = require('./_to-iobject');
65700var arrayIndexOf = require('./_array-includes')(false);
65701var IE_PROTO = require('./_shared-key')('IE_PROTO');
65702
65703module.exports = function (object, names) {
65704  var O = toIObject(object);
65705  var i = 0;
65706  var result = [];
65707  var key;
65708  for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
65709  // Don't enum bug & hidden keys
65710  while (names.length > i) if (has(O, key = names[i++])) {
65711    ~arrayIndexOf(result, key) || result.push(key);
65712  }
65713  return result;
65714};
65715
65716},{"./_has":"node_modules/core-js/modules/_has.js","./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_array-includes":"node_modules/core-js/modules/_array-includes.js","./_shared-key":"node_modules/core-js/modules/_shared-key.js"}],"node_modules/core-js/modules/_enum-bug-keys.js":[function(require,module,exports) {
65717// IE 8- don't enum bug keys
65718module.exports = (
65719  'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
65720).split(',');
65721
65722},{}],"node_modules/core-js/modules/_object-keys.js":[function(require,module,exports) {
65723// 19.1.2.14 / 15.2.3.14 Object.keys(O)
65724var $keys = require('./_object-keys-internal');
65725var enumBugKeys = require('./_enum-bug-keys');
65726
65727module.exports = Object.keys || function keys(O) {
65728  return $keys(O, enumBugKeys);
65729};
65730
65731},{"./_object-keys-internal":"node_modules/core-js/modules/_object-keys-internal.js","./_enum-bug-keys":"node_modules/core-js/modules/_enum-bug-keys.js"}],"node_modules/core-js/modules/_object-gops.js":[function(require,module,exports) {
65732exports.f = Object.getOwnPropertySymbols;
65733
65734},{}],"node_modules/core-js/modules/_object-pie.js":[function(require,module,exports) {
65735exports.f = {}.propertyIsEnumerable;
65736
65737},{}],"node_modules/core-js/modules/_enum-keys.js":[function(require,module,exports) {
65738// all enumerable object keys, includes symbols
65739var getKeys = require('./_object-keys');
65740var gOPS = require('./_object-gops');
65741var pIE = require('./_object-pie');
65742module.exports = function (it) {
65743  var result = getKeys(it);
65744  var getSymbols = gOPS.f;
65745  if (getSymbols) {
65746    var symbols = getSymbols(it);
65747    var isEnum = pIE.f;
65748    var i = 0;
65749    var key;
65750    while (symbols.length > i) if (isEnum.call(it, key = symbols[i++])) result.push(key);
65751  } return result;
65752};
65753
65754},{"./_object-keys":"node_modules/core-js/modules/_object-keys.js","./_object-gops":"node_modules/core-js/modules/_object-gops.js","./_object-pie":"node_modules/core-js/modules/_object-pie.js"}],"node_modules/core-js/modules/_is-array.js":[function(require,module,exports) {
65755// 7.2.2 IsArray(argument)
65756var cof = require('./_cof');
65757module.exports = Array.isArray || function isArray(arg) {
65758  return cof(arg) == 'Array';
65759};
65760
65761},{"./_cof":"node_modules/core-js/modules/_cof.js"}],"node_modules/core-js/modules/_to-object.js":[function(require,module,exports) {
65762// 7.1.13 ToObject(argument)
65763var defined = require('./_defined');
65764module.exports = function (it) {
65765  return Object(defined(it));
65766};
65767
65768},{"./_defined":"node_modules/core-js/modules/_defined.js"}],"node_modules/core-js/modules/_object-dps.js":[function(require,module,exports) {
65769var dP = require('./_object-dp');
65770var anObject = require('./_an-object');
65771var getKeys = require('./_object-keys');
65772
65773module.exports = require('./_descriptors') ? Object.defineProperties : function defineProperties(O, Properties) {
65774  anObject(O);
65775  var keys = getKeys(Properties);
65776  var length = keys.length;
65777  var i = 0;
65778  var P;
65779  while (length > i) dP.f(O, P = keys[i++], Properties[P]);
65780  return O;
65781};
65782
65783},{"./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_object-keys":"node_modules/core-js/modules/_object-keys.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js"}],"node_modules/core-js/modules/_html.js":[function(require,module,exports) {
65784var document = require('./_global').document;
65785module.exports = document && document.documentElement;
65786
65787},{"./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/_object-create.js":[function(require,module,exports) {
65788// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
65789var anObject = require('./_an-object');
65790var dPs = require('./_object-dps');
65791var enumBugKeys = require('./_enum-bug-keys');
65792var IE_PROTO = require('./_shared-key')('IE_PROTO');
65793var Empty = function () { /* empty */ };
65794var PROTOTYPE = 'prototype';
65795
65796// Create object with fake `null` prototype: use iframe Object with cleared prototype
65797var createDict = function () {
65798  // Thrash, waste and sodomy: IE GC bug
65799  var iframe = require('./_dom-create')('iframe');
65800  var i = enumBugKeys.length;
65801  var lt = '<';
65802  var gt = '>';
65803  var iframeDocument;
65804  iframe.style.display = 'none';
65805  require('./_html').appendChild(iframe);
65806  iframe.src = 'javascript:'; // eslint-disable-line no-script-url
65807  // createDict = iframe.contentWindow.Object;
65808  // html.removeChild(iframe);
65809  iframeDocument = iframe.contentWindow.document;
65810  iframeDocument.open();
65811  iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
65812  iframeDocument.close();
65813  createDict = iframeDocument.F;
65814  while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
65815  return createDict();
65816};
65817
65818module.exports = Object.create || function create(O, Properties) {
65819  var result;
65820  if (O !== null) {
65821    Empty[PROTOTYPE] = anObject(O);
65822    result = new Empty();
65823    Empty[PROTOTYPE] = null;
65824    // add "__proto__" for Object.getPrototypeOf polyfill
65825    result[IE_PROTO] = O;
65826  } else result = createDict();
65827  return Properties === undefined ? result : dPs(result, Properties);
65828};
65829
65830},{"./_an-object":"node_modules/core-js/modules/_an-object.js","./_object-dps":"node_modules/core-js/modules/_object-dps.js","./_enum-bug-keys":"node_modules/core-js/modules/_enum-bug-keys.js","./_shared-key":"node_modules/core-js/modules/_shared-key.js","./_dom-create":"node_modules/core-js/modules/_dom-create.js","./_html":"node_modules/core-js/modules/_html.js"}],"node_modules/core-js/modules/_object-gopn.js":[function(require,module,exports) {
65831// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
65832var $keys = require('./_object-keys-internal');
65833var hiddenKeys = require('./_enum-bug-keys').concat('length', 'prototype');
65834
65835exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
65836  return $keys(O, hiddenKeys);
65837};
65838
65839},{"./_object-keys-internal":"node_modules/core-js/modules/_object-keys-internal.js","./_enum-bug-keys":"node_modules/core-js/modules/_enum-bug-keys.js"}],"node_modules/core-js/modules/_object-gopn-ext.js":[function(require,module,exports) {
65840// fallback for IE11 buggy Object.getOwnPropertyNames with iframe and window
65841var toIObject = require('./_to-iobject');
65842var gOPN = require('./_object-gopn').f;
65843var toString = {}.toString;
65844
65845var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
65846  ? Object.getOwnPropertyNames(window) : [];
65847
65848var getWindowNames = function (it) {
65849  try {
65850    return gOPN(it);
65851  } catch (e) {
65852    return windowNames.slice();
65853  }
65854};
65855
65856module.exports.f = function getOwnPropertyNames(it) {
65857  return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it));
65858};
65859
65860},{"./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_object-gopn":"node_modules/core-js/modules/_object-gopn.js"}],"node_modules/core-js/modules/_object-gopd.js":[function(require,module,exports) {
65861var pIE = require('./_object-pie');
65862var createDesc = require('./_property-desc');
65863var toIObject = require('./_to-iobject');
65864var toPrimitive = require('./_to-primitive');
65865var has = require('./_has');
65866var IE8_DOM_DEFINE = require('./_ie8-dom-define');
65867var gOPD = Object.getOwnPropertyDescriptor;
65868
65869exports.f = require('./_descriptors') ? gOPD : function getOwnPropertyDescriptor(O, P) {
65870  O = toIObject(O);
65871  P = toPrimitive(P, true);
65872  if (IE8_DOM_DEFINE) try {
65873    return gOPD(O, P);
65874  } catch (e) { /* empty */ }
65875  if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
65876};
65877
65878},{"./_object-pie":"node_modules/core-js/modules/_object-pie.js","./_property-desc":"node_modules/core-js/modules/_property-desc.js","./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js","./_has":"node_modules/core-js/modules/_has.js","./_ie8-dom-define":"node_modules/core-js/modules/_ie8-dom-define.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js"}],"node_modules/core-js/modules/es6.symbol.js":[function(require,module,exports) {
65879
65880'use strict';
65881// ECMAScript 6 symbols shim
65882var global = require('./_global');
65883var has = require('./_has');
65884var DESCRIPTORS = require('./_descriptors');
vendor: 7,527 bytes, lines 65885-66085
65885var $export = require('./_export');
65886var redefine = require('./_redefine');
65887var META = require('./_meta').KEY;
65888var $fails = require('./_fails');
65889var shared = require('./_shared');
65890var setToStringTag = require('./_set-to-string-tag');
65891var uid = require('./_uid');
65892var wks = require('./_wks');
65893var wksExt = require('./_wks-ext');
65894var wksDefine = require('./_wks-define');
65895var enumKeys = require('./_enum-keys');
65896var isArray = require('./_is-array');
65897var anObject = require('./_an-object');
65898var isObject = require('./_is-object');
65899var toObject = require('./_to-object');
65900var toIObject = require('./_to-iobject');
65901var toPrimitive = require('./_to-primitive');
65902var createDesc = require('./_property-desc');
65903var _create = require('./_object-create');
65904var gOPNExt = require('./_object-gopn-ext');
65905var $GOPD = require('./_object-gopd');
65906var $GOPS = require('./_object-gops');
65907var $DP = require('./_object-dp');
65908var $keys = require('./_object-keys');
65909var gOPD = $GOPD.f;
65910var dP = $DP.f;
65911var gOPN = gOPNExt.f;
65912var $Symbol = global.Symbol;
65913var $JSON = global.JSON;
65914var _stringify = $JSON && $JSON.stringify;
65915var PROTOTYPE = 'prototype';
65916var HIDDEN = wks('_hidden');
65917var TO_PRIMITIVE = wks('toPrimitive');
65918var isEnum = {}.propertyIsEnumerable;
65919var SymbolRegistry = shared('symbol-registry');
65920var AllSymbols = shared('symbols');
65921var OPSymbols = shared('op-symbols');
65922var ObjectProto = Object[PROTOTYPE];
65923var USE_NATIVE = typeof $Symbol == 'function' && !!$GOPS.f;
65924var QObject = global.QObject;
65925// Don't use setters in Qt Script, https://github.com/zloirock/core-js/issues/173
65926var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild;
65927
65928// fallback for old Android, https://code.google.com/p/v8/issues/detail?id=687
65929var setSymbolDesc = DESCRIPTORS && $fails(function () {
65930  return _create(dP({}, 'a', {
65931    get: function () { return dP(this, 'a', { value: 7 }).a; }
65932  })).a != 7;
65933}) ? function (it, key, D) {
65934  var protoDesc = gOPD(ObjectProto, key);
65935  if (protoDesc) delete ObjectProto[key];
65936  dP(it, key, D);
65937  if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc);
65938} : dP;
65939
65940var wrap = function (tag) {
65941  var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]);
65942  sym._k = tag;
65943  return sym;
65944};
65945
65946var isSymbol = USE_NATIVE && typeof $Symbol.iterator == 'symbol' ? function (it) {
65947  return typeof it == 'symbol';
65948} : function (it) {
65949  return it instanceof $Symbol;
65950};
65951
65952var $defineProperty = function defineProperty(it, key, D) {
65953  if (it === ObjectProto) $defineProperty(OPSymbols, key, D);
65954  anObject(it);
65955  key = toPrimitive(key, true);
65956  anObject(D);
65957  if (has(AllSymbols, key)) {
65958    if (!D.enumerable) {
65959      if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {}));
65960      it[HIDDEN][key] = true;
65961    } else {
65962      if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false;
65963      D = _create(D, { enumerable: createDesc(0, false) });
65964    } return setSymbolDesc(it, key, D);
65965  } return dP(it, key, D);
65966};
65967var $defineProperties = function defineProperties(it, P) {
65968  anObject(it);
65969  var keys = enumKeys(P = toIObject(P));
65970  var i = 0;
65971  var l = keys.length;
65972  var key;
65973  while (l > i) $defineProperty(it, key = keys[i++], P[key]);
65974  return it;
65975};
65976var $create = function create(it, P) {
65977  return P === undefined ? _create(it) : $defineProperties(_create(it), P);
65978};
65979var $propertyIsEnumerable = function propertyIsEnumerable(key) {
65980  var E = isEnum.call(this, key = toPrimitive(key, true));
65981  if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false;
65982  return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true;
65983};
65984var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) {
65985  it = toIObject(it);
65986  key = toPrimitive(key, true);
65987  if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return;
65988  var D = gOPD(it, key);
65989  if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true;
65990  return D;
65991};
65992var $getOwnPropertyNames = function getOwnPropertyNames(it) {
65993  var names = gOPN(toIObject(it));
65994  var result = [];
65995  var i = 0;
65996  var key;
65997  while (names.length > i) {
65998    if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key);
65999  } return result;
66000};
66001var $getOwnPropertySymbols = function getOwnPropertySymbols(it) {
66002  var IS_OP = it === ObjectProto;
66003  var names = gOPN(IS_OP ? OPSymbols : toIObject(it));
66004  var result = [];
66005  var i = 0;
66006  var key;
66007  while (names.length > i) {
66008    if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]);
66009  } return result;
66010};
66011
66012// 19.4.1.1 Symbol([description])
66013if (!USE_NATIVE) {
66014  $Symbol = function Symbol() {
66015    if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!');
66016    var tag = uid(arguments.length > 0 ? arguments[0] : undefined);
66017    var $set = function (value) {
66018      if (this === ObjectProto) $set.call(OPSymbols, value);
66019      if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false;
66020      setSymbolDesc(this, tag, createDesc(1, value));
66021    };
66022    if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { configurable: true, set: $set });
66023    return wrap(tag);
66024  };
66025  redefine($Symbol[PROTOTYPE], 'toString', function toString() {
66026    return this._k;
66027  });
66028
66029  $GOPD.f = $getOwnPropertyDescriptor;
66030  $DP.f = $defineProperty;
66031  require('./_object-gopn').f = gOPNExt.f = $getOwnPropertyNames;
66032  require('./_object-pie').f = $propertyIsEnumerable;
66033  $GOPS.f = $getOwnPropertySymbols;
66034
66035  if (DESCRIPTORS && !require('./_library')) {
66036    redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true);
66037  }
66038
66039  wksExt.f = function (name) {
66040    return wrap(wks(name));
66041  };
66042}
66043
66044$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol });
66045
66046for (var es6Symbols = (
66047  // 19.4.2.2, 19.4.2.3, 19.4.2.4, 19.4.2.6, 19.4.2.8, 19.4.2.9, 19.4.2.10, 19.4.2.11, 19.4.2.12, 19.4.2.13, 19.4.2.14
66048  'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'
66049).split(','), j = 0; es6Symbols.length > j;)wks(es6Symbols[j++]);
66050
66051for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) wksDefine(wellKnownSymbols[k++]);
66052
66053$export($export.S + $export.F * !USE_NATIVE, 'Symbol', {
66054  // 19.4.2.1 Symbol.for(key)
66055  'for': function (key) {
66056    return has(SymbolRegistry, key += '')
66057      ? SymbolRegistry[key]
66058      : SymbolRegistry[key] = $Symbol(key);
66059  },
66060  // 19.4.2.5 Symbol.keyFor(sym)
66061  keyFor: function keyFor(sym) {
66062    if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!');
66063    for (var key in SymbolRegistry) if (SymbolRegistry[key] === sym) return key;
66064  },
66065  useSetter: function () { setter = true; },
66066  useSimple: function () { setter = false; }
66067});
66068
66069$export($export.S + $export.F * !USE_NATIVE, 'Object', {
66070  // 19.1.2.2 Object.create(O [, Properties])
66071  create: $create,
66072  // 19.1.2.4 Object.defineProperty(O, P, Attributes)
66073  defineProperty: $defineProperty,
66074  // 19.1.2.3 Object.defineProperties(O, Properties)
66075  defineProperties: $defineProperties,
66076  // 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
66077  getOwnPropertyDescriptor: $getOwnPropertyDescriptor,
66078  // 19.1.2.7 Object.getOwnPropertyNames(O)
66079  getOwnPropertyNames: $getOwnPropertyNames,
66080  // 19.1.2.8 Object.getOwnPropertySymbols(O)
66081  getOwnPropertySymbols: $getOwnPropertySymbols
66082});
66083
66084// Chrome 38 and 39 `Object.getOwnPropertySymbols` fails on primitives
66085// https://bugs.chromium.org/p/v8/issues/detail?id=3443
66086var FAILS_ON_PRIMITIVES = $fails(function () { $GOPS.f(1); });
66087
66088$export($export.S + $export.F * FAILS_ON_PRIMITIVES, 'Object', {
66089  getOwnPropertySymbols: function getOwnPropertySymbols(it) {
66090    return $GOPS.f(toObject(it));
66091  }
66092});
66093
66094// 24.3.2 JSON.stringify(value [, replacer [, space]])
66095$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () {
66096  var S = $Symbol();
66097  // MS Edge converts symbol values to JSON as {}
66098  // WebKit converts symbol values to JSON as null
66099  // V8 throws on boxed symbols
66100  return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}';
66101})), 'JSON', {
66102  stringify: function stringify(it) {
66103    var args = [it];
66104    var i = 1;
66105    var replacer, $replacer;
66106    while (arguments.length > i) args.push(arguments[i++]);
66107    $replacer = replacer = args[1];
66108    if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined
66109    if (!isArray(replacer)) replacer = function (key, value) {
66110      if (typeof $replacer == 'function') value = $replacer.call(this, key, value);
66111      if (!isSymbol(value)) return value;
66112    };
66113    args[1] = replacer;
66114    return _stringify.apply($JSON, args);
66115  }
66116});
66117
66118// 19.4.3.4 Symbol.prototype[@@toPrimitive](hint)
66119$Symbol[PROTOTYPE][TO_PRIMITIVE] || require('./_hide')($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf);
66120// 19.4.3.5 Symbol.prototype[@@toStringTag]
66121setToStringTag($Symbol, 'Symbol');
66122// 20.2.1.9 Math[@@toStringTag]
66123setToStringTag(Math, 'Math', true);
66124// 24.3.3 JSON[@@toStringTag]
66125setToStringTag(global.JSON, 'JSON', true);
66126
66127},{"./_global":"node_modules/core-js/modules/_global.js","./_has":"node_modules/core-js/modules/_has.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_export":"node_modules/core-js/modules/_export.js","./_redefine":"node_modules/core-js/modules/_redefine.js","./_meta":"node_modules/core-js/modules/_meta.js","./_fails":"node_modules/core-js/modules/_fails.js","./_shared":"node_modules/core-js/modules/_shared.js","./_set-to-string-tag":"node_modules/core-js/modules/_set-to-string-tag.js","./_uid":"node_modules/core-js/modules/_uid.js","./_wks":"node_modules/core-js/modules/_wks.js","./_wks-ext":"node_modules/core-js/modules/_wks-ext.js","./_wks-define":"node_modules/core-js/modules/_wks-define.js","./_enum-keys":"node_modules/core-js/modules/_enum-keys.js","./_is-array":"node_modules/core-js/modules/_is-array.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js","./_property-desc":"node_modules/core-js/modules/_property-desc.js","./_object-create":"node_modules/core-js/modules/_object-create.js","./_object-gopn-ext":"node_modules/core-js/modules/_object-gopn-ext.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_object-gops":"node_modules/core-js/modules/_object-gops.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_object-keys":"node_modules/core-js/modules/_object-keys.js","./_object-gopn":"node_modules/core-js/modules/_object-gopn.js","./_object-pie":"node_modules/core-js/modules/_object-pie.js","./_library":"node_modules/core-js/modules/_library.js","./_hide":"node_modules/core-js/modules/_hide.js"}],"node_modules/core-js/modules/es6.object.create.js":[function(require,module,exports) {
66128var $export = require('./_export');
66129// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
66130$export($export.S, 'Object', { create: require('./_object-create') });
66131
66132},{"./_export":"node_modules/core-js/modules/_export.js","./_object-create":"node_modules/core-js/modules/_object-create.js"}],"node_modules/core-js/modules/es6.object.define-property.js":[function(require,module,exports) {
66133var $export = require('./_export');
66134// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
66135$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f });
66136
66137},{"./_export":"node_modules/core-js/modules/_export.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js"}],"node_modules/core-js/modules/es6.object.define-properties.js":[function(require,module,exports) {
66138var $export = require('./_export');
66139// 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties)
66140$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperties: require('./_object-dps') });
66141
66142},{"./_export":"node_modules/core-js/modules/_export.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_object-dps":"node_modules/core-js/modules/_object-dps.js"}],"node_modules/core-js/modules/_object-sap.js":[function(require,module,exports) {
66143// most Object methods by ES6 should accept primitives
66144var $export = require('./_export');
66145var core = require('./_core');
66146var fails = require('./_fails');
66147module.exports = function (KEY, exec) {
66148  var fn = (core.Object || {})[KEY] || Object[KEY];
66149  var exp = {};
66150  exp[KEY] = exec(fn);
66151  $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp);
66152};
66153
66154},{"./_export":"node_modules/core-js/modules/_export.js","./_core":"node_modules/core-js/modules/_core.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.object.get-own-property-descriptor.js":[function(require,module,exports) {
66155// 19.1.2.6 Object.getOwnPropertyDescriptor(O, P)
66156var toIObject = require('./_to-iobject');
66157var $getOwnPropertyDescriptor = require('./_object-gopd').f;
66158
66159require('./_object-sap')('getOwnPropertyDescriptor', function () {
66160  return function getOwnPropertyDescriptor(it, key) {
66161    return $getOwnPropertyDescriptor(toIObject(it), key);
66162  };
66163});
66164
66165},{"./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_object-sap":"node_modules/core-js/modules/_object-sap.js"}],"node_modules/core-js/modules/_object-gpo.js":[function(require,module,exports) {
66166// 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
66167var has = require('./_has');
66168var toObject = require('./_to-object');
66169var IE_PROTO = require('./_shared-key')('IE_PROTO');
66170var ObjectProto = Object.prototype;
66171
66172module.exports = Object.getPrototypeOf || function (O) {
66173  O = toObject(O);
66174  if (has(O, IE_PROTO)) return O[IE_PROTO];
66175  if (typeof O.constructor == 'function' && O instanceof O.constructor) {
66176    return O.constructor.prototype;
66177  } return O instanceof Object ? ObjectProto : null;
66178};
66179
66180},{"./_has":"node_modules/core-js/modules/_has.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_shared-key":"node_modules/core-js/modules/_shared-key.js"}],"node_modules/core-js/modules/es6.object.get-prototype-of.js":[function(require,module,exports) {
66181// 19.1.2.9 Object.getPrototypeOf(O)
66182var toObject = require('./_to-object');
66183var $getPrototypeOf = require('./_object-gpo');
66184
66185require('./_object-sap')('getPrototypeOf', function () {
66186  return function getPrototypeOf(it) {
66187    return $getPrototypeOf(toObject(it));
66188  };
66189});
66190
66191},{"./_to-object":"node_modules/core-js/modules/_to-object.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js","./_object-sap":"node_modules/core-js/modules/_object-sap.js"}],"node_modules/core-js/modules/es6.object.keys.js":[function(require,module,exports) {
66192// 19.1.2.14 Object.keys(O)
66193var toObject = require('./_to-object');
66194var $keys = require('./_object-keys');
66195
66196require('./_object-sap')('keys', function () {
66197  return function keys(it) {
66198    return $keys(toObject(it));
66199  };
66200});
66201
66202},{"./_to-object":"node_modules/core-js/modules/_to-object.js","./_object-keys":"node_modules/core-js/modules/_object-keys.js","./_object-sap":"node_modules/core-js/modules/_object-sap.js"}],"node_modules/core-js/modules/es6.object.get-own-property-names.js":[function(require,module,exports) {
66203// 19.1.2.7 Object.getOwnPropertyNames(O)
66204require('./_object-sap')('getOwnPropertyNames', function () {
66205  return require('./_object-gopn-ext').f;
66206});
66207
66208},{"./_object-sap":"node_modules/core-js/modules/_object-sap.js","./_object-gopn-ext":"node_modules/core-js/modules/_object-gopn-ext.js"}],"node_modules/core-js/modules/es6.object.freeze.js":[function(require,module,exports) {
66209// 19.1.2.5 Object.freeze(O)
66210var isObject = require('./_is-object');
66211var meta = require('./_meta').onFreeze;
66212
66213require('./_object-sap')('freeze', function ($freeze) {
66214  return function freeze(it) {
66215    return $freeze && isObject(it) ? $freeze(meta(it)) : it;
66216  };
66217});
66218
66219},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_meta":"node_modules/core-js/modules/_meta.js","./_object-sap":"node_modules/core-js/modules/_object-sap.js"}],"node_modules/core-js/modules/es6.object.seal.js":[function(require,module,exports) {
66220// 19.1.2.17 Object.seal(O)
66221var isObject = require('./_is-object');
66222var meta = require('./_meta').onFreeze;
66223
66224require('./_object-sap')('seal', function ($seal) {
66225  return function seal(it) {
66226    return $seal && isObject(it) ? $seal(meta(it)) : it;
66227  };
66228});
66229
66230},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_meta":"node_modules/core-js/modules/_meta.js","./_object-sap":"node_modules/core-js/modules/_object-sap.js"}],"node_modules/core-js/modules/es6.object.prevent-extensions.js":[function(require,module,exports) {
66231// 19.1.2.15 Object.preventExtensions(O)
66232var isObject = require('./_is-object');
66233var meta = require('./_meta').onFreeze;
66234
66235require('./_object-sap')('preventExtensions', function ($preventExtensions) {
66236  return function preventExtensions(it) {
66237    return $preventExtensions && isObject(it) ? $preventExtensions(meta(it)) : it;
66238  };
66239});
66240
66241},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_meta":"node_modules/core-js/modules/_meta.js","./_object-sap":"node_modules/core-js/modules/_object-sap.js"}],"node_modules/core-js/modules/es6.object.is-frozen.js":[function(require,module,exports) {
66242// 19.1.2.12 Object.isFrozen(O)
66243var isObject = require('./_is-object');
66244
66245require('./_object-sap')('isFrozen', function ($isFrozen) {
66246  return function isFrozen(it) {
66247    return isObject(it) ? $isFrozen ? $isFrozen(it) : false : true;
66248  };
66249});
66250
66251},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_object-sap":"node_modules/core-js/modules/_object-sap.js"}],"node_modules/core-js/modules/es6.object.is-sealed.js":[function(require,module,exports) {
66252// 19.1.2.13 Object.isSealed(O)
66253var isObject = require('./_is-object');
66254
66255require('./_object-sap')('isSealed', function ($isSealed) {
66256  return function isSealed(it) {
66257    return isObject(it) ? $isSealed ? $isSealed(it) : false : true;
66258  };
66259});
66260
66261},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_object-sap":"node_modules/core-js/modules/_object-sap.js"}],"node_modules/core-js/modules/es6.object.is-extensible.js":[function(require,module,exports) {
66262// 19.1.2.11 Object.isExtensible(O)
66263var isObject = require('./_is-object');
66264
66265require('./_object-sap')('isExtensible', function ($isExtensible) {
66266  return function isExtensible(it) {
66267    return isObject(it) ? $isExtensible ? $isExtensible(it) : true : false;
66268  };
66269});
66270
66271},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_object-sap":"node_modules/core-js/modules/_object-sap.js"}],"node_modules/core-js/modules/_object-assign.js":[function(require,module,exports) {
66272'use strict';
66273// 19.1.2.1 Object.assign(target, source, ...)
66274var DESCRIPTORS = require('./_descriptors');
66275var getKeys = require('./_object-keys');
66276var gOPS = require('./_object-gops');
66277var pIE = require('./_object-pie');
66278var toObject = require('./_to-object');
66279var IObject = require('./_iobject');
66280var $assign = Object.assign;
66281
66282// should work with symbols and should have deterministic property order (V8 bug)
66283module.exports = !$assign || require('./_fails')(function () {
66284  var A = {};
66285  var B = {};
66286  // eslint-disable-next-line no-undef
66287  var S = Symbol();
66288  var K = 'abcdefghijklmnopqrst';
66289  A[S] = 7;
66290  K.split('').forEach(function (k) { B[k] = k; });
66291  return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K;
66292}) ? function assign(target, source) { // eslint-disable-line no-unused-vars
66293  var T = toObject(target);
66294  var aLen = arguments.length;
66295  var index = 1;
66296  var getSymbols = gOPS.f;
66297  var isEnum = pIE.f;
66298  while (aLen > index) {
66299    var S = IObject(arguments[index++]);
66300    var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S);
66301    var length = keys.length;
66302    var j = 0;
66303    var key;
66304    while (length > j) {
66305      key = keys[j++];
66306      if (!DESCRIPTORS || isEnum.call(S, key)) T[key] = S[key];
66307    }
66308  } return T;
66309} : $assign;
66310
66311},{"./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_object-keys":"node_modules/core-js/modules/_object-keys.js","./_object-gops":"node_modules/core-js/modules/_object-gops.js","./_object-pie":"node_modules/core-js/modules/_object-pie.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_iobject":"node_modules/core-js/modules/_iobject.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.object.assign.js":[function(require,module,exports) {
66312// 19.1.3.1 Object.assign(target, source)
66313var $export = require('./_export');
66314
66315$export($export.S + $export.F, 'Object', { assign: require('./_object-assign') });
66316
66317},{"./_export":"node_modules/core-js/modules/_export.js","./_object-assign":"node_modules/core-js/modules/_object-assign.js"}],"node_modules/core-js/modules/_same-value.js":[function(require,module,exports) {
66318// 7.2.9 SameValue(x, y)
66319module.exports = Object.is || function is(x, y) {
66320  // eslint-disable-next-line no-self-compare
66321  return x === y ? x !== 0 || 1 / x === 1 / y : x != x && y != y;
66322};
66323
66324},{}],"node_modules/core-js/modules/es6.object.is.js":[function(require,module,exports) {
66325// 19.1.3.10 Object.is(value1, value2)
66326var $export = require('./_export');
66327$export($export.S, 'Object', { is: require('./_same-value') });
66328
66329},{"./_export":"node_modules/core-js/modules/_export.js","./_same-value":"node_modules/core-js/modules/_same-value.js"}],"node_modules/core-js/modules/_set-proto.js":[function(require,module,exports) {
66330// Works with __proto__ only. Old v8 can't work with null proto objects.
66331/* eslint-disable no-proto */
66332var isObject = require('./_is-object');
66333var anObject = require('./_an-object');
66334var check = function (O, proto) {
66335  anObject(O);
66336  if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!");
66337};
66338module.exports = {
66339  set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line
66340    function (test, buggy, set) {
66341      try {
66342        set = require('./_ctx')(Function.call, require('./_object-gopd').f(Object.prototype, '__proto__').set, 2);
66343        set(test, []);
66344        buggy = !(test instanceof Array);
66345      } catch (e) { buggy = true; }
66346      return function setPrototypeOf(O, proto) {
66347        check(O, proto);
66348        if (buggy) O.__proto__ = proto;
66349        else set(O, proto);
66350        return O;
66351      };
66352    }({}, false) : undefined),
66353  check: check
66354};
66355
66356},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_ctx":"node_modules/core-js/modules/_ctx.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js"}],"node_modules/core-js/modules/es6.object.set-prototype-of.js":[function(require,module,exports) {
66357// 19.1.3.19 Object.setPrototypeOf(O, proto)
66358var $export = require('./_export');
66359$export($export.S, 'Object', { setPrototypeOf: require('./_set-proto').set });
66360
66361},{"./_export":"node_modules/core-js/modules/_export.js","./_set-proto":"node_modules/core-js/modules/_set-proto.js"}],"node_modules/core-js/modules/_classof.js":[function(require,module,exports) {
66362// getting tag from 19.1.3.6 Object.prototype.toString()
66363var cof = require('./_cof');
66364var TAG = require('./_wks')('toStringTag');
66365// ES3 wrong here
66366var ARG = cof(function () { return arguments; }()) == 'Arguments';
66367
66368// fallback for IE11 Script Access Denied error
66369var tryGet = function (it, key) {
66370  try {
66371    return it[key];
66372  } catch (e) { /* empty */ }
66373};
66374
66375module.exports = function (it) {
66376  var O, T, B;
66377  return it === undefined ? 'Undefined' : it === null ? 'Null'
66378    // @@toStringTag case
66379    : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
66380    // builtinTag case
66381    : ARG ? cof(O)
66382    // ES3 arguments fallback
66383    : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
66384};
66385
66386},{"./_cof":"node_modules/core-js/modules/_cof.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/es6.object.to-string.js":[function(require,module,exports) {
66387'use strict';
66388// 19.1.3.6 Object.prototype.toString()
66389var classof = require('./_classof');
66390var test = {};
66391test[require('./_wks')('toStringTag')] = 'z';
66392if (test + '' != '[object z]') {
66393  require('./_redefine')(Object.prototype, 'toString', function toString() {
66394    return '[object ' + classof(this) + ']';
66395  }, true);
66396}
66397
66398},{"./_classof":"node_modules/core-js/modules/_classof.js","./_wks":"node_modules/core-js/modules/_wks.js","./_redefine":"node_modules/core-js/modules/_redefine.js"}],"node_modules/core-js/modules/_invoke.js":[function(require,module,exports) {
66399// fast apply, http://jsperf.lnkit.com/fast-apply/5
66400module.exports = function (fn, args, that) {
66401  var un = that === undefined;
66402  switch (args.length) {
66403    case 0: return un ? fn()
66404                      : fn.call(that);
66405    case 1: return un ? fn(args[0])
66406                      : fn.call(that, args[0]);
66407    case 2: return un ? fn(args[0], args[1])
66408                      : fn.call(that, args[0], args[1]);
66409    case 3: return un ? fn(args[0], args[1], args[2])
66410                      : fn.call(that, args[0], args[1], args[2]);
66411    case 4: return un ? fn(args[0], args[1], args[2], args[3])
66412                      : fn.call(that, args[0], args[1], args[2], args[3]);
66413  } return fn.apply(that, args);
66414};
66415
66416},{}],"node_modules/core-js/modules/_bind.js":[function(require,module,exports) {
66417'use strict';
66418var aFunction = require('./_a-function');
66419var isObject = require('./_is-object');
66420var invoke = require('./_invoke');
66421var arraySlice = [].slice;
66422var factories = {};
66423
66424var construct = function (F, len, args) {
66425  if (!(len in factories)) {
66426    for (var n = [], i = 0; i < len; i++) n[i] = 'a[' + i + ']';
66427    // eslint-disable-next-line no-new-func
66428    factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')');
66429  } return factories[len](F, args);
66430};
66431
66432module.exports = Function.bind || function bind(that /* , ...args */) {
66433  var fn = aFunction(this);
66434  var partArgs = arraySlice.call(arguments, 1);
66435  var bound = function (/* args... */) {
66436    var args = partArgs.concat(arraySlice.call(arguments));
66437    return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that);
66438  };
66439  if (isObject(fn.prototype)) bound.prototype = fn.prototype;
66440  return bound;
66441};
66442
66443},{"./_a-function":"node_modules/core-js/modules/_a-function.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_invoke":"node_modules/core-js/modules/_invoke.js"}],"node_modules/core-js/modules/es6.function.bind.js":[function(require,module,exports) {
66444// 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...)
66445var $export = require('./_export');
66446
66447$export($export.P, 'Function', { bind: require('./_bind') });
66448
66449},{"./_export":"node_modules/core-js/modules/_export.js","./_bind":"node_modules/core-js/modules/_bind.js"}],"node_modules/core-js/modules/es6.function.name.js":[function(require,module,exports) {
66450var dP = require('./_object-dp').f;
66451var FProto = Function.prototype;
66452var nameRE = /^\s*function ([^ (]*)/;
66453var NAME = 'name';
66454
66455// 19.2.4.2 name
66456NAME in FProto || require('./_descriptors') && dP(FProto, NAME, {
66457  configurable: true,
66458  get: function () {
66459    try {
66460      return ('' + this).match(nameRE)[1];
66461    } catch (e) {
66462      return '';
66463    }
66464  }
66465});
66466
66467},{"./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js"}],"node_modules/core-js/modules/es6.function.has-instance.js":[function(require,module,exports) {
66468'use strict';
66469var isObject = require('./_is-object');
66470var getPrototypeOf = require('./_object-gpo');
66471var HAS_INSTANCE = require('./_wks')('hasInstance');
66472var FunctionProto = Function.prototype;
66473// 19.2.3.6 Function.prototype[@@hasInstance](V)
66474if (!(HAS_INSTANCE in FunctionProto)) require('./_object-dp').f(FunctionProto, HAS_INSTANCE, { value: function (O) {
66475  if (typeof this != 'function' || !isObject(O)) return false;
66476  if (!isObject(this.prototype)) return O instanceof this;
66477  // for environment w/o native `@@hasInstance` logic enough `instanceof`, but add this:
66478  while (O = getPrototypeOf(O)) if (this.prototype === O) return true;
66479  return false;
66480} });
66481
66482},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js","./_wks":"node_modules/core-js/modules/_wks.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js"}],"node_modules/core-js/modules/_string-ws.js":[function(require,module,exports) {
66483module.exports = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
66484  '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
66485
66486},{}],"node_modules/core-js/modules/_string-trim.js":[function(require,module,exports) {
66487var $export = require('./_export');
66488var defined = require('./_defined');
66489var fails = require('./_fails');
66490var spaces = require('./_string-ws');
66491var space = '[' + spaces + ']';
66492var non = '\u200b\u0085';
66493var ltrim = RegExp('^' + space + space + '*');
66494var rtrim = RegExp(space + space + '*$');
66495
66496var exporter = function (KEY, exec, ALIAS) {
66497  var exp = {};
66498  var FORCE = fails(function () {
66499    return !!spaces[KEY]() || non[KEY]() != non;
66500  });
66501  var fn = exp[KEY] = FORCE ? exec(trim) : spaces[KEY];
66502  if (ALIAS) exp[ALIAS] = fn;
66503  $export($export.P + $export.F * FORCE, 'String', exp);
66504};
66505
66506// 1 -> String#trimLeft
66507// 2 -> String#trimRight
66508// 3 -> String#trim
66509var trim = exporter.trim = function (string, TYPE) {
66510  string = String(defined(string));
66511  if (TYPE & 1) string = string.replace(ltrim, '');
66512  if (TYPE & 2) string = string.replace(rtrim, '');
66513  return string;
66514};
66515
66516module.exports = exporter;
66517
66518},{"./_export":"node_modules/core-js/modules/_export.js","./_defined":"node_modules/core-js/modules/_defined.js","./_fails":"node_modules/core-js/modules/_fails.js","./_string-ws":"node_modules/core-js/modules/_string-ws.js"}],"node_modules/core-js/modules/_parse-int.js":[function(require,module,exports) {
66519var $parseInt = require('./_global').parseInt;
66520var $trim = require('./_string-trim').trim;
66521var ws = require('./_string-ws');
66522var hex = /^[-+]?0[xX]/;
66523
66524module.exports = $parseInt(ws + '08') !== 8 || $parseInt(ws + '0x16') !== 22 ? function parseInt(str, radix) {
66525  var string = $trim(String(str), 3);
66526  return $parseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
66527} : $parseInt;
66528
66529},{"./_global":"node_modules/core-js/modules/_global.js","./_string-trim":"node_modules/core-js/modules/_string-trim.js","./_string-ws":"node_modules/core-js/modules/_string-ws.js"}],"node_modules/core-js/modules/es6.parse-int.js":[function(require,module,exports) {
66530var $export = require('./_export');
66531var $parseInt = require('./_parse-int');
66532// 18.2.5 parseInt(string, radix)
66533$export($export.G + $export.F * (parseInt != $parseInt), { parseInt: $parseInt });
66534
66535},{"./_export":"node_modules/core-js/modules/_export.js","./_parse-int":"node_modules/core-js/modules/_parse-int.js"}],"node_modules/core-js/modules/_parse-float.js":[function(require,module,exports) {
66536var $parseFloat = require('./_global').parseFloat;
66537var $trim = require('./_string-trim').trim;
66538
66539module.exports = 1 / $parseFloat(require('./_string-ws') + '-0') !== -Infinity ? function parseFloat(str) {
66540  var string = $trim(String(str), 3);
66541  var result = $parseFloat(string);
66542  return result === 0 && string.charAt(0) == '-' ? -0 : result;
66543} : $parseFloat;
66544
66545},{"./_global":"node_modules/core-js/modules/_global.js","./_string-trim":"node_modules/core-js/modules/_string-trim.js","./_string-ws":"node_modules/core-js/modules/_string-ws.js"}],"node_modules/core-js/modules/es6.parse-float.js":[function(require,module,exports) {
66546var $export = require('./_export');
66547var $parseFloat = require('./_parse-float');
66548// 18.2.4 parseFloat(string)
66549$export($export.G + $export.F * (parseFloat != $parseFloat), { parseFloat: $parseFloat });
66550
66551},{"./_export":"node_modules/core-js/modules/_export.js","./_parse-float":"node_modules/core-js/modules/_parse-float.js"}],"node_modules/core-js/modules/_inherit-if-required.js":[function(require,module,exports) {
66552var isObject = require('./_is-object');
66553var setPrototypeOf = require('./_set-proto').set;
66554module.exports = function (that, target, C) {
66555  var S = target.constructor;
66556  var P;
66557  if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) {
66558    setPrototypeOf(that, P);
66559  } return that;
66560};
66561
66562},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_set-proto":"node_modules/core-js/modules/_set-proto.js"}],"node_modules/core-js/modules/es6.number.constructor.js":[function(require,module,exports) {
66563
66564'use strict';
66565var global = require('./_global');
66566var has = require('./_has');
66567var cof = require('./_cof');
66568var inheritIfRequired = require('./_inherit-if-required');
66569var toPrimitive = require('./_to-primitive');
66570var fails = require('./_fails');
66571var gOPN = require('./_object-gopn').f;
66572var gOPD = require('./_object-gopd').f;
66573var dP = require('./_object-dp').f;
66574var $trim = require('./_string-trim').trim;
vendor: 8,241 bytes, lines 66575-66792
66575var NUMBER = 'Number';
66576var $Number = global[NUMBER];
66577var Base = $Number;
66578var proto = $Number.prototype;
66579// Opera ~12 has broken Object#toString
66580var BROKEN_COF = cof(require('./_object-create')(proto)) == NUMBER;
66581var TRIM = 'trim' in String.prototype;
66582
66583// 7.1.3 ToNumber(argument)
66584var toNumber = function (argument) {
66585  var it = toPrimitive(argument, false);
66586  if (typeof it == 'string' && it.length > 2) {
66587    it = TRIM ? it.trim() : $trim(it, 3);
66588    var first = it.charCodeAt(0);
66589    var third, radix, maxCode;
66590    if (first === 43 || first === 45) {
66591      third = it.charCodeAt(2);
66592      if (third === 88 || third === 120) return NaN; // Number('+0x1') should be NaN, old V8 fix
66593    } else if (first === 48) {
66594      switch (it.charCodeAt(1)) {
66595        case 66: case 98: radix = 2; maxCode = 49; break; // fast equal /^0b[01]+$/i
66596        case 79: case 111: radix = 8; maxCode = 55; break; // fast equal /^0o[0-7]+$/i
66597        default: return +it;
66598      }
66599      for (var digits = it.slice(2), i = 0, l = digits.length, code; i < l; i++) {
66600        code = digits.charCodeAt(i);
66601        // parseInt parses a string to a first unavailable symbol
66602        // but ToNumber should return NaN if a string contains unavailable symbols
66603        if (code < 48 || code > maxCode) return NaN;
66604      } return parseInt(digits, radix);
66605    }
66606  } return +it;
66607};
66608
66609if (!$Number(' 0o1') || !$Number('0b1') || $Number('+0x1')) {
66610  $Number = function Number(value) {
66611    var it = arguments.length < 1 ? 0 : value;
66612    var that = this;
66613    return that instanceof $Number
66614      // check on 1..constructor(foo) case
66615      && (BROKEN_COF ? fails(function () { proto.valueOf.call(that); }) : cof(that) != NUMBER)
66616        ? inheritIfRequired(new Base(toNumber(it)), that, $Number) : toNumber(it);
66617  };
66618  for (var keys = require('./_descriptors') ? gOPN(Base) : (
66619    // ES3:
66620    'MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' +
66621    // ES6 (in case, if modules with ES6 Number statics required before):
66622    'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' +
66623    'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger'
66624  ).split(','), j = 0, key; keys.length > j; j++) {
66625    if (has(Base, key = keys[j]) && !has($Number, key)) {
66626      dP($Number, key, gOPD(Base, key));
66627    }
66628  }
66629  $Number.prototype = proto;
66630  proto.constructor = $Number;
66631  require('./_redefine')(global, NUMBER, $Number);
66632}
66633
66634},{"./_global":"node_modules/core-js/modules/_global.js","./_has":"node_modules/core-js/modules/_has.js","./_cof":"node_modules/core-js/modules/_cof.js","./_inherit-if-required":"node_modules/core-js/modules/_inherit-if-required.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js","./_fails":"node_modules/core-js/modules/_fails.js","./_object-gopn":"node_modules/core-js/modules/_object-gopn.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_string-trim":"node_modules/core-js/modules/_string-trim.js","./_object-create":"node_modules/core-js/modules/_object-create.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_redefine":"node_modules/core-js/modules/_redefine.js"}],"node_modules/core-js/modules/_a-number-value.js":[function(require,module,exports) {
66635var cof = require('./_cof');
66636module.exports = function (it, msg) {
66637  if (typeof it != 'number' && cof(it) != 'Number') throw TypeError(msg);
66638  return +it;
66639};
66640
66641},{"./_cof":"node_modules/core-js/modules/_cof.js"}],"node_modules/core-js/modules/_string-repeat.js":[function(require,module,exports) {
66642'use strict';
66643var toInteger = require('./_to-integer');
66644var defined = require('./_defined');
66645
66646module.exports = function repeat(count) {
66647  var str = String(defined(this));
66648  var res = '';
66649  var n = toInteger(count);
66650  if (n < 0 || n == Infinity) throw RangeError("Count can't be negative");
66651  for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str;
66652  return res;
66653};
66654
66655},{"./_to-integer":"node_modules/core-js/modules/_to-integer.js","./_defined":"node_modules/core-js/modules/_defined.js"}],"node_modules/core-js/modules/es6.number.to-fixed.js":[function(require,module,exports) {
66656'use strict';
66657var $export = require('./_export');
66658var toInteger = require('./_to-integer');
66659var aNumberValue = require('./_a-number-value');
66660var repeat = require('./_string-repeat');
66661var $toFixed = 1.0.toFixed;
66662var floor = Math.floor;
66663var data = [0, 0, 0, 0, 0, 0];
66664var ERROR = 'Number.toFixed: incorrect invocation!';
66665var ZERO = '0';
66666
66667var multiply = function (n, c) {
66668  var i = -1;
66669  var c2 = c;
66670  while (++i < 6) {
66671    c2 += n * data[i];
66672    data[i] = c2 % 1e7;
66673    c2 = floor(c2 / 1e7);
66674  }
66675};
66676var divide = function (n) {
66677  var i = 6;
66678  var c = 0;
66679  while (--i >= 0) {
66680    c += data[i];
66681    data[i] = floor(c / n);
66682    c = (c % n) * 1e7;
66683  }
66684};
66685var numToString = function () {
66686  var i = 6;
66687  var s = '';
66688  while (--i >= 0) {
66689    if (s !== '' || i === 0 || data[i] !== 0) {
66690      var t = String(data[i]);
66691      s = s === '' ? t : s + repeat.call(ZERO, 7 - t.length) + t;
66692    }
66693  } return s;
66694};
66695var pow = function (x, n, acc) {
66696  return n === 0 ? acc : n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc);
66697};
66698var log = function (x) {
66699  var n = 0;
66700  var x2 = x;
66701  while (x2 >= 4096) {
66702    n += 12;
66703    x2 /= 4096;
66704  }
66705  while (x2 >= 2) {
66706    n += 1;
66707    x2 /= 2;
66708  } return n;
66709};
66710
66711$export($export.P + $export.F * (!!$toFixed && (
66712  0.00008.toFixed(3) !== '0.000' ||
66713  0.9.toFixed(0) !== '1' ||
66714  1.255.toFixed(2) !== '1.25' ||
66715  1000000000000000128.0.toFixed(0) !== '1000000000000000128'
66716) || !require('./_fails')(function () {
66717  // V8 ~ Android 4.3-
66718  $toFixed.call({});
66719})), 'Number', {
66720  toFixed: function toFixed(fractionDigits) {
66721    var x = aNumberValue(this, ERROR);
66722    var f = toInteger(fractionDigits);
66723    var s = '';
66724    var m = ZERO;
66725    var e, z, j, k;
66726    if (f < 0 || f > 20) throw RangeError(ERROR);
66727    // eslint-disable-next-line no-self-compare
66728    if (x != x) return 'NaN';
66729    if (x <= -1e21 || x >= 1e21) return String(x);
66730    if (x < 0) {
66731      s = '-';
66732      x = -x;
66733    }
66734    if (x > 1e-21) {
66735      e = log(x * pow(2, 69, 1)) - 69;
66736      z = e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1);
66737      z *= 0x10000000000000;
66738      e = 52 - e;
66739      if (e > 0) {
66740        multiply(0, z);
66741        j = f;
66742        while (j >= 7) {
66743          multiply(1e7, 0);
66744          j -= 7;
66745        }
66746        multiply(pow(10, j, 1), 0);
66747        j = e - 1;
66748        while (j >= 23) {
66749          divide(1 << 23);
66750          j -= 23;
66751        }
66752        divide(1 << j);
66753        multiply(1, 1);
66754        divide(2);
66755        m = numToString();
66756      } else {
66757        multiply(0, z);
66758        multiply(1 << -e, 0);
66759        m = numToString() + repeat.call(ZERO, f);
66760      }
66761    }
66762    if (f > 0) {
66763      k = m.length;
66764      m = s + (k <= f ? '0.' + repeat.call(ZERO, f - k) + m : m.slice(0, k - f) + '.' + m.slice(k - f));
66765    } else {
66766      m = s + m;
66767    } return m;
66768  }
66769});
66770
66771},{"./_export":"node_modules/core-js/modules/_export.js","./_to-integer":"node_modules/core-js/modules/_to-integer.js","./_a-number-value":"node_modules/core-js/modules/_a-number-value.js","./_string-repeat":"node_modules/core-js/modules/_string-repeat.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.number.to-precision.js":[function(require,module,exports) {
66772'use strict';
66773var $export = require('./_export');
66774var $fails = require('./_fails');
66775var aNumberValue = require('./_a-number-value');
66776var $toPrecision = 1.0.toPrecision;
66777
66778$export($export.P + $export.F * ($fails(function () {
66779  // IE7-
66780  return $toPrecision.call(1, undefined) !== '1';
66781}) || !$fails(function () {
66782  // V8 ~ Android 4.3-
66783  $toPrecision.call({});
66784})), 'Number', {
66785  toPrecision: function toPrecision(precision) {
66786    var that = aNumberValue(this, 'Number#toPrecision: incorrect invocation!');
66787    return precision === undefined ? $toPrecision.call(that) : $toPrecision.call(that, precision);
66788  }
66789});
66790
66791},{"./_export":"node_modules/core-js/modules/_export.js","./_fails":"node_modules/core-js/modules/_fails.js","./_a-number-value":"node_modules/core-js/modules/_a-number-value.js"}],"node_modules/core-js/modules/es6.number.epsilon.js":[function(require,module,exports) {
66792// 20.1.2.1 Number.EPSILON
66793var $export = require('./_export');
66794
66795$export($export.S, 'Number', { EPSILON: Math.pow(2, -52) });
66796
66797},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.number.is-finite.js":[function(require,module,exports) {
66798// 20.1.2.2 Number.isFinite(number)
66799var $export = require('./_export');
66800var _isFinite = require('./_global').isFinite;
66801
66802$export($export.S, 'Number', {
66803  isFinite: function isFinite(it) {
66804    return typeof it == 'number' && _isFinite(it);
66805  }
66806});
66807
66808},{"./_export":"node_modules/core-js/modules/_export.js","./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/_is-integer.js":[function(require,module,exports) {
66809// 20.1.2.3 Number.isInteger(number)
66810var isObject = require('./_is-object');
66811var floor = Math.floor;
66812module.exports = function isInteger(it) {
66813  return !isObject(it) && isFinite(it) && floor(it) === it;
66814};
66815
66816},{"./_is-object":"node_modules/core-js/modules/_is-object.js"}],"node_modules/core-js/modules/es6.number.is-integer.js":[function(require,module,exports) {
66817// 20.1.2.3 Number.isInteger(number)
66818var $export = require('./_export');
66819
66820$export($export.S, 'Number', { isInteger: require('./_is-integer') });
66821
66822},{"./_export":"node_modules/core-js/modules/_export.js","./_is-integer":"node_modules/core-js/modules/_is-integer.js"}],"node_modules/core-js/modules/es6.number.is-nan.js":[function(require,module,exports) {
66823// 20.1.2.4 Number.isNaN(number)
66824var $export = require('./_export');
66825
66826$export($export.S, 'Number', {
66827  isNaN: function isNaN(number) {
66828    // eslint-disable-next-line no-self-compare
66829    return number != number;
66830  }
66831});
66832
66833},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.number.is-safe-integer.js":[function(require,module,exports) {
66834// 20.1.2.5 Number.isSafeInteger(number)
66835var $export = require('./_export');
66836var isInteger = require('./_is-integer');
66837var abs = Math.abs;
66838
66839$export($export.S, 'Number', {
66840  isSafeInteger: function isSafeInteger(number) {
66841    return isInteger(number) && abs(number) <= 0x1fffffffffffff;
66842  }
66843});
66844
66845},{"./_export":"node_modules/core-js/modules/_export.js","./_is-integer":"node_modules/core-js/modules/_is-integer.js"}],"node_modules/core-js/modules/es6.number.max-safe-integer.js":[function(require,module,exports) {
66846// 20.1.2.6 Number.MAX_SAFE_INTEGER
66847var $export = require('./_export');
66848
66849$export($export.S, 'Number', { MAX_SAFE_INTEGER: 0x1fffffffffffff });
66850
66851},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.number.min-safe-integer.js":[function(require,module,exports) {
66852// 20.1.2.10 Number.MIN_SAFE_INTEGER
66853var $export = require('./_export');
66854
66855$export($export.S, 'Number', { MIN_SAFE_INTEGER: -0x1fffffffffffff });
66856
66857},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.number.parse-float.js":[function(require,module,exports) {
66858var $export = require('./_export');
66859var $parseFloat = require('./_parse-float');
66860// 20.1.2.12 Number.parseFloat(string)
66861$export($export.S + $export.F * (Number.parseFloat != $parseFloat), 'Number', { parseFloat: $parseFloat });
66862
66863},{"./_export":"node_modules/core-js/modules/_export.js","./_parse-float":"node_modules/core-js/modules/_parse-float.js"}],"node_modules/core-js/modules/es6.number.parse-int.js":[function(require,module,exports) {
66864var $export = require('./_export');
66865var $parseInt = require('./_parse-int');
66866// 20.1.2.13 Number.parseInt(string, radix)
66867$export($export.S + $export.F * (Number.parseInt != $parseInt), 'Number', { parseInt: $parseInt });
66868
66869},{"./_export":"node_modules/core-js/modules/_export.js","./_parse-int":"node_modules/core-js/modules/_parse-int.js"}],"node_modules/core-js/modules/_math-log1p.js":[function(require,module,exports) {
66870// 20.2.2.20 Math.log1p(x)
66871module.exports = Math.log1p || function log1p(x) {
66872  return (x = +x) > -1e-8 && x < 1e-8 ? x - x * x / 2 : Math.log(1 + x);
66873};
66874
66875},{}],"node_modules/core-js/modules/es6.math.acosh.js":[function(require,module,exports) {
66876// 20.2.2.3 Math.acosh(x)
66877var $export = require('./_export');
66878var log1p = require('./_math-log1p');
66879var sqrt = Math.sqrt;
66880var $acosh = Math.acosh;
66881
66882$export($export.S + $export.F * !($acosh
66883  // V8 bug: https://code.google.com/p/v8/issues/detail?id=3509
66884  && Math.floor($acosh(Number.MAX_VALUE)) == 710
66885  // Tor Browser bug: Math.acosh(Infinity) -> NaN
66886  && $acosh(Infinity) == Infinity
66887), 'Math', {
66888  acosh: function acosh(x) {
66889    return (x = +x) < 1 ? NaN : x > 94906265.62425156
66890      ? Math.log(x) + Math.LN2
66891      : log1p(x - 1 + sqrt(x - 1) * sqrt(x + 1));
66892  }
66893});
66894
66895},{"./_export":"node_modules/core-js/modules/_export.js","./_math-log1p":"node_modules/core-js/modules/_math-log1p.js"}],"node_modules/core-js/modules/es6.math.asinh.js":[function(require,module,exports) {
66896// 20.2.2.5 Math.asinh(x)
66897var $export = require('./_export');
66898var $asinh = Math.asinh;
66899
66900function asinh(x) {
66901  return !isFinite(x = +x) || x == 0 ? x : x < 0 ? -asinh(-x) : Math.log(x + Math.sqrt(x * x + 1));
66902}
66903
66904// Tor Browser bug: Math.asinh(0) -> -0
66905$export($export.S + $export.F * !($asinh && 1 / $asinh(0) > 0), 'Math', { asinh: asinh });
66906
66907},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.math.atanh.js":[function(require,module,exports) {
66908// 20.2.2.7 Math.atanh(x)
66909var $export = require('./_export');
66910var $atanh = Math.atanh;
66911
66912// Tor Browser bug: Math.atanh(-0) -> 0
66913$export($export.S + $export.F * !($atanh && 1 / $atanh(-0) < 0), 'Math', {
66914  atanh: function atanh(x) {
66915    return (x = +x) == 0 ? x : Math.log((1 + x) / (1 - x)) / 2;
66916  }
66917});
66918
66919},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/_math-sign.js":[function(require,module,exports) {
66920// 20.2.2.28 Math.sign(x)
66921module.exports = Math.sign || function sign(x) {
66922  // eslint-disable-next-line no-self-compare
66923  return (x = +x) == 0 || x != x ? x : x < 0 ? -1 : 1;
66924};
66925
66926},{}],"node_modules/core-js/modules/es6.math.cbrt.js":[function(require,module,exports) {
66927// 20.2.2.9 Math.cbrt(x)
66928var $export = require('./_export');
66929var sign = require('./_math-sign');
66930
66931$export($export.S, 'Math', {
66932  cbrt: function cbrt(x) {
66933    return sign(x = +x) * Math.pow(Math.abs(x), 1 / 3);
66934  }
66935});
66936
66937},{"./_export":"node_modules/core-js/modules/_export.js","./_math-sign":"node_modules/core-js/modules/_math-sign.js"}],"node_modules/core-js/modules/es6.math.clz32.js":[function(require,module,exports) {
66938// 20.2.2.11 Math.clz32(x)
66939var $export = require('./_export');
66940
66941$export($export.S, 'Math', {
66942  clz32: function clz32(x) {
66943    return (x >>>= 0) ? 31 - Math.floor(Math.log(x + 0.5) * Math.LOG2E) : 32;
66944  }
66945});
66946
66947},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.math.cosh.js":[function(require,module,exports) {
66948// 20.2.2.12 Math.cosh(x)
66949var $export = require('./_export');
66950var exp = Math.exp;
66951
66952$export($export.S, 'Math', {
66953  cosh: function cosh(x) {
66954    return (exp(x = +x) + exp(-x)) / 2;
66955  }
66956});
66957
66958},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/_math-expm1.js":[function(require,module,exports) {
66959// 20.2.2.14 Math.expm1(x)
66960var $expm1 = Math.expm1;
66961module.exports = (!$expm1
66962  // Old FF bug
66963  || $expm1(10) > 22025.465794806719 || $expm1(10) < 22025.4657948067165168
66964  // Tor Browser bug
66965  || $expm1(-2e-17) != -2e-17
66966) ? function expm1(x) {
66967  return (x = +x) == 0 ? x : x > -1e-6 && x < 1e-6 ? x + x * x / 2 : Math.exp(x) - 1;
66968} : $expm1;
66969
66970},{}],"node_modules/core-js/modules/es6.math.expm1.js":[function(require,module,exports) {
66971// 20.2.2.14 Math.expm1(x)
66972var $export = require('./_export');
66973var $expm1 = require('./_math-expm1');
66974
66975$export($export.S + $export.F * ($expm1 != Math.expm1), 'Math', { expm1: $expm1 });
66976
66977},{"./_export":"node_modules/core-js/modules/_export.js","./_math-expm1":"node_modules/core-js/modules/_math-expm1.js"}],"node_modules/core-js/modules/_math-fround.js":[function(require,module,exports) {
66978// 20.2.2.16 Math.fround(x)
66979var sign = require('./_math-sign');
66980var pow = Math.pow;
66981var EPSILON = pow(2, -52);
66982var EPSILON32 = pow(2, -23);
66983var MAX32 = pow(2, 127) * (2 - EPSILON32);
66984var MIN32 = pow(2, -126);
66985
66986var roundTiesToEven = function (n) {
66987  return n + 1 / EPSILON - 1 / EPSILON;
66988};
66989
66990module.exports = Math.fround || function fround(x) {
66991  var $abs = Math.abs(x);
66992  var $sign = sign(x);
66993  var a, result;
66994  if ($abs < MIN32) return $sign * roundTiesToEven($abs / MIN32 / EPSILON32) * MIN32 * EPSILON32;
66995  a = (1 + EPSILON32 / EPSILON) * $abs;
66996  result = a - (a - $abs);
66997  // eslint-disable-next-line no-self-compare
66998  if (result > MAX32 || result != result) return $sign * Infinity;
66999  return $sign * result;
67000};
67001
67002},{"./_math-sign":"node_modules/core-js/modules/_math-sign.js"}],"node_modules/core-js/modules/es6.math.fround.js":[function(require,module,exports) {
67003// 20.2.2.16 Math.fround(x)
67004var $export = require('./_export');
67005
67006$export($export.S, 'Math', { fround: require('./_math-fround') });
67007
67008},{"./_export":"node_modules/core-js/modules/_export.js","./_math-fround":"node_modules/core-js/modules/_math-fround.js"}],"node_modules/core-js/modules/es6.math.hypot.js":[function(require,module,exports) {
67009// 20.2.2.17 Math.hypot([value1[, value2[, … ]]])
67010var $export = require('./_export');
67011var abs = Math.abs;
67012
67013$export($export.S, 'Math', {
67014  hypot: function hypot(value1, value2) { // eslint-disable-line no-unused-vars
67015    var sum = 0;
67016    var i = 0;
67017    var aLen = arguments.length;
67018    var larg = 0;
67019    var arg, div;
67020    while (i < aLen) {
67021      arg = abs(arguments[i++]);
67022      if (larg < arg) {
67023        div = larg / arg;
67024        sum = sum * div * div + 1;
67025        larg = arg;
67026      } else if (arg > 0) {
67027        div = arg / larg;
67028        sum += div * div;
67029      } else sum += arg;
67030    }
67031    return larg === Infinity ? Infinity : larg * Math.sqrt(sum);
67032  }
67033});
67034
67035},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.math.imul.js":[function(require,module,exports) {
67036// 20.2.2.18 Math.imul(x, y)
67037var $export = require('./_export');
67038var $imul = Math.imul;
67039
67040// some WebKit versions fails with big numbers, some has wrong arity
67041$export($export.S + $export.F * require('./_fails')(function () {
67042  return $imul(0xffffffff, 5) != -5 || $imul.length != 2;
67043}), 'Math', {
67044  imul: function imul(x, y) {
67045    var UINT16 = 0xffff;
67046    var xn = +x;
67047    var yn = +y;
67048    var xl = UINT16 & xn;
67049    var yl = UINT16 & yn;
67050    return 0 | xl * yl + ((UINT16 & xn >>> 16) * yl + xl * (UINT16 & yn >>> 16) << 16 >>> 0);
67051  }
67052});
67053
67054},{"./_export":"node_modules/core-js/modules/_export.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.math.log10.js":[function(require,module,exports) {
67055// 20.2.2.21 Math.log10(x)
67056var $export = require('./_export');
67057
67058$export($export.S, 'Math', {
67059  log10: function log10(x) {
67060    return Math.log(x) * Math.LOG10E;
67061  }
67062});
67063
67064},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.math.log1p.js":[function(require,module,exports) {
67065// 20.2.2.20 Math.log1p(x)
67066var $export = require('./_export');
67067
67068$export($export.S, 'Math', { log1p: require('./_math-log1p') });
67069
67070},{"./_export":"node_modules/core-js/modules/_export.js","./_math-log1p":"node_modules/core-js/modules/_math-log1p.js"}],"node_modules/core-js/modules/es6.math.log2.js":[function(require,module,exports) {
67071// 20.2.2.22 Math.log2(x)
67072var $export = require('./_export');
67073
67074$export($export.S, 'Math', {
67075  log2: function log2(x) {
67076    return Math.log(x) / Math.LN2;
67077  }
67078});
67079
67080},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.math.sign.js":[function(require,module,exports) {
67081// 20.2.2.28 Math.sign(x)
67082var $export = require('./_export');
67083
67084$export($export.S, 'Math', { sign: require('./_math-sign') });
67085
67086},{"./_export":"node_modules/core-js/modules/_export.js","./_math-sign":"node_modules/core-js/modules/_math-sign.js"}],"node_modules/core-js/modules/es6.math.sinh.js":[function(require,module,exports) {
67087// 20.2.2.30 Math.sinh(x)
67088var $export = require('./_export');
67089var expm1 = require('./_math-expm1');
67090var exp = Math.exp;
67091
67092// V8 near Chromium 38 has a problem with very small numbers
67093$export($export.S + $export.F * require('./_fails')(function () {
67094  return !Math.sinh(-2e-17) != -2e-17;
67095}), 'Math', {
67096  sinh: function sinh(x) {
67097    return Math.abs(x = +x) < 1
67098      ? (expm1(x) - expm1(-x)) / 2
67099      : (exp(x - 1) - exp(-x - 1)) * (Math.E / 2);
67100  }
67101});
67102
67103},{"./_export":"node_modules/core-js/modules/_export.js","./_math-expm1":"node_modules/core-js/modules/_math-expm1.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.math.tanh.js":[function(require,module,exports) {
67104// 20.2.2.33 Math.tanh(x)
67105var $export = require('./_export');
67106var expm1 = require('./_math-expm1');
67107var exp = Math.exp;
67108
67109$export($export.S, 'Math', {
67110  tanh: function tanh(x) {
67111    var a = expm1(x = +x);
67112    var b = expm1(-x);
67113    return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (exp(x) + exp(-x));
67114  }
67115});
67116
67117},{"./_export":"node_modules/core-js/modules/_export.js","./_math-expm1":"node_modules/core-js/modules/_math-expm1.js"}],"node_modules/core-js/modules/es6.math.trunc.js":[function(require,module,exports) {
67118// 20.2.2.34 Math.trunc(x)
67119var $export = require('./_export');
67120
67121$export($export.S, 'Math', {
67122  trunc: function trunc(it) {
67123    return (it >
67123 0 ? Math.floor : Math.ceil)(it);
67124  }
67125});
67126
67127},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.string.from-code-point.js":[function(require,module,exports) {
67128var $export = require('./_export');
67129var toAbsoluteIndex = require('./_to-absolute-index');
67130var fromCharCode = String.fromCharCode;
67131var $fromCodePoint = String.fromCodePoint;
67132
67133// length should be 1, old FF problem
67134$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
67135  // 21.1.2.2 String.fromCodePoint(...codePoints)
67136  fromCodePoint: function fromCodePoint(x) { // eslint-disable-line no-unused-vars
67137    var res = [];
67138    var aLen = arguments.length;
67139    var i = 0;
67140    var code;
67141    while (aLen > i) {
67142      code = +arguments[i++];
67143      if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point');
67144      res.push(code < 0x10000
67145        ? fromCharCode(code)
67146        : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
67147      );
67148    } return res.join('');
67149  }
67150});
67151
67152},{"./_export":"node_modules/core-js/modules/_export.js","./_to-absolute-index":"node_modules/core-js/modules/_to-absolute-index.js"}],"node_modules/core-js/modules/es6.string.raw.js":[function(require,module,exports) {
67153var $export = require('./_export');
67154var toIObject = require('./_to-iobject');
67155var toLength = require('./_to-length');
67156
67157$export($export.S, 'String', {
67158  // 21.1.2.4 String.raw(callSite, ...substitutions)
67159  raw: function raw(callSite) {
67160    var tpl = toIObject(callSite.raw);
67161    var len = toLength(tpl.length);
67162    var aLen = arguments.length;
67163    var res = [];
67164    var i = 0;
67165    while (len > i) {
67166      res.push(String(tpl[i++]));
67167      if (i < aLen) res.push(String(arguments[i]));
67168    } return res.join('');
67169  }
67170});
67171
67172},{"./_export":"node_modules/core-js/modules/_export.js","./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_to-length":"node_modules/core-js/modules/_to-length.js"}],"node_modules/core-js/modules/es6.string.trim.js":[function(require,module,exports) {
67173'use strict';
67174// 21.1.3.25 String.prototype.trim()
67175require('./_string-trim')('trim', function ($trim) {
67176  return function trim() {
67177    return $trim(this, 3);
67178  };
67179});
67180
67181},{"./_string-trim":"node_modules/core-js/modules/_string-trim.js"}],"node_modules/core-js/modules/_string-at.js":[function(require,module,exports) {
67182var toInteger = require('./_to-integer');
67183var defined = require('./_defined');
67184// true  -> String#at
67185// false -> String#codePointAt
67186module.exports = function (TO_STRING) {
67187  return function (that, pos) {
67188    var s = String(defined(that));
67189    var i = toInteger(pos);
67190    var l = s.length;
67191    var a, b;
67192    if (i < 0 || i >= l) return TO_STRING ? '' : undefined;
67193    a = s.charCodeAt(i);
67194    return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
67195      ? TO_STRING ? s.charAt(i) : a
67196      : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
67197  };
67198};
67199
67200},{"./_to-integer":"node_modules/core-js/modules/_to-integer.js","./_defined":"node_modules/core-js/modules/_defined.js"}],"node_modules/core-js/modules/_iterators.js":[function(require,module,exports) {
67201module.exports = {};
67202
67203},{}],"node_modules/core-js/modules/_iter-create.js":[function(require,module,exports) {
67204'use strict';
67205var create = require('./_object-create');
67206var descriptor = require('./_property-desc');
67207var setToStringTag = require('./_set-to-string-tag');
67208var IteratorPrototype = {};
67209
67210// 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
67211require('./_hide')(IteratorPrototype, require('./_wks')('iterator'), function () { return this; });
67212
67213module.exports = function (Constructor, NAME, next) {
67214  Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
67215  setToStringTag(Constructor, NAME + ' Iterator');
67216};
67217
67218},{"./_object-create":"node_modules/core-js/modules/_object-create.js","./_property-desc":"node_modules/core-js/modules/_property-desc.js","./_set-to-string-tag":"node_modules/core-js/modules/_set-to-string-tag.js","./_hide":"node_modules/core-js/modules/_hide.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/_iter-define.js":[function(require,module,exports) {
67219'use strict';
67220var LIBRARY = require('./_library');
vendor: 4,122 bytes, lines 67221-67309
67221var $export = require('./_export');
67222var redefine = require('./_redefine');
67223var hide = require('./_hide');
67224var Iterators = require('./_iterators');
67225var $iterCreate = require('./_iter-create');
67226var setToStringTag = require('./_set-to-string-tag');
67227var getPrototypeOf = require('./_object-gpo');
67228var ITERATOR = require('./_wks')('iterator');
67229var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
67230var FF_ITERATOR = '@@iterator';
67231var KEYS = 'keys';
67232var VALUES = 'values';
67233
67234var returnThis = function () { return this; };
67235
67236module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
67237  $iterCreate(Constructor, NAME, next);
67238  var getMethod = function (kind) {
67239    if (!BUGGY && kind in proto) return proto[kind];
67240    switch (kind) {
67241      case KEYS: return function keys() { return new Constructor(this, kind); };
67242      case VALUES: return function values() { return new Constructor(this, kind); };
67243    } return function entries() { return new Constructor(this, kind); };
67244  };
67245  var TAG = NAME + ' Iterator';
67246  var DEF_VALUES = DEFAULT == VALUES;
67247  var VALUES_BUG = false;
67248  var proto = Base.prototype;
67249  var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
67250  var $default = $native || getMethod(DEFAULT);
67251  var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
67252  var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
67253  var methods, key, IteratorPrototype;
67254  // Fix native
67255  if ($anyNative) {
67256    IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
67257    if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
67258      // Set @@toStringTag to native iterators
67259      setToStringTag(IteratorPrototype, TAG, true);
67260      // fix for some old engines
67261      if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
67262    }
67263  }
67264  // fix Array#{values, @@iterator}.name in V8 / FF
67265  if (DEF_VALUES && $native && $native.name !== VALUES) {
67266    VALUES_BUG = true;
67267    $default = function values() { return $native.call(this); };
67268  }
67269  // Define iterator
67270  if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
67271    hide(proto, ITERATOR, $default);
67272  }
67273  // Plug for library
67274  Iterators[NAME] = $default;
67275  Iterators[TAG] = returnThis;
67276  if (DEFAULT) {
67277    methods = {
67278      values: DEF_VALUES ? $default : getMethod(VALUES),
67279      keys: IS_SET ? $default : getMethod(KEYS),
67280      entries: $entries
67281    };
67282    if (FORCED) for (key in methods) {
67283      if (!(key in proto)) redefine(proto, key, methods[key]);
67284    } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
67285  }
67286  return methods;
67287};
67288
67289},{"./_library":"node_modules/core-js/modules/_library.js","./_export":"node_modules/core-js/modules/_export.js","./_redefine":"node_modules/core-js/modules/_redefine.js","./_hide":"node_modules/core-js/modules/_hide.js","./_iterators":"node_modules/core-js/modules/_iterators.js","./_iter-create":"node_modules/core-js/modules/_iter-create.js","./_set-to-string-tag":"node_modules/core-js/modules/_set-to-string-tag.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/es6.string.iterator.js":[function(require,module,exports) {
67290'use strict';
67291var $at = require('./_string-at')(true);
67292
67293// 21.1.3.27 String.prototype[@@iterator]()
67294require('./_iter-define')(String, 'String', function (iterated) {
67295  this._t = String(iterated); // target
67296  this._i = 0;                // next index
67297// 21.1.5.2.1 %StringIteratorPrototype%.next()
67298}, function () {
67299  var O = this._t;
67300  var index = this._i;
67301  var point;
67302  if (index >= O.length) return { value: undefined, done: true };
67303  point = $at(O, index);
67304  this._i += point.length;
67305  return { value: point, done: false };
67306});
67307
67308},{"./_string-at":"node_modules/core-js/modules/_string-at.js","./_iter-define":"node_modules/core-js/modules/_iter-define.js"}],"node_modules/core-js/modules/es6.string.code-point-at.js":[function(require,module,exports) {
67309'use strict';
67310var $export = require('./_export');
67311var $at = require('./_string-at')(false);
67312$export($export.P, 'String', {
67313  // 21.1.3.3 String.prototype.codePointAt(pos)
67314  codePointAt: function codePointAt(pos) {
67315    return $at(this, pos);
67316  }
67317});
67318
67319},{"./_export":"node_modules/core-js/modules/_export.js","./_string-at":"node_modules/core-js/modules/_string-at.js"}],"node_modules/core-js/modules/_is-regexp.js":[function(require,module,exports) {
67320// 7.2.8 IsRegExp(argument)
67321var isObject = require('./_is-object');
67322var cof = require('./_cof');
67323var MATCH = require('./_wks')('match');
67324module.exports = function (it) {
67325  var isRegExp;
67326  return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp');
67327};
67328
67329},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_cof":"node_modules/core-js/modules/_cof.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/_string-context.js":[function(require,module,exports) {
67330// helper for String#{startsWith, endsWith, includes}
67331var isRegExp = require('./_is-regexp');
67332var defined = require('./_defined');
67333
67334module.exports = function (that, searchString, NAME) {
67335  if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!");
67336  return String(defined(that));
67337};
67338
67339},{"./_is-regexp":"node_modules/core-js/modules/_is-regexp.js","./_defined":"node_modules/core-js/modules/_defined.js"}],"node_modules/core-js/modules/_fails-is-regexp.js":[function(require,module,exports) {
67340var MATCH = require('./_wks')('match');
67341module.exports = function (KEY) {
67342  var re = /./;
67343  try {
67344    '/./'[KEY](re);
67345  } catch (e) {
67346    try {
67347      re[MATCH] = false;
67348      return !'/./'[KEY](re);
67349    } catch (f) { /* empty */ }
67350  } return true;
67351};
67352
67353},{"./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/es6.string.ends-with.js":[function(require,module,exports) {
67354// 21.1.3.6 String.prototype.endsWith(searchString [, endPosition])
67355'use strict';
67356var $export = require('./_export');
67357var toLength = require('./_to-length');
67358var context = require('./_string-context');
67359var ENDS_WITH = 'endsWith';
67360var $endsWith = ''[ENDS_WITH];
67361
67362$export($export.P + $export.F * require('./_fails-is-regexp')(ENDS_WITH), 'String', {
67363  endsWith: function endsWith(searchString /* , endPosition = @length */) {
67364    var that = context(this, searchString, ENDS_WITH);
67365    var endPosition = arguments.length > 1 ? arguments[1] : undefined;
67366    var len = toLength(that.length);
67367    var end = endPosition === undefined ? len : Math.min(toLength(endPosition), len);
67368    var search = String(searchString);
67369    return $endsWith
67370      ? $endsWith.call(that, search, end)
67371      : that.slice(end - search.length, end) === search;
67372  }
67373});
67374
67375},{"./_export":"node_modules/core-js/modules/_export.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_string-context":"node_modules/core-js/modules/_string-context.js","./_fails-is-regexp":"node_modules/core-js/modules/_fails-is-regexp.js"}],"node_modules/core-js/modules/es6.string.includes.js":[function(require,module,exports) {
67376// 21.1.3.7 String.prototype.includes(searchString, position = 0)
67377'use strict';
67378var $export = require('./_export');
67379var context = require('./_string-context');
67380var INCLUDES = 'includes';
67381
67382$export($export.P + $export.F * require('./_fails-is-regexp')(INCLUDES), 'String', {
67383  includes: function includes(searchString /* , position = 0 */) {
67384    return !!~context(this, searchString, INCLUDES)
67385      .indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined);
67386  }
67387});
67388
67389},{"./_export":"node_modules/core-js/modules/_export.js","./_string-context":"node_modules/core-js/modules/_string-context.js","./_fails-is-regexp":"node_modules/core-js/modules/_fails-is-regexp.js"}],"node_modules/core-js/modules/es6.string.repeat.js":[function(require,module,exports) {
67390var $export = require('./_export');
67391
67392$export($export.P, 'String', {
67393  // 21.1.3.13 String.prototype.repeat(count)
67394  repeat: require('./_string-repeat')
67395});
67396
67397},{"./_export":"node_modules/core-js/modules/_export.js","./_string-repeat":"node_modules/core-js/modules/_string-repeat.js"}],"node_modules/core-js/modules/es6.string.starts-with.js":[function(require,module,exports) {
67398// 21.1.3.18 String.prototype.startsWith(searchString [, position ])
67399'use strict';
vendor: 6,596 bytes, lines 67400-67556
67400var $export = require('./_export');
67401var toLength = require('./_to-length');
67402var context = require('./_string-context');
67403var STARTS_WITH = 'startsWith';
67404var $startsWith = ''[STARTS_WITH];
67405
67406$export($export.P + $export.F * require('./_fails-is-regexp')(STARTS_WITH), 'String', {
67407  startsWith: function startsWith(searchString /* , position = 0 */) {
67408    var that = context(this, searchString, STARTS_WITH);
67409    var index = toLength(Math.min(arguments.length > 1 ? arguments[1] : undefined, that.length));
67410    var search = String(searchString);
67411    return $startsWith
67412      ? $startsWith.call(that, search, index)
67413      : that.slice(index, index + search.length) === search;
67414  }
67415});
67416
67417},{"./_export":"node_modules/core-js/modules/_export.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_string-context":"node_modules/core-js/modules/_string-context.js","./_fails-is-regexp":"node_modules/core-js/modules/_fails-is-regexp.js"}],"node_modules/core-js/modules/_string-html.js":[function(require,module,exports) {
67418var $export = require('./_export');
67419var fails = require('./_fails');
67420var defined = require('./_defined');
67421var quot = /"/g;
67422// B.2.3.2.1 CreateHTML(string, tag, attribute, value)
67423var createHTML = function (string, tag, attribute, value) {
67424  var S = String(defined(string));
67425  var p1 = '<' + tag;
67426  if (attribute !== '') p1 += ' ' + attribute + '="' + String(value).replace(quot, '&quot;') + '"';
67427  return p1 + '>' + S + '</' + tag + '>';
67428};
67429module.exports = function (NAME, exec) {
67430  var O = {};
67431  O[NAME] = exec(createHTML);
67432  $export($export.P + $export.F * fails(function () {
67433    var test = ''[NAME]('"');
67434    return test !== test.toLowerCase() || test.split('"').length > 3;
67435  }), 'String', O);
67436};
67437
67438},{"./_export":"node_modules/core-js/modules/_export.js","./_fails":"node_modules/core-js/modules/_fails.js","./_defined":"node_modules/core-js/modules/_defined.js"}],"node_modules/core-js/modules/es6.string.anchor.js":[function(require,module,exports) {
67439'use strict';
67440// B.2.3.2 String.prototype.anchor(name)
67441require('./_string-html')('anchor', function (createHTML) {
67442  return function anchor(name) {
67443    return createHTML(this, 'a', 'name', name);
67444  };
67445});
67446
67447},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.big.js":[function(require,module,exports) {
67448'use strict';
67449// B.2.3.3 String.prototype.big()
67450require('./_string-html')('big', function (createHTML) {
67451  return function big() {
67452    return createHTML(this, 'big', '', '');
67453  };
67454});
67455
67456},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.blink.js":[function(require,module,exports) {
67457'use strict';
67458// B.2.3.4 String.prototype.blink()
67459require('./_string-html')('blink', function (createHTML) {
67460  return function blink() {
67461    return createHTML(this, 'blink', '', '');
67462  };
67463});
67464
67465},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.bold.js":[function(require,module,exports) {
67466'use strict';
67467// B.2.3.5 String.prototype.bold()
67468require('./_string-html')('bold', function (createHTML) {
67469  return function bold() {
67470    return createHTML(this, 'b', '', '');
67471  };
67472});
67473
67474},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.fixed.js":[function(require,module,exports) {
67475'use strict';
67476// B.2.3.6 String.prototype.fixed()
67477require('./_string-html')('fixed', function (createHTML) {
67478  return function fixed() {
67479    return createHTML(this, 'tt', '', '');
67480  };
67481});
67482
67483},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.fontcolor.js":[function(require,module,exports) {
67484'use strict';
67485// B.2.3.7 String.prototype.fontcolor(color)
67486require('./_string-html')('fontcolor', function (createHTML) {
67487  return function fontcolor(color) {
67488    return createHTML(this, 'font', 'color', color);
67489  };
67490});
67491
67492},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.fontsize.js":[function(require,module,exports) {
67493'use strict';
67494// B.2.3.8 String.prototype.fontsize(size)
67495require('./_string-html')('fontsize', function (createHTML) {
67496  return function fontsize(size) {
67497    return createHTML(this, 'font', 'size', size);
67498  };
67499});
67500
67501},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.italics.js":[function(require,module,exports) {
67502'use strict';
67503// B.2.3.9 String.prototype.italics()
67504require('./_string-html')('italics', function (createHTML) {
67505  return function italics() {
67506    return createHTML(this, 'i', '', '');
67507  };
67508});
67509
67510},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.link.js":[function(require,module,exports) {
67511'use strict';
67512// B.2.3.10 String.prototype.link(url)
67513require('./_string-html')('link', function (createHTML) {
67514  return function link(url) {
67515    return createHTML(this, 'a', 'href', url);
67516  };
67517});
67518
67519},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.small.js":[function(require,module,exports) {
67520'use strict';
67521// B.2.3.11 String.prototype.small()
67522require('./_string-html')('small', function (createHTML) {
67523  return function small() {
67524    return createHTML(this, 'small', '', '');
67525  };
67526});
67527
67528},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.strike.js":[function(require,module,exports) {
67529'use strict';
67530// B.2.3.12 String.prototype.strike()
67531require('./_string-html')('strike', function (createHTML) {
67532  return function strike() {
67533    return createHTML(this, 'strike', '', '');
67534  };
67535});
67536
67537},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.sub.js":[function(require,module,exports) {
67538'use strict';
67539// B.2.3.13 String.prototype.sub()
67540require('./_string-html')('sub', function (createHTML) {
67541  return function sub() {
67542    return createHTML(this, 'sub', '', '');
67543  };
67544});
67545
67546},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.string.sup.js":[function(require,module,exports) {
67547'use strict';
67548// B.2.3.14 String.prototype.sup()
67549require('./_string-html')('sup', function (createHTML) {
67550  return function sup() {
67551    return createHTML(this, 'sup', '', '');
67552  };
67553});
67554
67555},{"./_string-html":"node_modules/core-js/modules/_string-html.js"}],"node_modules/core-js/modules/es6.date.now.js":[function(require,module,exports) {
67556// 20.3.3.1 / 15.9.4.4 Date.now()
67557var $export = require('./_export');
67558
67559$export($export.S, 'Date', { now: function () { return new Date().getTime(); } });
67560
67561},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.date.to-json.js":[function(require,module,exports) {
67562'use strict';
67563var $export = require('./_export');
67564var toObject = require('./_to-object');
67565var toPrimitive = require('./_to-primitive');
67566
67567$export($export.P + $export.F * require('./_fails')(function () {
67568  return new Date(NaN).toJSON() !== null
67569    || Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1;
67570}), 'Date', {
67571  // eslint-disable-next-line no-unused-vars
67572  toJSON: function toJSON(key) {
67573    var O = toObject(this);
67574    var pv = toPrimitive(O);
67575    return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
67576  }
67577});
67578
67579},{"./_export":"node_modules/core-js/modules/_export.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/_date-to-iso-string.js":[function(require,module,exports) {
67580'use strict';
67581// 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
67582var fails = require('./_fails');
67583var getTime = Date.prototype.getTime;
67584var $toISOString = Date.prototype.toISOString;
67585
67586var lz = function (num) {
67587  return num > 9 ? num : '0' + num;
67588};
67589
67590// PhantomJS / old WebKit has a broken implementations
67591module.exports = (fails(function () {
67592  return $toISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';
67593}) || !fails(function () {
67594  $toISOString.call(new Date(NaN));
67595})) ? function toISOString() {
67596  if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value');
67597  var d = this;
67598  var y = d.getUTCFullYear();
67599  var m = d.getUTCMilliseconds();
67600  var s = y < 0 ? '-' : y > 9999 ? '+' : '';
67601  return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) +
67602    '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) +
67603    'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) +
67604    ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z';
67605} : $toISOString;
67606
67607},{"./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.date.to-iso-string.js":[function(require,module,exports) {
67608// 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
67609var $export = require('./_export');
67610var toISOString = require('./_date-to-iso-string');
67611
67612// PhantomJS / old WebKit has a broken implementations
67613$export($export.P + $export.F * (Date.prototype.toISOString !== toISOString), 'Date', {
67614  toISOString: toISOString
67615});
67616
67617},{"./_export":"node_modules/core-js/modules/_export.js","./_date-to-iso-string":"node_modules/core-js/modules/_date-to-iso-string.js"}],"node_modules/core-js/modules/es6.date.to-string.js":[function(require,module,exports) {
67618var DateProto = Date.prototype;
67619var INVALID_DATE = 'Invalid Date';
67620var TO_STRING = 'toString';
67621var $toString = DateProto[TO_STRING];
67622var getTime = DateProto.getTime;
67623if (new Date(NaN) + '' != INVALID_DATE) {
67624  require('./_redefine')(DateProto, TO_STRING, function toString() {
67625    var value = getTime.call(this);
67626    // eslint-disable-next-line no-self-compare
67627    return value === value ? $toString.call(this) : INVALID_DATE;
67628  });
67629}
67630
67631},{"./_redefine":"node_modules/core-js/modules/_redefine.js"}],"node_modules/core-js/modules/_date-to-primitive.js":[function(require,module,exports) {
67632'use strict';
67633var anObject = require('./_an-object');
67634var toPrimitive = require('./_to-primitive');
67635var NUMBER = 'number';
67636
67637module.exports = function (hint) {
67638  if (hint !== 'string' && hint !== NUMBER && hint !== 'default') throw TypeError('Incorrect hint');
67639  return toPrimitive(anObject(this), hint != NUMBER);
67640};
67641
67642},{"./_an-object":"node_modules/core-js/modules/_an-object.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js"}],"node_modules/core-js/modules/es6.date.to-primitive.js":[function(require,module,exports) {
67643var TO_PRIMITIVE = require('./_wks')('toPrimitive');
67644var proto = Date.prototype;
67645
67646if (!(TO_PRIMITIVE in proto)) require('./_hide')(proto, TO_PRIMITIVE, require('./_date-to-primitive'));
67647
67648},{"./_wks":"node_modules/core-js/modules/_wks.js","./_hide":"node_modules/core-js/modules/_hide.js","./_date-to-primitive":"node_modules/core-js/modules/_date-to-primitive.js"}],"node_modules/core-js/modules/es6.array.is-array.js":[function(require,module,exports) {
67649// 22.1.2.2 / 15.4.3.2 Array.isArray(arg)
67650var $export = require('./_export');
67651
67652$export($export.S, 'Array', { isArray: require('./_is-array') });
67653
67654},{"./_export":"node_modules/core-js/modules/_export.js","./_is-array":"node_modules/core-js/modules/_is-array.js"}],"node_modules/core-js/modules/_iter-call.js":[function(require,module,exports) {
67655// call something on iterator step with safe closing on error
67656var anObject = require('./_an-object');
67657module.exports = function (iterator, fn, value, entries) {
67658  try {
67659    return entries ? fn(anObject(value)[0], value[1]) : fn(value);
67660  // 7.4.6 IteratorClose(iterator, completion)
67661  } catch (e) {
67662    var ret = iterator['return'];
67663    if (ret !== undefined) anObject(ret.call(iterator));
67664    throw e;
67665  }
67666};
67667
67668},{"./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/_is-array-iter.js":[function(require,module,exports) {
67669// check on default Array iterator
67670var Iterators = require('./_iterators');
67671var ITERATOR = require('./_wks')('iterator');
67672var ArrayProto = Array.prototype;
67673
67674module.exports = function (it) {
67675  return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
67676};
67677
67678},{"./_iterators":"node_modules/core-js/modules/_iterators.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/_create-property.js":[function(require,module,exports) {
67679'use strict';
67680var $defineProperty = require('./_object-dp');
67681var createDesc = require('./_property-desc');
67682
67683module.exports = function (object, index, value) {
67684  if (index in object) $defineProperty.f(object, index, createDesc(0, value));
67685  else object[index] = value;
67686};
67687
67688},{"./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_property-desc":"node_modules/core-js/modules/_property-desc.js"}],"node_modules/core-js/modules/core.get-iterator-method.js":[function(require,module,exports) {
67689var classof = require('./_classof');
67690var ITERATOR = require('./_wks')('iterator');
67691var Iterators = require('./_iterators');
67692module.exports = require('./_core').getIteratorMethod = function (it) {
67693  if (it != undefined) return it[ITERATOR]
67694    || it['@@iterator']
67695    || Iterators[classof(it)];
67696};
67697
67698},{"./_classof":"node_modules/core-js/modules/_classof.js","./_wks":"node_modules/core-js/modules/_wks.js","./_iterators":"node_modules/core-js/modules/_iterators.js","./_core":"node_modules/core-js/modules/_core.js"}],"node_modules/core-js/modules/_iter-detect.js":[function(require,module,exports) {
vendor: 4,234 bytes, lines 67699-67793
67699var ITERATOR = require('./_wks')('iterator');
67700var SAFE_CLOSING = false;
67701
67702try {
67703  var riter = [7][ITERATOR]();
67704  riter['return'] = function () { SAFE_CLOSING = true; };
67705  // eslint-disable-next-line no-throw-literal
67706  Array.from(riter, function () { throw 2; });
67707} catch (e) { /* empty */ }
67708
67709module.exports = function (exec, skipClosing) {
67710  if (!skipClosing && !SAFE_CLOSING) return false;
67711  var safe = false;
67712  try {
67713    var arr = [7];
67714    var iter = arr[ITERATOR]();
67715    iter.next = function () { return { done: safe = true }; };
67716    arr[ITERATOR] = function () { return iter; };
67717    exec(arr);
67718  } catch (e) { /* empty */ }
67719  return safe;
67720};
67721
67722},{"./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/es6.array.from.js":[function(require,module,exports) {
67723'use strict';
67724var ctx = require('./_ctx');
67725var $export = require('./_export');
67726var toObject = require('./_to-object');
67727var call = require('./_iter-call');
67728var isArrayIter = require('./_is-array-iter');
67729var toLength = require('./_to-length');
67730var createProperty = require('./_create-property');
67731var getIterFn = require('./core.get-iterator-method');
67732
67733$export($export.S + $export.F * !require('./_iter-detect')(function (iter) { Array.from(iter); }), 'Array', {
67734  // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
67735  from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
67736    var O = toObject(arrayLike);
67737    var C = typeof this == 'function' ? this : Array;
67738    var aLen = arguments.length;
67739    var mapfn = aLen > 1 ? arguments[1] : undefined;
67740    var mapping = mapfn !== undefined;
67741    var index = 0;
67742    var iterFn = getIterFn(O);
67743    var length, result, step, iterator;
67744    if (mapping) mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
67745    // if object isn't iterable or it's array with default iterator - use simple case
67746    if (iterFn != undefined && !(C == Array && isArrayIter(iterFn))) {
67747      for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) {
67748        createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
67749      }
67750    } else {
67751      length = toLength(O.length);
67752      for (result = new C(length); length > index; index++) {
67753        createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
67754      }
67755    }
67756    result.length = index;
67757    return result;
67758  }
67759});
67760
67761},{"./_ctx":"node_modules/core-js/modules/_ctx.js","./_export":"node_modules/core-js/modules/_export.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_iter-call":"node_modules/core-js/modules/_iter-call.js","./_is-array-iter":"node_modules/core-js/modules/_is-array-iter.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_create-property":"node_modules/core-js/modules/_create-property.js","./core.get-iterator-method":"node_modules/core-js/modules/core.get-iterator-method.js","./_iter-detect":"node_modules/core-js/modules/_iter-detect.js"}],"node_modules/core-js/modules/es6.array.of.js":[function(require,module,exports) {
67762'use strict';
67763var $export = require('./_export');
67764var createProperty = require('./_create-property');
67765
67766// WebKit Array.of isn't generic
67767$export($export.S + $export.F * require('./_fails')(function () {
67768  function F() { /* empty */ }
67769  return !(Array.of.call(F) instanceof F);
67770}), 'Array', {
67771  // 22.1.2.3 Array.of( ...items)
67772  of: function of(/* ...args */) {
67773    var index = 0;
67774    var aLen = arguments.length;
67775    var result = new (typeof this == 'function' ? this : Array)(aLen);
67776    while (aLen > index) createProperty(result, index, arguments[index++]);
67777    result.length = aLen;
67778    return result;
67779  }
67780});
67781
67782},{"./_export":"node_modules/core-js/modules/_export.js","./_create-property":"node_modules/core-js/modules/_create-property.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/_strict-method.js":[function(require,module,exports) {
67783'use strict';
67784var fails = require('./_fails');
67785
67786module.exports = function (method, arg) {
67787  return !!method && fails(function () {
67788    // eslint-disable-next-line no-useless-call
67789    arg ? method.call(null, function () { /* empty */ }, 1) : method.call(null);
67790  });
67791};
67792
67793}
67793,{"./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.array.join.js":[function(require,module,exports) {
67794'use strict';
67795// 22.1.3.13 Array.prototype.join(separator)
67796var $export = require('./_export');
67797var toIObject = require('./_to-iobject');
67798var arrayJoin = [].join;
67799
67800// fallback for not array-like strings
67801$export($export.P + $export.F * (require('./_iobject') != Object || !require('./_strict-method')(arrayJoin)), 'Array', {
67802  join: function join(separator) {
67803    return arrayJoin.call(toIObject(this), separator === undefined ? ',' : separator);
67804  }
67805});
67806
67807},{"./_export":"node_modules/core-js/modules/_export.js","./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_iobject":"node_modules/core-js/modules/_iobject.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/es6.array.slice.js":[function(require,module,exports) {
67808'use strict';
67809var $export = require('./_export');
67810var html = require('./_html');
67811var cof = require('./_cof');
67812var toAbsoluteIndex = require('./_to-absolute-index');
67813var toLength = require('./_to-length');
67814var arraySlice = [].slice;
67815
67816// fallback for not array-like ES3 strings and DOM objects
67817$export($export.P + $export.F * require('./_fails')(function () {
67818  if (html) arraySlice.call(html);
67819}), 'Array', {
67820  slice: function slice(begin, end) {
67821    var len = toLength(this.length);
67822    var klass = cof(this);
67823    end = end === undefined ? len : end;
67824    if (klass == 'Array') return arraySlice.call(this, begin, end);
67825    var start = toAbsoluteIndex(begin, len);
67826    var upTo = toAbsoluteIndex(end, len);
67827    var size = toLength(upTo - start);
67828    var cloned = new Array(size);
67829    var i = 0;
67830    for (; i < size; i++) cloned[i] = klass == 'String'
67831      ? this.charAt(start + i)
67832      : this[start + i];
67833    return cloned;
67834  }
67835});
67836
67837},{"./_export":"node_modules/core-js/modules/_export.js","./_html":"node_modules/core-js/modules/_html.js","./_cof":"node_modules/core-js/modules/_cof.js","./_to-absolute-index":"node_modules/core-js/modules/_to-absolute-index.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.array.sort.js":[function(require,module,exports) {
67838'use strict';
67839var $export = require('./_export');
67840var aFunction = require('./_a-function');
67841var toObject = require('./_to-object');
67842var fails = require('./_fails');
67843var $sort = [].sort;
67844var test = [1, 2, 3];
67845
67846$export($export.P + $export.F * (fails(function () {
67847  // IE8-
67848  test.sort(undefined);
67849}) || !fails(function () {
67850  // V8 bug
67851  test.sort(null);
67852  // Old WebKit
67853}) || !require('./_strict-method')($sort)), 'Array', {
67854  // 22.1.3.25 Array.prototype.sort(comparefn)
67855  sort: function sort(comparefn) {
67856    return comparefn === undefined
67857      ? $sort.call(toObject(this))
67858      : $sort.call(toObject(this), aFunction(comparefn));
67859  }
67860});
67861
67862},{"./_export":"node_modules/core-js/modules/_export.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_fails":"node_modules/core-js/modules/_fails.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/_array-species-constructor.js":[function(require,module,exports) {
67863var isObject = require('./_is-object');
67864var isArray = require('./_is-array');
67865var SPECIES = require('./_wks')('species');
67866
67867module.exports = function (original) {
67868  var C;
67869  if (isArray(original)) {
67870    C = original.constructor;
67871    // cross-realm fallback
67872    if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
67873    if (isObject(C)) {
67874      C = C[SPECIES];
67875      if (C === null) C = undefined;
67876    }
67877  } return C === undefined ? Array : C;
67878};
67879
67880},{"./_is-object":"node_modules/core-js/modules/_is-object.js","./_is-array":"node_modules/core-js/modules/_is-array.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/_array-species-create.js":[function(require,module,exports) {
67881// 9.4.2.3 ArraySpeciesCreate(originalArray, length)
67882var speciesConstructor = require('./_array-species-constructor');
67883
67884module.exports = function (original, length) {
67885  return new (speciesConstructor(original))(length);
67886};
67887
67888},{"./_array-species-constructor":"node_modules/core-js/modules/_array-species-constructor.js"}],"node_modules/core-js/modules/_array-methods.js":[function(require,module,exports) {
67889// 0 -> Array#forEach
67890// 1 -> Array#map
67891// 2 -> Array#filter
67892// 3 -> Array#some
67893// 4 -> Array#every
67894// 5 -> Array#find
67895// 6 -> Array#findIndex
67896var ctx = require('./_ctx');
67897var IObject = require('./_iobject');
67898var toObject = require('./_to-object');
vendor: 4,290 bytes, lines 67899-67984
67899var toLength = require('./_to-length');
67900var asc = require('./_array-species-create');
67901module.exports = function (TYPE, $create) {
67902  var IS_MAP = TYPE == 1;
67903  var IS_FILTER = TYPE == 2;
67904  var IS_SOME = TYPE == 3;
67905  var IS_EVERY = TYPE == 4;
67906  var IS_FIND_INDEX = TYPE == 6;
67907  var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
67908  var create = $create || asc;
67909  return function ($this, callbackfn, that) {
67910    var O = toObject($this);
67911    var self = IObject(O);
67912    var f = ctx(callbackfn, that, 3);
67913    var length = toLength(self.length);
67914    var index = 0;
67915    var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
67916    var val, res;
67917    for (;length > index; index++) if (NO_HOLES || index in self) {
67918      val = self[index];
67919      res = f(val, index, O);
67920      if (TYPE) {
67921        if (IS_MAP) result[index] = res;   // map
67922        else if (res) switch (TYPE) {
67923          case 3: return true;             // some
67924          case 5: return val;              // find
67925          case 6: return index;            // findIndex
67926          case 2: result.push(val);        // filter
67927        } else if (IS_EVERY) return false; // every
67928      }
67929    }
67930    return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result;
67931  };
67932};
67933
67934},{"./_ctx":"node_modules/core-js/modules/_ctx.js","./_iobject":"node_modules/core-js/modules/_iobject.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_array-species-create":"node_modules/core-js/modules/_array-species-create.js"}],"node_modules/core-js/modules/es6.array.for-each.js":[function(require,module,exports) {
67935'use strict';
67936var $export = require('./_export');
67937var $forEach = require('./_array-methods')(0);
67938var STRICT = require('./_strict-method')([].forEach, true);
67939
67940$export($export.P + $export.F * !STRICT, 'Array', {
67941  // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg])
67942  forEach: function forEach(callbackfn /* , thisArg */) {
67943    return $forEach(this, callbackfn, arguments[1]);
67944  }
67945});
67946
67947},{"./_export":"node_modules/core-js/modules/_export.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/es6.array.map.js":[function(require,module,exports) {
67948'use strict';
67949var $export = require('./_export');
67950var $map = require('./_array-methods')(1);
67951
67952$export($export.P + $export.F * !require('./_strict-method')([].map, true), 'Array', {
67953  // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg])
67954  map: function map(callbackfn /* , thisArg */) {
67955    return $map(this, callbackfn, arguments[1]);
67956  }
67957});
67958
67959},{"./_export":"node_modules/core-js/modules/_export.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/es6.array.filter.js":[function(require,module,exports) {
67960'use strict';
67961var $export = require('./_export');
67962var $filter = require('./_array-methods')(2);
67963
67964$export($export.P + $export.F * !require('./_strict-method')([].filter, true), 'Array', {
67965  // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg])
67966  filter: function filter(callbackfn /* , thisArg */) {
67967    return $filter(this, callbackfn, arguments[1]);
67968  }
67969});
67970
67971},{"./_export":"node_modules/core-js/modules/_export.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/es6.array.some.js":[function(require,module,exports) {
67972'use strict';
67973var $export = require('./_export');
67974var $some = require('./_array-methods')(3);
67975
67976$export($export.P + $export.F * !require('./_strict-method')([].some, true), 'Array', {
67977  // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg])
67978  some: function some(callbackfn /* , thisArg */) {
67979    return $some(this, callbackfn, arguments[1]);
67980  }
67981});
67982
67983},{"./_export":"node_modules/core-js/modules/_export.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/es6.array.every.js":[function(require,module,exports) {
67984'use strict';
67985var $export = require('./_export');
67986var $every = require('./_array-methods')(4);
67987
67988$export($export.P + $export.F * !require('./_strict-method')([].every, true), 'Array', {
67989  // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg])
67990  every: function every(callbackfn /* , thisArg */) {
67991    return $every(this, callbackfn, arguments[1]);
67992  }
67993});
67994
67995},{"./_export":"node_modules/core-js/modules/_export.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/_array-reduce.js":[function(require,module,exports) {
67996var aFunction = require('./_a-function');
67997var toObject = require('./_to-object');
67998var IObject = require('./_iobject');
67999var toLength = require('./_to-length');
68000
68001module.exports = function (that, callbackfn, aLen, memo, isRight) {
68002  aFunction(callbackfn);
68003  var O = toObject(that);
68004  var self = IObject(O);
68005  var length = toLength(O.length);
68006  var index = isRight ? length - 1 : 0;
68007  var i = isRight ? -1 : 1;
68008  if (aLen < 2) for (;;) {
68009    if (index in self) {
68010      memo = self[index];
68011      index += i;
68012      break;
68013    }
68014    index += i;
68015    if (isRight ? index < 0 : length <= index) {
68016      throw TypeError('Reduce of empty array with no initial value');
68017    }
68018  }
68019  for (;isRight ? index >= 0 : length > index; index += i) if (index in self) {
68020    memo = callbackfn(memo, self[index], index, O);
68021  }
68022  return memo;
68023};
68024
68025},{"./_a-function":"node_modules/core-js/modules/_a-function.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_iobject":"node_modules/core-js/modules/_iobject.js","./_to-length":"node_modules/core-js/modules/_to-length.js"}],"node_modules/core-js/modules/es6.array.reduce.js":[function(require,module,exports) {
68026'use strict';
68027var $export = require('./_export');
68028var $reduce = require('./_array-reduce');
68029
68030$export($export.P + $export.F * !require('./_strict-method')([].reduce, true), 'Array', {
68031  // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue])
68032  reduce: function reduce(callbackfn /* , initialValue */) {
68033    return $reduce(this, callbackfn, arguments.length, arguments[1], false);
68034  }
68035});
68036
68037},{"./_export":"node_modules/core-js/modules/_export.js","./_array-reduce":"node_modules/core-js/modules/_array-reduce.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/es6.array.reduce-right.js":[function(require,module,exports) {
68038'use strict';
68039var $export = require('./_export');
68040var $reduce = require('./_array-reduce');
68041
68042$export($export.P + $export.F * !require('./_strict-method')([].reduceRight, true), 'Array', {
68043  // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue])
68044  reduceRight: function reduceRight(callbackfn /* , initialValue */) {
68045    return $reduce(this, callbackfn, arguments.length, arguments[1], true);
68046  }
68047});
68048
68049},{"./_export":"node_modules/core-js/modules/_export.js","./_array-reduce":"node_modules/core-js/modules/_array-reduce.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/es6.array.index-of.js":[function(require,module,exports) {
68050'use strict';
68051var $export = require('./_export');
68052var $indexOf = require('./_array-includes')(false);
68053var $native = [].indexOf;
68054var NEGATIVE_ZERO = !!$native && 1 / [1].indexOf(1, -0) < 0;
68055
68056$export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($native)), 'Array', {
68057  // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex])
68058  indexOf: function indexOf(searchElement /* , fromIndex = 0 */) {
68059    return NEGATIVE_ZERO
68060      // convert -0 to +0
68061      ? $native.apply(this, arguments) || 0
68062      : $indexOf(this, searchElement, arguments[1]);
68063  }
68064});
68065
68066},{"./_export":"node_modules/core-js/modules/_export.js","./_array-includes":"node_modules/core-js/modules/_array-includes.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/es6.array.last-index-of.js":[function(require,module,exports) {
68067'use strict';
68068var $export = require('./_export');
68069var toIObject = require('./_to-iobject');
68070var toInteger = require('./_to-integer');
68071var toLength = require('./_to-length');
68072var $native = [].lastIndexOf;
68073var NEGATIVE_ZERO = !!$native && 1 / [1].lastIndexOf(1, -0) < 0;
68074
68075$export($export.P + $export.F * (NEGATIVE_ZERO || !require('./_strict-method')($native)), 'Array', {
68076  // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex])
68077  lastIndexOf: function lastIndexOf(searchElement /* , fromIndex = @[*-1] */) {
68078    // convert -0 to +0
68079    if (NEGATIVE_ZERO) return $native.apply(this, arguments) || 0;
68080    var O = toIObject(this);
68081    var length = toLength(O.length);
68082    var index = length - 1;
68083    if (arguments.length > 1) index = Math.min(index, toInteger(arguments[1]));
68084    if (index < 0) index = length + index;
68085    for (;index >= 0; index--) if (index in O) if (O[index] === searchElement) return index || 0;
68086    return -1;
68087  }
68088});
68089
68090},{"./_export":"node_modules/core-js/modules/_export.js","./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_to-integer":"node_modules/core-js/modules/_to-integer.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_strict-method":"node_modules/core-js/modules/_strict-method.js"}],"node_modules/core-js/modules/_array-copy-within.js":[function(require,module,exports) {
68091// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
68092'use strict';
68093var toObject = require('./_to-object');
68094var toAbsoluteIndex = require('./_to-absolute-index');
68095var toLength = require('./_to-length');
68096
68097module.exports = [].copyWithin || function copyWithin(target /* = 0 */, start /* = 0, end = @length */) {
68098  var O = toObject(this);
68099  var len = toLength(O.length);
68100  var to = toAbsoluteIndex(target, len);
68101  var from = toAbsoluteIndex(start, len);
68102  var end = arguments.length > 2 ? arguments[2] : undefined;
68103  var count = Math.min((end === undefined ? len : toAbsoluteIndex(end, len)) - from, len - to);
68104  var inc = 1;
68105  if (from < to && to < from + count) {
68106    inc = -1;
68107    from += count - 1;
68108    to += count - 1;
68109  }
68110  while (count-- > 0) {
68111    if (from in O) O[to] = O[from];
68112    else delete O[to];
68113    to += inc;
68114    from += inc;
68115  } return O;
68116};
68117
68118},{"./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-absolute-index":"node_modules/core-js/modules/_to-absolute-index.js","./_to-length":"node_modules/core-js/modules/_to-length.js"}],"node_modules/core-js/modules/_add-to-unscopables.js":[function(require,module,exports) {
68119// 22.1.3.31 Array.prototype[@@unscopables]
68120var UNSCOPABLES = require('./_wks')('unscopables');
68121var ArrayProto = Array.prototype;
68122if (ArrayProto[UNSCOPABLES] == undefined) require('./_hide')(ArrayProto, UNSCOPABLES, {});
68123module.exports = function (key) {
68124  ArrayProto[UNSCOPABLES][key] = true;
68125};
68126
68127},{"./_wks":"node_modules/core-js/modules/_wks.js","./_hide":"node_modules/core-js/modules/_hide.js"}],"node_modules/core-js/modules/es6.array.copy-within.js":[function(require,module,exports) {
68128// 22.1.3.3 Array.prototype.copyWithin(target, start, end = this.length)
68129var $export = require('./_export');
68130
68131$export($export.P, 'Array', { copyWithin: require('./_array-copy-within') });
68132
68133require('./_add-to-unscopables')('copyWithin');
68134
68135},{"./_export":"node_modules/core-js/modules/_export.js","./_array-copy-within":"node_modules/core-js/modules/_array-copy-within.js","./_add-to-unscopables":"node_modules/core-js/modules/_add-to-unscopables.js"}],"node_modules/core-js/modules/_array-fill.js":[function(require,module,exports) {
68136// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
68137'use strict';
68138var toObject = require('./_to-object');
68139var toAbsoluteIndex = require('./_to-absolute-index');
68140var toLength = require('./_to-length');
68141module.exports = function fill(value /* , start = 0, end = @length */) {
68142  var O = toObject(this);
68143  var length = toLength(O.length);
68144  var aLen = arguments.length;
68145  var index = toAbsoluteIndex(aLen > 1 ? arguments[1] : undefined, length);
68146  var end = aLen > 2 ? arguments[2] : undefined;
68147  var endPos = end === undefined ? length : toAbsoluteIndex(end, length);
68148  while (endPos > index) O[index++] = value;
68149  return O;
68150};
68151
68152},{"./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-absolute-index":"node_modules/core-js/modules/_to-absolute-index.js","./_to-length":"node_modules/core-js/modules/_to-length.js"}],"node_modules/core-js/modules/es6.array.fill.js":[function(require,module,exports) {
68153// 22.1.3.6 Array.prototype.fill(value, start = 0, end = this.length)
68154var $export = require('./_export');
68155
68156$export($export.P, 'Array', { fill: require('./_array-fill') });
68157
68158require('./_add-to-unscopables')('fill');
68159
68160},{"./_export":"node_modules/core-js/modules/_export.js","./_array-fill":"node_modules/core-js/modules/_array-fill.js","./_add-to-unscopables":"node_modules/core-js/modules/_add-to-unscopables.js"}],"node_modules/core-js/modules/es6.array.find.js":[function(require,module,exports) {
68161'use strict';
68162// 22.1.3.8 Array.prototype.find(predicate, thisArg = undefined)
68163var $export = require('./_export');
68164var $find = require('./_array-methods')(5);
68165var KEY = 'find';
68166var forced = true;
68167// Shouldn't skip holes
68168if (KEY in []) Array(1)[KEY](function () { forced = false; });
68169$export($export.P + $export.F * forced, 'Array', {
68170  find: function find(callbackfn /* , that = undefined */) {
68171    return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
68172  }
68173});
68174require('./_add-to-unscopables')(KEY);
68175
68176},{"./_export":"node_modules/core-js/modules/_export.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_add-to-unscopables":"node_modules/core-js/modules/_add-to-unscopables.js"}],"node_modules/core-js/modules/es6.array.find-index.js":[function(require,module,exports) {
68177'use strict';
68178// 22.1.3.9 Array.prototype.findIndex(predicate, thisArg = undefined)
68179var $export = require('./_export');
68180var $find = require('./_array-methods')(6);
68181var KEY = 'findIndex';
68182var forced = true;
68183// Shouldn't skip holes
68184if (KEY in []) Array(1)[KEY](function () { forced = false; });
68185$export($export.P + $export.F * forced, 'Array', {
68186  findIndex: function findIndex(callbackfn /* , that = undefined */) {
68187    return $find(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
68188  }
68189});
68190require('./_add-to-unscopables')(KEY);
68191
68192},{"./_export":"node_modules/core-js/modules/_export.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_add-to-unscopables":"node_modules/core-js/modules/_add-to-unscopables.js"}],"node_modules/core-js/modules/_set-species.js":[function(require,module,exports) {
68193
68194'use strict';
68195var global = require('./_global');
68196var dP = require('./_object-dp');
68197var DESCRIPTORS = require('./_descriptors');
68198var SPECIES = require('./_wks')('species');
68199
68200module.exports = function (KEY) {
68201  var C = global[KEY];
68202  if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, {
68203    configurable: true,
68204    get: function () { return this; }
68205  });
68206};
68207
68208},{"./_global":"node_modules/core-js/modules/_global.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/es6.array.species.js":[function(require,module,exports) {
68209require('./_set-species')('Array');
68210
68211},{"./_set-species":"node_modules/core-js/modules/_set-species.js"}],"node_modules/core-js/modules/_iter-step.js":[function(require,module,exports) {
68212module.exports = function (done, value) {
68213  return { value: value, done: !!done };
68214};
68215
68216},{}],"node_modules/core-js/modules/es6.array.iterator.js":[function(require,module,exports) {
68217'use strict';
68218var addToUnscopables = require('./_add-to-unscopables');
68219var step = require('./_iter-step');
68220var Iterators = require('./_iterators');
68221var toIObject = require('./_to-iobject');
68222
68223// 22.1.3.4 Array.prototype.entries()
68224// 22.1.3.13 Array.prototype.keys()
68225// 22.1.3.29 Array.prototype.values()
68226// 22.1.3.30 Array.prototype[@@iterator]()
68227module.exports = require('./_iter-define')(Array, 'Array', function (iterated, kind) {
68228  this._t = toIObject(iterated); // target
68229  this._i = 0;                   // next index
68230  this._k = kind;                // kind
68231// 22.1.5.2.1 %ArrayIteratorPrototype%.next()
68232}, function () {
68233  var O = this._t;
68234  var kind = this._k;
68235  var index = this._i++;
68236  if (!O || index >= O.length) {
68237    this._t = undefined;
68238    return step(1);
68239  }
68240  if (kind == 'keys') return step(0, index);
68241  if (kind == 'values') return step(0, O[index]);
68242  return step(0, [index, O[index]]);
68243}, 'values');
68244
68245// argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
68246Iterators.Arguments = Iterators.Array;
68247
68248addToUnscopables('keys');
68249addToUnscopables('values');
68250addToUnscopables('entries');
68251
68252},{"./_add-to-unscopables":"node_modules/core-js/modules/_add-to-unscopables.js","./_iter-step":"node_modules/core-js/modules/_iter-step.js","./_iterators":"node_modules/core-js/modules/_iterators.js","./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_iter-define":"node_modules/core-js/modules/_iter-define.js"}],"node_modules/core-js/modules/_flags.js":[function(require,module,exports) {
68253'use strict';
68254// 21.2.5.3 get RegExp.prototype.flags
68255var anObject = require('./_an-object');
68256module.exports = function () {
68257  var that = anObject(this);
68258  var result = '';
68259  if (that.global) result += 'g';
68260  if (that.ignoreCase) result += 'i';
68261  if (that.multiline) result += 'm';
68262  if (that.unicode) result += 'u';
68263  if (that.sticky) result += 'y';
68264  return result;
68265};
68266
68267},{"./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es6.regexp.constructor.js":[function(require,module,exports) {
68268
68269var global = require('./_global');
68270var inheritIfRequired = require('./_inherit-if-required');
68271var dP = require('./_object-dp').f;
68272var gOPN = require('./_object-gopn').f;
68273var isRegExp = require('./_is-regexp');
68274var $flags = require('./_flags');
68275var $RegExp = global.RegExp;
68276var Base = $RegExp;
68277var proto = $RegExp.prototype;
68278var re1 = /a/g;
68279var re2 = /a/g;
68280// "new" creates a new object, old webkit buggy here
68281var CORRECT_NEW = new $RegExp(re1) !== re1;
68282
68283if (require('./_descriptors') && (!CORRECT_NEW || require('./_fails')(function () {
68284  re2[require('./_wks')('match')] = false;
vendor: 4,193 bytes, lines 68285-68386
68285  // RegExp constructor can alter flags and IsRegExp works correct with @@match
68286  return $RegExp(re1) != re1 || $RegExp(re2) == re2 || $RegExp(re1, 'i') != '/a/i';
68287}))) {
68288  $RegExp = function RegExp(p, f) {
68289    var tiRE = this instanceof $RegExp;
68290    var piRE = isRegExp(p);
68291    var fiU = f === undefined;
68292    return !tiRE && piRE && p.constructor === $RegExp && fiU ? p
68293      : inheritIfRequired(CORRECT_NEW
68294        ? new Base(piRE && !fiU ? p.source : p, f)
68295        : Base((piRE = p instanceof $RegExp) ? p.source : p, piRE && fiU ? $flags.call(p) : f)
68296      , tiRE ? this : proto, $RegExp);
68297  };
68298  var proxy = function (key) {
68299    key in $RegExp || dP($RegExp, key, {
68300      configurable: true,
68301      get: function () { return Base[key]; },
68302      set: function (it) { Base[key] = it; }
68303    });
68304  };
68305  for (var keys = gOPN(Base), i = 0; keys.length > i;) proxy(keys[i++]);
68306  proto.constructor = $RegExp;
68307  $RegExp.prototype = proto;
68308  require('./_redefine')(global, 'RegExp', $RegExp);
68309}
68310
68311require('./_set-species')('RegExp');
68312
68313},{"./_global":"node_modules/core-js/modules/_global.js","./_inherit-if-required":"node_modules/core-js/modules/_inherit-if-required.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_object-gopn":"node_modules/core-js/modules/_object-gopn.js","./_is-regexp":"node_modules/core-js/modules/_is-regexp.js","./_flags":"node_modules/core-js/modules/_flags.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_fails":"node_modules/core-js/modules/_fails.js","./_wks":"node_modules/core-js/modules/_wks.js","./_redefine":"node_modules/core-js/modules/_redefine.js","./_set-species":"node_modules/core-js/modules/_set-species.js"}],"node_modules/core-js/modules/_regexp-exec.js":[function(require,module,exports) {
68314'use strict';
68315
68316var regexpFlags = require('./_flags');
68317
68318var nativeExec = RegExp.prototype.exec;
68319// This always refers to the native implementation, because the
68320// String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
68321// which loads this file before patching the method.
68322var nativeReplace = String.prototype.replace;
68323
68324var patchedExec = nativeExec;
68325
68326var LAST_INDEX = 'lastIndex';
68327
68328var UPDATES_LAST_INDEX_WRONG = (function () {
68329  var re1 = /a/,
68330      re2 = /b*/g;
68331  nativeExec.call(re1, 'a');
68332  nativeExec.call(re2, 'a');
68333  return re1[LAST_INDEX] !== 0 || re2[LAST_INDEX] !== 0;
68334})();
68335
68336// nonparticipating capturing group, copied from es5-shim's String#split patch.
68337var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
68338
68339var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
68340
68341if (PATCH) {
68342  patchedExec = function exec(str) {
68343    var re = this;
68344    var lastIndex, reCopy, match, i;
68345
68346    if (NPCG_INCLUDED) {
68347      reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
68348    }
68349    if (UPDATES_LAST_INDEX_WRONG) lastIndex = re[LAST_INDEX];
68350
68351    match = nativeExec.call(re, str);
68352
68353    if (UPDATES_LAST_INDEX_WRONG && match) {
68354      re[LAST_INDEX] = re.global ? match.index + match[0].length : lastIndex;
68355    }
68356    if (NPCG_INCLUDED && match && match.length > 1) {
68357      // Fix browsers whose `exec` methods don't consistently return `undefined`
68358      // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
68359      // eslint-disable-next-line no-loop-func
68360      nativeReplace.call(match[0], reCopy, function () {
68361        for (i = 1; i < arguments.length - 2; i++) {
68362          if (arguments[i] === undefined) match[i] = undefined;
68363        }
68364      });
68365    }
68366
68367    return match;
68368  };
68369}
68370
68371module.exports = patchedExec;
68372
68373},{"./_flags":"node_modules/core-js/modules/_flags.js"}],"node_modules/core-js/modules/es6.regexp.exec.js":[function(require,module,exports) {
68374'use strict';
68375var regexpExec = require('./_regexp-exec');
68376require('./_export')({
68377  target: 'RegExp',
68378  proto: true,
68379  forced: regexpExec !== /./.exec
68380}, {
68381  exec: regexpExec
68382});
68383
68384},{"./_regexp-exec":"node_modules/core-js/modules/_regexp-exec.js","./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.regexp.flags.js":[function(require,module,exports) {
68385// 21.2.5.3 get RegExp.prototype.flags()
68386if (require('./_descriptors') && /./g.flags != 'g') require('./_object-dp').f(RegExp.prototype, 'flags', {
68387  configurable: true,
68388  get: require('./_flags')
68389});
68390
68391},{"./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_flags":"node_modules/core-js/modules/_flags.js"}],"node_modules/core-js/modules/es6.regexp.to-string.js":[function(require,module,exports) {
68392
68393'use strict';
68394require('./es6.regexp.flags');
68395var anObject = require('./_an-object');
68396var $flags = require('./_flags');
68397var DESCRIPTORS = require('./_descriptors');
68398var TO_STRING = 'toString';
68399var $toString = /./[TO_STRING];
68400
68401var define = function (fn) {
68402  require('./_redefine')(RegExp.prototype, TO_STRING, fn, true);
68403};
68404
68405// 21.2.5.14 RegExp.prototype.toString()
68406if (require('./_fails')(function () { return $toString.call({ source: 'a', flags: 'b' }) != '/a/b'; })) {
68407  define(function toString() {
68408    var R = anObject(this);
68409    return '/'.concat(R.source, '/',
68410      'flags' in R ? R.flags : !DESCRIPTORS && R instanceof RegExp ? $flags.call(R) : undefined);
68411  });
68412// FF44- RegExp#toString has a wrong name
68413} else if ($toString.name != TO_STRING) {
68414  define(function toString() {
68415    return $toString.call(this);
68416  });
68417}
68418
68419},{"./es6.regexp.flags":"node_modules/core-js/modules/es6.regexp.flags.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_flags":"node_modules/core-js/modules/_flags.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_redefine":"node_modules/core-js/modules/_redefine.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/_advance-string-index.js":[function(require,module,exports) {
68420'use strict';
68421var at = require('./_string-at')(true);
68422
68423 // `AdvanceStringIndex` abstract operation
68424// https://tc39.github.io/ecma262/#sec-advancestringindex
68425module.exports = function (S, index, unicode) {
68426  return index + (unicode ? at(S, index).length : 1);
68427};
68428
68429},{"./_string-at":"node_modules/core-js/modules/_string-at.js"}],"node_modules/core-js/modules/_regexp-exec-abstract.js":[function(require,module,exports) {
68430'use strict';
68431
68432var classof = require('./_classof');
68433var builtinExec = RegExp.prototype.exec;
68434
68435 // `RegExpExec` abstract operation
68436// https://tc39.github.io/ecma262/#sec-regexpexec
68437module.exports = function (R, S) {
68438  var exec = R.exec;
68439  if (typeof exec === 'function') {
68440    var result = exec.call(R, S);
68441    if (typeof result !== 'object') {
68442      throw new TypeError('RegExp exec method returned something other than an Object or null');
68443    }
68444    return result;
68445  }
68446  if (classof(R) !== 'RegExp') {
68447    throw new TypeError('RegExp#exec called on incompatible receiver');
68448  }
68449  return builtinExec.call(R, S);
68450};
68451
68452},{"./_classof":"node_modules/core-js/modules/_classof.js"}],"node_modules/core-js/modules/_fix-re-wks.js":[function(require,module,exports) {
68453'use strict';
68454require('./es6.regexp.exec');
68455var redefine = require('./_redefine');
68456var hide = require('./_hide');
68457var fails = require('./_fails');
68458var defined = require('./_defined');
68459var wks = require('./_wks');
68460var regexpExec = require('./_regexp-exec');
68461
68462var SPECIES = wks('species');
68463
68464var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
68465  // #replace needs built-in support for named groups.
68466  // #match works fine because it just return the exec results, even if it has
68467  // a "grops" property.
68468  var re = /./;
68469  re.exec = function () {
68470    var result = [];
68471    result.groups = { a: '7' };
68472    return result;
68473  };
68474  return ''.replace(re, '$<a>') !== '7';
68475});
68476
68477var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = (function () {
68478  // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
68479  var re = /(?:)/;
68480  var originalExec = re.exec;
68481  re.exec = function () { return originalExec.apply(this, arguments); };
68482  var result = 'ab'.split(re);
68483  return result.length === 2 && result[0] === 'a' && result[1] === 'b';
68484})();
68485
68486module.exports = function (KEY, length, exec) {
68487  var SYMBOL = wks(KEY);
68488
68489  var DELEGATES_TO_SYMBOL = !fails(function () {
68490    // String methods call symbol-named RegEp methods
68491    var O = {};
68492    O[SYMBOL] = function () { return 7; };
68493    return ''[KEY](O) != 7;
68494  });
68495
68496  var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL ? !fails(function () {
68497    // Symbol-named RegExp methods call .exec
68498    var execCalled = false;
vendor: 15,041 bytes, lines 68499-68839
68499    var re = /a/;
68500    re.exec = function () { execCalled = true; return null; };
68501    if (KEY === 'split') {
68502      // RegExp[@@split] doesn't call the regex's exec method, but first creates
68503      // a new one. We need to return the patched regex when creating the new one.
68504      re.constructor = {};
68505      re.constructor[SPECIES] = function () { return re; };
68506    }
68507    re[SYMBOL]('');
68508    return !execCalled;
68509  }) : undefined;
68510
68511  if (
68512    !DELEGATES_TO_SYMBOL ||
68513    !DELEGATES_TO_EXEC ||
68514    (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
68515    (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
68516  ) {
68517    var nativeRegExpMethod = /./[SYMBOL];
68518    var fns = exec(
68519      defined,
68520      SYMBOL,
68521      ''[KEY],
68522      function maybeCallNative(nativeMethod, regexp, str, arg2, forceStringMethod) {
68523        if (regexp.exec === regexpExec) {
68524          if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
68525            // The native String method already delegates to @@method (this
68526            // polyfilled function), leasing to infinite recursion.
68527            // We avoid it by directly calling the native @@method method.
68528            return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
68529          }
68530          return { done: true, value: nativeMethod.call(str, regexp, arg2) };
68531        }
68532        return { done: false };
68533      }
68534    );
68535    var strfn = fns[0];
68536    var rxfn = fns[1];
68537
68538    redefine(String.prototype, KEY, strfn);
68539    hide(RegExp.prototype, SYMBOL, length == 2
68540      // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
68541      // 21.2.5.11 RegExp.prototype[@@split](string, limit)
68542      ? function (string, arg) { return rxfn.call(string, this, arg); }
68543      // 21.2.5.6 RegExp.prototype[@@match](string)
68544      // 21.2.5.9 RegExp.prototype[@@search](string)
68545      : function (string) { return rxfn.call(string, this); }
68546    );
68547  }
68548};
68549
68550},{"./es6.regexp.exec":"node_modules/core-js/modules/es6.regexp.exec.js","./_redefine":"node_modules/core-js/modules/_redefine.js","./_hide":"node_modules/core-js/modules/_hide.js","./_fails":"node_modules/core-js/modules/_fails.js","./_defined":"node_modules/core-js/modules/_defined.js","./_wks":"node_modules/core-js/modules/_wks.js","./_regexp-exec":"node_modules/core-js/modules/_regexp-exec.js"}],"node_modules/core-js/modules/es6.regexp.match.js":[function(require,module,exports) {
68551'use strict';
68552
68553var anObject = require('./_an-object');
68554var toLength = require('./_to-length');
68555var advanceStringIndex = require('./_advance-string-index');
68556var regExpExec = require('./_regexp-exec-abstract');
68557
68558// @@match logic
68559require('./_fix-re-wks')('match', 1, function (defined, MATCH, $match, maybeCallNative) {
68560  return [
68561    // `String.prototype.match` method
68562    // https://tc39.github.io/ecma262/#sec-string.prototype.match
68563    function match(regexp) {
68564      var O = defined(this);
68565      var fn = regexp == undefined ? undefined : regexp[MATCH];
68566      return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
68567    },
68568    // `RegExp.prototype[@@match]` method
68569    // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
68570    function (regexp) {
68571      var res = maybeCallNative($match, regexp, this);
68572      if (res.done) return res.value;
68573      var rx = anObject(regexp);
68574      var S = String(this);
68575      if (!rx.global) return regExpExec(rx, S);
68576      var fullUnicode = rx.unicode;
68577      rx.lastIndex = 0;
68578      var A = [];
68579      var n = 0;
68580      var result;
68581      while ((result = regExpExec(rx, S)) !== null) {
68582        var matchStr = String(result[0]);
68583        A[n] = matchStr;
68584        if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
68585        n++;
68586      }
68587      return n === 0 ? null : A;
68588    }
68589  ];
68590});
68591
68592},{"./_an-object":"node_modules/core-js/modules/_an-object.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_advance-string-index":"node_modules/core-js/modules/_advance-string-index.js","./_regexp-exec-abstract":"node_modules/core-js/modules/_regexp-exec-abstract.js","./_fix-re-wks":"node_modules/core-js/modules/_fix-re-wks.js"}],"node_modules/core-js/modules/es6.regexp.replace.js":[function(require,module,exports) {
68593var global = arguments[3];
68594'use strict';
68595
68596var anObject = require('./_an-object');
68597var toObject = require('./_to-object');
68598var toLength = require('./_to-length');
68599var toInteger = require('./_to-integer');
68600var advanceStringIndex = require('./_advance-string-index');
68601var regExpExec = require('./_regexp-exec-abstract');
68602var max = Math.max;
68603var min = Math.min;
68604var floor = Math.floor;
68605var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
68606var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
68607
68608var maybeToString = function (it) {
68609  return it === undefined ? it : String(it);
68610};
68611
68612// @@replace logic
68613require('./_fix-re-wks')('replace', 2, function (defined, REPLACE, $replace, maybeCallNative) {
68614  return [
68615    // `String.prototype.replace` method
68616    // https://tc39.github.io/ecma262/#sec-string.prototype.replace
68617    function replace(searchValue, replaceValue) {
68618      var O = defined(this);
68619      var fn = searchValue == undefined ? undefined : searchValue[REPLACE];
68620      return fn !== undefined
68621        ? fn.call(searchValue, O, replaceValue)
68622        : $replace.call(String(O), searchValue, replaceValue);
68623    },
68624    // `RegExp.prototype[@@replace]` method
68625    // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
68626    function (regexp, replaceValue) {
68627      var res = maybeCallNative($replace, regexp, this, replaceValue);
68628      if (res.done) return res.value;
68629
68630      var rx = anObject(regexp);
68631      var S = String(this);
68632      var functionalReplace = typeof replaceValue === 'function';
68633      if (!functionalReplace) replaceValue = String(replaceValue);
68634      var global = rx.global;
68635      if (global) {
68636        var fullUnicode = rx.unicode;
68637        rx.lastIndex = 0;
68638      }
68639      var results = [];
68640      while (true) {
68641        var result = regExpExec(rx, S);
68642        if (result === null) break;
68643        results.push(result);
68644        if (!global) break;
68645        var matchStr = String(result[0]);
68646        if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
68647      }
68648      var accumulatedResult = '';
68649      var nextSourcePosition = 0;
68650      for (var i = 0; i < results.length; i++) {
68651        result = results[i];
68652        var matched = String(result[0]);
68653        var position = max(min(toInteger(result.index), S.length), 0);
68654        var captures = [];
68655        // NOTE: This is equivalent to
68656        //   captures = result.slice(1).map(maybeToString)
68657        // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
68658        // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
68659        // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
68660        for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
68661        var namedCaptures = result.groups;
68662        if (functionalReplace) {
68663          var replacerArgs = [matched].concat(captures, position, S);
68664          if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
68665          var replacement = String(replaceValue.apply(undefined, replacerArgs));
68666        } else {
68667          replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
68668        }
68669        if (position >= nextSourcePosition) {
68670          accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
68671          nextSourcePosition = position + matched.length;
68672        }
68673      }
68674      return accumulatedResult + S.slice(nextSourcePosition);
68675    }
68676  ];
68677
68678    // https://tc39.github.io/ecma262/#sec-getsubstitution
68679  function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
68680    var tailPos = position + matched.length;
68681    var m = captures.length;
68682    var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
68683    if (namedCaptures !== undefined) {
68684      namedCaptures = toObject(namedCaptures);
68685      symbols = SUBSTITUTION_SYMBOLS;
68686    }
68687    return $replace.call(replacement, symbols, function (match, ch) {
68688      var capture;
68689      switch (ch.charAt(0)) {
68690        case '$': return '$';
68691        case '&': return matched;
68692        case '`': return str.slice(0, position);
68693        case "'": return str.slice(tailPos);
68694        case '<':
68695          capture = namedCaptures[ch.slice(1, -1)];
68696          break;
68697        default: // \d\d?
68698          var n = +ch;
68699          if (n === 0) return match;
68700          if (n > m) {
68701            var f = floor(n / 10);
68702            if (f === 0) return match;
68703            if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
68704            return match;
68705          }
68706          capture = captures[n - 1];
68707      }
68708      return capture === undefined ? '' : capture;
68709    });
68710  }
68711});
68712
68713},{"./_an-object":"node_modules/core-js/modules/_an-object.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_to-integer":"node_modules/core-js/modules/_to-integer.js","./_advance-string-index":"node_modules/core-js/modules/_advance-string-index.js","./_regexp-exec-abstract":"node_modules/core-js/modules/_regexp-exec-abstract.js","./_fix-re-wks":"node_modules/core-js/modules/_fix-re-wks.js"}],"node_modules/core-js/modules/es6.regexp.search.js":[function(require,module,exports) {
68714'use strict';
68715
68716var anObject = require('./_an-object');
68717var sameValue = require('./_same-value');
68718var regExpExec = require('./_regexp-exec-abstract');
68719
68720// @@search logic
68721require('./_fix-re-wks')('search', 1, function (defined, SEARCH, $search, maybeCallNative) {
68722  return [
68723    // `String.prototype.search` method
68724    // https://tc39.github.io/ecma262/#sec-string.prototype.search
68725    function search(regexp) {
68726      var O = defined(this);
68727      var fn = regexp == undefined ? undefined : regexp[SEARCH];
68728      return fn !== undefined ? fn.call(regexp, O) : new RegExp(regexp)[SEARCH](String(O));
68729    },
68730    // `RegExp.prototype[@@search]` method
68731    // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@search
68732    function (regexp) {
68733      var res = maybeCallNative($search, regexp, this);
68734      if (res.done) return res.value;
68735      var rx = anObject(regexp);
68736      var S = String(this);
68737      var previousLastIndex = rx.lastIndex;
68738      if (!sameValue(previousLastIndex, 0)) rx.lastIndex = 0;
68739      var result = regExpExec(rx, S);
68740      if (!sameValue(rx.lastIndex, previousLastIndex)) rx.lastIndex = previousLastIndex;
68741      return result === null ? -1 : result.index;
68742    }
68743  ];
68744});
68745
68746},{"./_an-object":"node_modules/core-js/modules/_an-object.js","./_same-value":"node_modules/core-js/modules/_same-value.js","./_regexp-exec-abstract":"node_modules/core-js/modules/_regexp-exec-abstract.js","./_fix-re-wks":"node_modules/core-js/modules/_fix-re-wks.js"}],"node_modules/core-js/modules/_species-constructor.js":[function(require,module,exports) {
68747// 7.3.20 SpeciesConstructor(O, defaultConstructor)
68748var anObject = require('./_an-object');
68749var aFunction = require('./_a-function');
68750var SPECIES = require('./_wks')('species');
68751module.exports = function (O, D) {
68752  var C = anObject(O).constructor;
68753  var S;
68754  return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
68755};
68756
68757},{"./_an-object":"node_modules/core-js/modules/_an-object.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/es6.regexp.split.js":[function(require,module,exports) {
68758'use strict';
68759
68760var isRegExp = require('./_is-regexp');
68761var anObject = require('./_an-object');
68762var speciesConstructor = require('./_species-constructor');
68763var advanceStringIndex = require('./_advance-string-index');
68764var toLength = require('./_to-length');
68765var callRegExpExec = require('./_regexp-exec-abstract');
68766var regexpExec = require('./_regexp-exec');
68767var fails = require('./_fails');
68768var $min = Math.min;
68769var $push = [].push;
68770var $SPLIT = 'split';
68771var LENGTH = 'length';
68772var LAST_INDEX = 'lastIndex';
68773var MAX_UINT32 = 0xffffffff;
68774
68775// babel-minify transpiles RegExp('x', 'y') -> /x/y and it causes SyntaxError
68776var SUPPORTS_Y = !fails(function () { RegExp(MAX_UINT32, 'y'); });
68777
68778// @@split logic
68779require('./_fix-re-wks')('split', 2, function (defined, SPLIT, $split, maybeCallNative) {
68780  var internalSplit;
68781  if (
68782    'abbc'[$SPLIT](/(b)*/)[1] == 'c' ||
68783    'test'[$SPLIT](/(?:)/, -1)[LENGTH] != 4 ||
68784    'ab'[$SPLIT](/(?:ab)*/)[LENGTH] != 2 ||
68785    '.'[$SPLIT](/(.?)(.?)/)[LENGTH] != 4 ||
68786    '.'[$SPLIT](/()()/)[LENGTH] > 1 ||
68787    ''[$SPLIT](/.?/)[LENGTH]
68788  ) {
68789    // based on es5-shim implementation, need to rework it
68790    internalSplit = function (separator, limit) {
68791      var string = String(this);
68792      if (separator === undefined && limit === 0) return [];
68793      // If `separator` is not a regex, use native split
68794      if (!isRegExp(separator)) return $split.call(string, separator, limit);
68795      var output = [];
68796      var flags = (separator.ignoreCase ? 'i' : '') +
68797                  (separator.multiline ? 'm' : '') +
68798                  (separator.unicode ? 'u' : '') +
68799                  (separator.sticky ? 'y' : '');
68800      var lastLastIndex = 0;
68801      var splitLimit = limit === undefined ? MAX_UINT32 : limit >>> 0;
68802      // Make `global` and avoid `lastIndex` issues by working with a copy
68803      var separatorCopy = new RegExp(separator.source, flags + 'g');
68804      var match, lastIndex, lastLength;
68805      while (match = regexpExec.call(separatorCopy, string)) {
68806        lastIndex = separatorCopy[LAST_INDEX];
68807        if (lastIndex > lastLastIndex) {
68808          output.push(string.slice(lastLastIndex, match.index));
68809          if (match[LENGTH] > 1 && match.index < string[LENGTH]) $push.apply(output, match.slice(1));
68810          lastLength = match[0][LENGTH];
68811          lastLastIndex = lastIndex;
68812          if (output[LENGTH] >= splitLimit) break;
68813        }
68814        if (separatorCopy[LAST_INDEX] === match.index) separatorCopy[LAST_INDEX]++; // Avoid an infinite loop
68815      }
68816      if (lastLastIndex === string[LENGTH]) {
68817        if (lastLength || !separatorCopy.test('')) output.push('');
68818      } else output.push(string.slice(lastLastIndex));
68819      return output[LENGTH] > splitLimit ? output.slice(0, splitLimit) : output;
68820    };
68821  // Chakra, V8
68822  } else if ('0'[$SPLIT](undefined, 0)[LENGTH]) {
68823    internalSplit = function (separator, limit) {
68824      return separator === undefined && limit === 0 ? [] : $split.call(this, separator, limit);
68825    };
68826  } else {
68827    internalSplit = $split;
68828  }
68829
68830  return [
68831    // `String.prototype.split` method
68832    // https://tc39.github.io/ecma262/#sec-string.prototype.split
68833    function split(separator, limit) {
68834      var O = defined(this);
68835      var splitter = separator == undefined ? undefined : separator[SPLIT];
68836      return splitter !== undefined
68837        ? splitter.call(separator, O, limit)
68838        : internalSplit.call(String(O), separator, limit);
68839    },
vendor: 4,733 bytes, lines 68840-68937
68840    // `RegExp.prototype[@@split]` method
68841    // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@split
68842    //
68843    // NOTE: This cannot be properly polyfilled in engines that don't support
68844    // the 'y' flag.
68845    function (regexp, limit) {
68846      var res = maybeCallNative(internalSplit, regexp, this, limit, internalSplit !== $split);
68847      if (res.done) return res.value;
68848
68849      var rx = anObject(regexp);
68850      var S = String(this);
68851      var C = speciesConstructor(rx, RegExp);
68852
68853      var unicodeMatching = rx.unicode;
68854      var flags = (rx.ignoreCase ? 'i' : '') +
68855                  (rx.multiline ? 'm' : '') +
68856                  (rx.unicode ? 'u' : '') +
68857                  (SUPPORTS_Y ? 'y' : 'g');
68858
68859      // ^(? + rx + ) is needed, in combination with some S slicing, to
68860      // simulate the 'y' flag.
68861      var splitter = new C(SUPPORTS_Y ? rx : '^(?:' + rx.source + ')', flags);
68862      var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
68863      if (lim === 0) return [];
68864      if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];
68865      var p = 0;
68866      var q = 0;
68867      var A = [];
68868      while (q < S.length) {
68869        splitter.lastIndex = SUPPORTS_Y ? q : 0;
68870        var z = callRegExpExec(splitter, SUPPORTS_Y ? S : S.slice(q));
68871        var e;
68872        if (
68873          z === null ||
68874          (e = $min(toLength(splitter.lastIndex + (SUPPORTS_Y ? 0 : q)), S.length)) === p
68875        ) {
68876          q = advanceStringIndex(S, q, unicodeMatching);
68877        } else {
68878          A.push(S.slice(p, q));
68879          if (A.length === lim) return A;
68880          for (var i = 1; i <= z.length - 1; i++) {
68881            A.push(z[i]);
68882            if (A.length === lim) return A;
68883          }
68884          q = p = e;
68885        }
68886      }
68887      A.push(S.slice(p));
68888      return A;
68889    }
68890  ];
68891});
68892
68893},{"./_is-regexp":"node_modules/core-js/modules/_is-regexp.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_species-constructor":"node_modules/core-js/modules/_species-constructor.js","./_advance-string-index":"node_modules/core-js/modules/_advance-string-index.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_regexp-exec-abstract":"node_modules/core-js/modules/_regexp-exec-abstract.js","./_regexp-exec":"node_modules/core-js/modules/_regexp-exec.js","./_fails":"node_modules/core-js/modules/_fails.js","./_fix-re-wks":"node_modules/core-js/modules/_fix-re-wks.js"}],"node_modules/core-js/modules/_an-instance.js":[function(require,module,exports) {
68894module.exports = function (it, Constructor, name, forbiddenField) {
68895  if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {
68896    throw TypeError(name + ': incorrect invocation!');
68897  } return it;
68898};
68899
68900},{}],"node_modules/core-js/modules/_for-of.js":[function(require,module,exports) {
68901var ctx = require('./_ctx');
68902var call = require('./_iter-call');
68903var isArrayIter = require('./_is-array-iter');
68904var anObject = require('./_an-object');
68905var toLength = require('./_to-length');
68906var getIterFn = require('./core.get-iterator-method');
68907var BREAK = {};
68908var RETURN = {};
68909var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {
68910  var iterFn = ITERATOR ? function () { return iterable; } : getIterFn(iterable);
68911  var f = ctx(fn, that, entries ? 2 : 1);
68912  var index = 0;
68913  var length, step, iterator, result;
68914  if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');
68915  // fast case for arrays with default iterator
68916  if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) {
68917    result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
68918    if (result === BREAK || result === RETURN) return result;
68919  } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {
68920    result = call(iterator, f, step.value, entries);
68921    if (result === BREAK || result === RETURN) return result;
68922  }
68923};
68924exports.BREAK = BREAK;
68925exports.RETURN = RETURN;
68926
68927},{"./_ctx":"node_modules/core-js/modules/_ctx.js","./_iter-call":"node_modules/core-js/modules/_iter-call.js","./_is-array-iter":"node_modules/core-js/modules/_is-array-iter.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./core.get-iterator-method":"node_modules/core-js/modules/core.get-iterator-method.js"}],"node_modules/core-js/modules/_task.js":[function(require,module,exports) {
68928
68929
68930var ctx = require('./_ctx');
68931var invoke = require('./_invoke');
68932var html = require('./_html');
68933var cel = require('./_dom-create');
68934var global = require('./_global');
68935var process = global.process;
68936var setTask = global.setImmediate;
68937var clearTask = global.clearImmediate;
vendor: 41,239 bytes, lines 68938-70009
68938var MessageChannel = global.MessageChannel;
68939var Dispatch = global.Dispatch;
68940var counter = 0;
68941var queue = {};
68942var ONREADYSTATECHANGE = 'onreadystatechange';
68943var defer, channel, port;
68944var run = function () {
68945  var id = +this;
68946  // eslint-disable-next-line no-prototype-builtins
68947  if (queue.hasOwnProperty(id)) {
68948    var fn = queue[id];
68949    delete queue[id];
68950    fn();
68951  }
68952};
68953var listener = function (event) {
68954  run.call(event.data);
68955};
68956// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
68957if (!setTask || !clearTask) {
68958  setTask = function setImmediate(fn) {
68959    var args = [];
68960    var i = 1;
68961    while (arguments.length > i) args.push(arguments[i++]);
68962    queue[++counter] = function () {
68963      // eslint-disable-next-line no-new-func
68964      invoke(typeof fn == 'function' ? fn : Function(fn), args);
68965    };
68966    defer(counter);
68967    return counter;
68968  };
68969  clearTask = function clearImmediate(id) {
68970    delete queue[id];
68971  };
68972  // Node.js 0.8-
68973  if (require('./_cof')(process) == 'process') {
68974    defer = function (id) {
68975      process.nextTick(ctx(run, id, 1));
68976    };
68977  // Sphere (JS game engine) Dispatch API
68978  } else if (Dispatch && Dispatch.now) {
68979    defer = function (id) {
68980      Dispatch.now(ctx(run, id, 1));
68981    };
68982  // Browsers with MessageChannel, includes WebWorkers
68983  } else if (MessageChannel) {
68984    channel = new MessageChannel();
68985    port = channel.port2;
68986    channel.port1.onmessage = listener;
68987    defer = ctx(port.postMessage, port, 1);
68988  // Browsers with postMessage, skip WebWorkers
68989  // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
68990  } else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) {
68991    defer = function (id) {
68992      global.postMessage(id + '', '*');
68993    };
68994    global.addEventListener('message', listener, false);
68995  // IE8-
68996  } else if (ONREADYSTATECHANGE in cel('script')) {
68997    defer = function (id) {
68998      html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () {
68999        html.removeChild(this);
69000        run.call(id);
69001      };
69002    };
69003  // Rest old browsers
69004  } else {
69005    defer = function (id) {
69006      setTimeout(ctx(run, id, 1), 0);
69007    };
69008  }
69009}
69010module.exports = {
69011  set: setTask,
69012  clear: clearTask
69013};
69014
69015},{"./_ctx":"node_modules/core-js/modules/_ctx.js","./_invoke":"node_modules/core-js/modules/_invoke.js","./_html":"node_modules/core-js/modules/_html.js","./_dom-create":"node_modules/core-js/modules/_dom-create.js","./_global":"node_modules/core-js/modules/_global.js","./_cof":"node_modules/core-js/modules/_cof.js"}],"node_modules/core-js/modules/_microtask.js":[function(require,module,exports) {
69016
69017
69018var global = require('./_global');
69019var macrotask = require('./_task').set;
69020var Observer = global.MutationObserver || global.WebKitMutationObserver;
69021var process = global.process;
69022var Promise = global.Promise;
69023var isNode = require('./_cof')(process) == 'process';
69024
69025module.exports = function () {
69026  var head, last, notify;
69027
69028  var flush = function () {
69029    var parent, fn;
69030    if (isNode && (parent = process.domain)) parent.exit();
69031    while (head) {
69032      fn = head.fn;
69033      head = head.next;
69034      try {
69035        fn();
69036      } catch (e) {
69037        if (head) notify();
69038        else last = undefined;
69039        throw e;
69040      }
69041    } last = undefined;
69042    if (parent) parent.enter();
69043  };
69044
69045  // Node.js
69046  if (isNode) {
69047    notify = function () {
69048      process.nextTick(flush);
69049    };
69050  // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339
69051  } else if (Observer && !(global.navigator && global.navigator.standalone)) {
69052    var toggle = true;
69053    var node = document.createTextNode('');
69054    new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new
69055    notify = function () {
69056      node.data = toggle = !toggle;
69057    };
69058  // environments with maybe non-completely correct, but existent Promise
69059  } else if (Promise && Promise.resolve) {
69060    // Promise.resolve without an argument throws an error in LG WebOS 2
69061    var promise = Promise.resolve(undefined);
69062    notify = function () {
69063      promise.then(flush);
69064    };
69065  // for other environments - macrotask based on:
69066  // - setImmediate
69067  // - MessageChannel
69068  // - window.postMessag
69069  // - onreadystatechange
69070  // - setTimeout
69071  } else {
69072    notify = function () {
69073      // strange IE + webpack dev server bug - use .call(global)
69074      macrotask.call(global, flush);
69075    };
69076  }
69077
69078  return function (fn) {
69079    var task = { fn: fn, next: undefined };
69080    if (last) last.next = task;
69081    if (!head) {
69082      head = task;
69083      notify();
69084    } last = task;
69085  };
69086};
69087
69088},{"./_global":"node_modules/core-js/modules/_global.js","./_task":"node_modules/core-js/modules/_task.js","./_cof":"node_modules/core-js/modules/_cof.js"}],"node_modules/core-js/modules/_new-promise-capability.js":[function(require,module,exports) {
69089'use strict';
69090// 25.4.1.5 NewPromiseCapability(C)
69091var aFunction = require('./_a-function');
69092
69093function PromiseCapability(C) {
69094  var resolve, reject;
69095  this.promise = new C(function ($$resolve, $$reject) {
69096    if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');
69097    resolve = $$resolve;
69098    reject = $$reject;
69099  });
69100  this.resolve = aFunction(resolve);
69101  this.reject = aFunction(reject);
69102}
69103
69104module.exports.f = function (C) {
69105  return new PromiseCapability(C);
69106};
69107
69108},{"./_a-function":"node_modules/core-js/modules/_a-function.js"}],"node_modules/core-js/modules/_perform.js":[function(require,module,exports) {
69109module.exports = function (exec) {
69110  try {
69111    return { e: false, v: exec() };
69112  } catch (e) {
69113    return { e: true, v: e };
69114  }
69115};
69116
69117},{}],"node_modules/core-js/modules/_user-agent.js":[function(require,module,exports) {
69118
69119var global = require('./_global');
69120var navigator = global.navigator;
69121
69122module.exports = navigator && navigator.userAgent || '';
69123
69124},{"./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/_promise-resolve.js":[function(require,module,exports) {
69125var anObject = require('./_an-object');
69126var isObject = require('./_is-object');
69127var newPromiseCapability = require('./_new-promise-capability');
69128
69129module.exports = function (C, x) {
69130  anObject(C);
69131  if (isObject(x) && x.constructor === C) return x;
69132  var promiseCapability = newPromiseCapability.f(C);
69133  var resolve = promiseCapability.resolve;
69134  resolve(x);
69135  return promiseCapability.promise;
69136};
69137
69138},{"./_an-object":"node_modules/core-js/modules/_an-object.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_new-promise-capability":"node_modules/core-js/modules/_new-promise-capability.js"}],"node_modules/core-js/modules/_redefine-all.js":[function(require,module,exports) {
69139var redefine = require('./_redefine');
69140module.exports = function (target, src, safe) {
69141  for (var key in src) redefine(target, key, src[key], safe);
69142  return target;
69143};
69144
69145},{"./_redefine":"node_modules/core-js/modules/_redefine.js"}],"node_modules/core-js/modules/es6.promise.js":[function(require,module,exports) {
69146
69147
69148'use strict';
69149var LIBRARY = require('./_library');
69150var global = require('./_global');
69151var ctx = require('./_ctx');
69152var classof = require('./_classof');
69153var $export = require('./_export');
69154var isObject = require('./_is-object');
69155var aFunction = require('./_a-function');
69156var anInstance = require('./_an-instance');
69157var forOf = require('./_for-of');
69158var speciesConstructor = require('./_species-constructor');
69159var task = require('./_task').set;
69160var microtask = require('./_microtask')();
69161var newPromiseCapabilityModule = require('./_new-promise-capability');
69162var perform = require('./_perform');
69163var userAgent = require('./_user-agent');
69164var promiseResolve = require('./_promise-resolve');
69165var PROMISE = 'Promise';
69166var TypeError = global.TypeError;
69167var process = global.process;
69168var versions = process && process.versions;
69169var v8 = versions && versions.v8 || '';
69170var $Promise = global[PROMISE];
69171var isNode = classof(process) == 'process';
69172var empty = function () { /* empty */ };
69173var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;
69174var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f;
69175
69176var USE_NATIVE = !!function () {
69177  try {
69178    // correct subclassing with @@species support
69179    var promise = $Promise.resolve(1);
69180    var FakePromise = (promise.constructor = {})[require('./_wks')('species')] = function (exec) {
69181      exec(empty, empty);
69182    };
69183    // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
69184    return (isNode || typeof PromiseRejectionEvent == 'function')
69185      && promise.then(empty) instanceof FakePromise
69186      // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables
69187      // https://bugs.chromium.org/p/chromium/issues/detail?id=830565
69188      // we can't detect it synchronously, so just check versions
69189      && v8.indexOf('6.6') !== 0
69190      && userAgent.indexOf('Chrome/66') === -1;
69191  } catch (e) { /* empty */ }
69192}();
69193
69194// helpers
69195var isThenable = function (it) {
69196  var then;
69197  return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
69198};
69199var notify = function (promise, isReject) {
69200  if (promise._n) return;
69201  promise._n = true;
69202  var chain = promise._c;
69203  microtask(function () {
69204    var value = promise._v;
69205    var ok = promise._s == 1;
69206    var i = 0;
69207    var run = function (reaction) {
69208      var handler = ok ? reaction.ok : reaction.fail;
69209      var resolve = reaction.resolve;
69210      var reject = reaction.reject;
69211      var domain = reaction.domain;
69212      var result, then, exited;
69213      try {
69214        if (handler) {
69215          if (!ok) {
69216            if (promise._h == 2) onHandleUnhandled(promise);
69217            promise._h = 1;
69218          }
69219          if (handler === true) result = value;
69220          else {
69221            if (domain) domain.enter();
69222            result = handler(value); // may throw
69223            if (domain) {
69224              domain.exit();
69225              exited = true;
69226            }
69227          }
69228          if (result === reaction.promise) {
69229            reject(TypeError('Promise-chain cycle'));
69230          } else if (then = isThenable(result)) {
69231            then.call(result, resolve, reject);
69232          } else resolve(result);
69233        } else reject(value);
69234      } catch (e) {
69235        if (domain && !exited) domain.exit();
69236        reject(e);
69237      }
69238    };
69239    while (chain.length > i) run(chain[i++]); // variable length - can't use forEach
69240    promise._c = [];
69241    promise._n = false;
69242    if (isReject && !promise._h) onUnhandled(promise);
69243  });
69244};
69245var onUnhandled = function (promise) {
69246  task.call(global, function () {
69247    var value = promise._v;
69248    var unhandled = isUnhandled(promise);
69249    var result, handler, console;
69250    if (unhandled) {
69251      result = perform(function () {
69252        if (isNode) {
69253          process.emit('unhandledRejection', value, promise);
69254        } else if (handler = global.onunhandledrejection) {
69255          handler({ promise: promise, reason: value });
69256        } else if ((console = global.console) && console.error) {
69257          console.error('Unhandled promise rejection', value);
69258        }
69259      });
69260      // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
69261      promise._h = isNode || isUnhandled(promise) ? 2 : 1;
69262    } promise._a = undefined;
69263    if (unhandled && result.e) throw result.v;
69264  });
69265};
69266var isUnhandled = function (promise) {
69267  return promise._h !== 1 && (promise._a || promise._c).length === 0;
69268};
69269var onHandleUnhandled = function (promise) {
69270  task.call(global, function () {
69271    var handler;
69272    if (isNode) {
69273      process.emit('rejectionHandled', promise);
69274    } else if (handler = global.onrejectionhandled) {
69275      handler({ promise: promise, reason: promise._v });
69276    }
69277  });
69278};
69279var $reject = function (value) {
69280  var promise = this;
69281  if (promise._d) return;
69282  promise._d = true;
69283  promise = promise._w || promise; // unwrap
69284  promise._v = value;
69285  promise._s = 2;
69286  if (!promise._a) promise._a = promise._c.slice();
69287  notify(promise, true);
69288};
69289var $resolve = function (value) {
69290  var promise = this;
69291  var then;
69292  if (promise._d) return;
69293  promise._d = true;
69294  promise = promise._w || promise; // unwrap
69295  try {
69296    if (promise === value) throw TypeError("Promise can't be resolved itself");
69297    if (then = isThenable(value)) {
69298      microtask(function () {
69299        var wrapper = { _w: promise, _d: false }; // wrap
69300        try {
69301          then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
69302        } catch (e) {
69303          $reject.call(wrapper, e);
69304        }
69305      });
69306    } else {
69307      promise._v = value;
69308      promise._s = 1;
69309      notify(promise, false);
69310    }
69311  } catch (e) {
69312    $reject.call({ _w: promise, _d: false }, e); // wrap
69313  }
69314};
69315
69316// constructor polyfill
69317if (!USE_NATIVE) {
69318  // 25.4.3.1 Promise(executor)
69319  $Promise = function Promise(executor) {
69320    anInstance(this, $Promise, PROMISE, '_h');
69321    aFunction(executor);
69322    Internal.call(this);
69323    try {
69324      executor(ctx($resolve, this, 1), ctx($reject, this, 1));
69325    } catch (err) {
69326      $reject.call(this, err);
69327    }
69328  };
69329  // eslint-disable-next-line no-unused-vars
69330  Internal = function Promise(executor) {
69331    this._c = [];             // <- awaiting reactions
69332    this._a = undefined;      // <- checked in isUnhandled reactions
69333    this._s = 0;              // <- state
69334    this._d = false;          // <- done
69335    this._v = undefined;      // <- value
69336    this._h = 0;              // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
69337    this._n = false;          // <- notify
69338  };
69339  Internal.prototype = require('./_redefine-all')($Promise.prototype, {
69340    // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
69341    then: function then(onFulfilled, onRejected) {
69342      var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
69343      reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
69344      reaction.fail = typeof onRejected == 'function' && onRejected;
69345      reaction.domain = isNode ? process.domain : undefined;
69346      this._c.push(reaction);
69347      if (this._a) this._a.push(reaction);
69348      if (this._s) notify(this, false);
69349      return reaction.promise;
69350    },
69351    // 25.4.5.1 Promise.prototype.catch(onRejected)
69352    'catch': function (onRejected) {
69353      return this.then(undefined, onRejected);
69354    }
69355  });
69356  OwnPromiseCapability = function () {
69357    var promise = new Internal();
69358    this.promise = promise;
69359    this.resolve = ctx($resolve, promise, 1);
69360    this.reject = ctx($reject, promise, 1);
69361  };
69362  newPromiseCapabilityModule.f = newPromiseCapability = function (C) {
69363    return C === $Promise || C === Wrapper
69364      ? new OwnPromiseCapability(C)
69365      : newGenericPromiseCapability(C);
69366  };
69367}
69368
69369$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise });
69370require('./_set-to-string-tag')($Promise, PROMISE);
69371require('./_set-species')(PROMISE);
69372Wrapper = require('./_core')[PROMISE];
69373
69374// statics
69375$export($export.S + $export.F * !USE_NATIVE, PROMISE, {
69376  // 25.4.4.5 Promise.reject(r)
69377  reject: function reject(r) {
69378    var capability = newPromiseCapability(this);
69379    var $$reject = capability.reject;
69380    $$reject(r);
69381    return capability.promise;
69382  }
69383});
69384$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
69385  // 25.4.4.6 Promise.resolve(x)
69386  resolve: function resolve(x) {
69387    return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x);
69388  }
69389});
69390$export($export.S + $export.F * !(USE_NATIVE && require('./_iter-detect')(function (iter) {
69391  $Promise.all(iter)['catch'](empty);
69392})), PROMISE, {
69393  // 25.4.4.1 Promise.all(iterable)
69394  all: function all(iterable) {
69395    var C = this;
69396    var capability = newPromiseCapability(C);
69397    var resolve = capability.resolve;
69398    var reject = capability.reject;
69399    var result = perform(function () {
69400      var values = [];
69401      var index = 0;
69402      var remaining = 1;
69403      forOf(iterable, false, function (promise) {
69404        var $index = index++;
69405        var alreadyCalled = false;
69406        values.push(undefined);
69407        remaining++;
69408        C.resolve(promise).then(function (value) {
69409          if (alreadyCalled) return;
69410          alreadyCalled = true;
69411          values[$index] = value;
69412          --remaining || resolve(values);
69413        }, reject);
69414      });
69415      --remaining || resolve(values);
69416    });
69417    if (result.e) reject(result.v);
69418    return capability.promise;
69419  },
69420  // 25.4.4.4 Promise.race(iterable)
69421  race: function race(iterable) {
69422    var C = this;
69423    var capability = newPromiseCapability(C);
69424    var reject = capability.reject;
69425    var result = perform(function () {
69426      forOf(iterable, false, function (promise) {
69427        C.resolve(promise).then(capability.resolve, reject);
69428      });
69429    });
69430    if (result.e) reject(result.v);
69431    return capability.promise;
69432  }
69433});
69434
69435},{"./_library":"node_modules/core-js/modules/_library.js","./_global":"node_modules/core-js/modules/_global.js","./_ctx":"node_modules/core-js/modules/_ctx.js","./_classof":"node_modules/core-js/modules/_classof.js","./_export":"node_modules/core-js/modules/_export.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_an-instance":"node_modules/core-js/modules/_an-instance.js","./_for-of":"node_modules/core-js/modules/_for-of.js","./_species-constructor":"node_modules/core-js/modules/_species-constructor.js","./_task":"node_modules/core-js/modules/_task.js","./_microtask":"node_modules/core-js/modules/_microtask.js","./_new-promise-capability":"node_modules/core-js/modules/_new-promise-capability.js","./_perform":"node_modules/core-js/modules/_perform.js","./_user-agent":"node_modules/core-js/modules/_user-agent.js","./_promise-resolve":"node_modules/core-js/modules/_promise-resolve.js","./_wks":"node_modules/core-js/modules/_wks.js","./_redefine-all":"node_modules/core-js/modules/_redefine-all.js","./_set-to-string-tag":"node_modules/core-js/modules/_set-to-string-tag.js","./_set-species":"node_modules/core-js/modules/_set-species.js","./_core":"node_modules/core-js/modules/_core.js","./_iter-detect":"node_modules/core-js/modules/_iter-detect.js"}],"node_modules/core-js/modules/_validate-collection.js":[function(require,module,exports) {
69436var isObject = require('./_is-object');
69437module.exports = function (it, TYPE) {
69438  if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!');
69439  return it;
69440};
69441
69442},{"./_is-object":"node_modules/core-js/modules/_is-object.js"}],"node_modules/core-js/modules/_collection-strong.js":[function(require,module,exports) {
69443'use strict';
69444var dP = require('./_object-dp').f;
69445var create = require('./_object-create');
69446var redefineAll = require('./_redefine-all');
69447var ctx = require('./_ctx');
69448var anInstance = require('./_an-instance');
69449var forOf = require('./_for-of');
69450var $iterDefine = require('./_iter-define');
69451var step = require('./_iter-step');
69452var setSpecies = require('./_set-species');
69453var DESCRIPTORS = require('./_descriptors');
69454var fastKey = require('./_meta').fastKey;
69455var validate = require('./_validate-collection');
69456var SIZE = DESCRIPTORS ? '_s' : 'size';
69457
69458var getEntry = function (that, key) {
69459  // fast case
69460  var index = fastKey(key);
69461  var entry;
69462  if (index !== 'F') return that._i[index];
69463  // frozen object case
69464  for (entry = that._f; entry; entry = entry.n) {
69465    if (entry.k == key) return entry;
69466  }
69467};
69468
69469module.exports = {
69470  getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
69471    var C = wrapper(function (that, iterable) {
69472      anInstance(that, C, NAME, '_i');
69473      that._t = NAME;         // collection type
69474      that._i = create(null); // index
69475      that._f = undefined;    // first entry
69476      that._l = undefined;    // last entry
69477      that[SIZE] = 0;         // size
69478      if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
69479    });
69480    redefineAll(C.prototype, {
69481      // 23.1.3.1 Map.prototype.clear()
69482      // 23.2.3.2 Set.prototype.clear()
69483      clear: function clear() {
69484        for (var that = validate(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) {
69485          entry.r = true;
69486          if (entry.p) entry.p = entry.p.n = undefined;
69487          delete data[entry.i];
69488        }
69489        that._f = that._l = undefined;
69490        that[SIZE] = 0;
69491      },
69492      // 23.1.3.3 Map.prototype.delete(key)
69493      // 23.2.3.4 Set.prototype.delete(value)
69494      'delete': function (key) {
69495        var that = validate(this, NAME);
69496        var entry = getEntry(that, key);
69497        if (entry) {
69498          var next = entry.n;
69499          var prev = entry.p;
69500          delete that._i[entry.i];
69501          entry.r = true;
69502          if (prev) prev.n = next;
69503          if (next) next.p = prev;
69504          if (that._f == entry) that._f = next;
69505          if (that._l == entry) that._l = prev;
69506          that[SIZE]--;
69507        } return !!entry;
69508      },
69509      // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined)
69510      // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined)
69511      forEach: function forEach(callbackfn /* , that = undefined */) {
69512        validate(this, NAME);
69513        var f = ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3);
69514        var entry;
69515        while (entry = entry ? entry.n : this._f) {
69516          f(entry.v, entry.k, this);
69517          // revert to the last existing entry
69518          while (entry && entry.r) entry = entry.p;
69519        }
69520      },
69521      // 23.1.3.7 Map.prototype.has(key)
69522      // 23.2.3.7 Set.prototype.has(value)
69523      has: function has(key) {
69524        return !!getEntry(validate(this, NAME), key);
69525      }
69526    });
69527    if (DESCRIPTORS) dP(C.prototype, 'size', {
69528      get: function () {
69529        return validate(this, NAME)[SIZE];
69530      }
69531    });
69532    return C;
69533  },
69534  def: function (that, key, value) {
69535    var entry = getEntry(that, key);
69536    var prev, index;
69537    // change existing entry
69538    if (entry) {
69539      entry.v = value;
69540    // create new entry
69541    } else {
69542      that._l = entry = {
69543        i: index = fastKey(key, true), // <- index
69544        k: key,                        // <- key
69545        v: value,                      // <- value
69546        p: prev = that._l,             // <- previous entry
69547        n: undefined,                  // <- next entry
69548        r: false                       // <- removed
69549      };
69550      if (!that._f) that._f = entry;
69551      if (prev) prev.n = entry;
69552      that[SIZE]++;
69553      // add to index
69554      if (index !== 'F') that._i[index] = entry;
69555    } return that;
69556  },
69557  getEntry: getEntry,
69558  setStrong: function (C, NAME, IS_MAP) {
69559    // add .keys, .values, .entries, [@@iterator]
69560    // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11
69561    $iterDefine(C, NAME, function (iterated, kind) {
69562      this._t = validate(iterated, NAME); // target
69563      this._k = kind;                     // kind
69564      this._l = undefined;                // previous
69565    }, function () {
69566      var that = this;
69567      var kind = that._k;
69568      var entry = that._l;
69569      // revert to the last existing entry
69570      while (entry && entry.r) entry = entry.p;
69571      // get next entry
69572      if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) {
69573        // or finish the iteration
69574        that._t = undefined;
69575        return step(1);
69576      }
69577      // return step by kind
69578      if (kind == 'keys') return step(0, entry.k);
69579      if (kind == 'values') return step(0, entry.v);
69580      return step(0, [entry.k, entry.v]);
69581    }, IS_MAP ? 'entries' : 'values', !IS_MAP, true);
69582
69583    // add [@@species], 23.1.2.2, 23.2.2.2
69584    setSpecies(NAME);
69585  }
69586};
69587
69588},{"./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_object-create":"node_modules/core-js/modules/_object-create.js","./_redefine-all":"node_modules/core-js/modules/_redefine-all.js","./_ctx":"node_modules/core-js/modules/_ctx.js","./_an-instance":"node_modules/core-js/modules/_an-instance.js","./_for-of":"node_modules/core-js/modules/_for-of.js","./_iter-define":"node_modules/core-js/modules/_iter-define.js","./_iter-step":"node_modules/core-js/modules/_iter-step.js","./_set-species":"node_modules/core-js/modules/_set-species.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_meta":"node_modules/core-js/modules/_meta.js","./_validate-collection":"node_modules/core-js/modules/_validate-collection.js"}],"node_modules/core-js/modules/_collection.js":[function(require,module,exports) {
69589
69590'use strict';
69591var global = require('./_global');
69592var $export = require('./_export');
69593var redefine = require('./_redefine');
69594var redefineAll = require('./_redefine-all');
69595var meta = require('./_meta');
69596var forOf = require('./_for-of');
69597var anInstance = require('./_an-instance');
69598var isObject = require('./_is-object');
69599var fails = require('./_fails');
69600var $iterDetect = require('./_iter-detect');
69601var setToStringTag = require('./_set-to-string-tag');
69602var inheritIfRequired = require('./_inherit-if-required');
69603
69604module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) {
69605  var Base = global[NAME];
69606  var C = Base;
69607  var ADDER = IS_MAP ? 'set' : 'add';
69608  var proto = C && C.prototype;
69609  var O = {};
69610  var fixMethod = function (KEY) {
69611    var fn = proto[KEY];
69612    redefine(proto, KEY,
69613      KEY == 'delete' ? function (a) {
69614        return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
69615      } : KEY == 'has' ? function has(a) {
69616        return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a);
69617      } : KEY == 'get' ? function get(a) {
69618        return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a);
69619      } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a); return this; }
69620        : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b); return this; }
69621    );
69622  };
69623  if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () {
69624    new C().entries().next();
69625  }))) {
69626    // create collection constructor
69627    C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER);
69628    redefineAll(C.prototype, methods);
69629    meta.NEED = true;
69630  } else {
69631    var instance = new C();
69632    // early implementations not supports chaining
69633    var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance;
69634    // V8 ~  Chromium 40- weak-collections throws on primitives, but should return false
69635    var THROWS_ON_PRIMITIVES = fails(function () { instance.has(1); });
69636    // most early implementations doesn't supports iterables, most modern - not close it correctly
69637    var ACCEPT_ITERABLES = $iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new
69638    // for early implementations -0 and +0 not the same
69639    var BUGGY_ZERO = !IS_WEAK && fails(function () {
69640      // V8 ~ Chromium 42- fails only with 5+ elements
69641      var $instance = new C();
69642      var index = 5;
69643      while (index--) $instance[ADDER](index, index);
69644      return !$instance.has(-0);
69645    });
69646    if (!ACCEPT_ITERABLES) {
69647      C = wrapper(function (target, iterable) {
69648        anInstance(target, C, NAME);
69649        var that = inheritIfRequired(new Base(), target, C);
69650        if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
69651        return that;
69652      });
69653      C.prototype = proto;
69654      proto.constructor = C;
69655    }
69656    if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) {
69657      fixMethod('delete');
69658      fixMethod('has');
69659      IS_MAP && fixMethod('get');
69660    }
69661    if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER);
69662    // weak collections should not contains .clear method
69663    if (IS_WEAK && proto.clear) delete proto.clear;
69664  }
69665
69666  setToStringTag(C, NAME);
69667
69668  O[NAME] = C;
69669  $export($export.G + $export.W + $export.F * (C != Base), O);
69670
69671  if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP);
69672
69673  return C;
69674};
69675
69676},{"./_global":"node_modules/core-js/modules/_global.js","./_export":"node_modules/core-js/modules/_export.js","./_redefine":"node_modules/core-js/modules/_redefine.js","./_redefine-all":"node_modules/core-js/modules/_redefine-all.js","./_meta":"node_modules/core-js/modules/_meta.js","./_for-of":"node_modules/core-js/modules/_for-of.js","./_an-instance":"node_modules/core-js/modules/_an-instance.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_fails":"node_modules/core-js/modules/_fails.js","./_iter-detect":"node_modules/core-js/modules/_iter-detect.js","./_set-to-string-tag":"node_modules/core-js/modules/_set-to-string-tag.js","./_inherit-if-required":"node_modules/core-js/modules/_inherit-if-required.js"}],"node_modules/core-js/modules/es6.map.js":[function(require,module,exports) {
69677'use strict';
69678var strong = require('./_collection-strong');
69679var validate = require('./_validate-collection');
69680var MAP = 'Map';
69681
69682// 23.1 Map Objects
69683module.exports = require('./_collection')(MAP, function (get) {
69684  return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
69685}, {
69686  // 23.1.3.6 Map.prototype.get(key)
69687  get: function get(key) {
69688    var entry = strong.getEntry(validate(this, MAP), key);
69689    return entry && entry.v;
69690  },
69691  // 23.1.3.9 Map.prototype.set(key, value)
69692  set: function set(key, value) {
69693    return strong.def(validate(this, MAP), key === 0 ? 0 : key, value);
69694  }
69695}, strong, true);
69696
69697},{"./_collection-strong":"node_modules/core-js/modules/_collection-strong.js","./_validate-collection":"node_modules/core-js/modules/_validate-collection.js","./_collection":"node_modules/core-js/modules/_collection.js"}],"node_modules/core-js/modules/es6.set.js":[function(require,module,exports) {
69698'use strict';
69699var strong = require('./_collection-strong');
69700var validate = require('./_validate-collection');
69701var SET = 'Set';
69702
69703// 23.2 Set Objects
69704module.exports = require('./_collection')(SET, function (get) {
69705  return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
69706}, {
69707  // 23.2.3.1 Set.prototype.add(value)
69708  add: function add(value) {
69709    return strong.def(validate(this, SET), value = value === 0 ? 0 : value, value);
69710  }
69711}, strong);
69712
69713},{"./_collection-strong":"node_modules/core-js/modules/_collection-strong.js","./_validate-collection":"node_modules/core-js/modules/_validate-collection.js","./_collection":"node_modules/core-js/modules/_collection.js"}],"node_modules/core-js/modules/_collection-weak.js":[function(require,module,exports) {
69714'use strict';
69715var redefineAll = require('./_redefine-all');
69716var getWeak = require('./_meta').getWeak;
69717var anObject = require('./_an-object');
69718var isObject = require('./_is-object');
69719var anInstance = require('./_an-instance');
69720var forOf = require('./_for-of');
69721var createArrayMethod = require('./_array-methods');
69722var $has = require('./_has');
69723var validate = require('./_validate-collection');
69724var arrayFind = createArrayMethod(5);
69725var arrayFindIndex = createArrayMethod(6);
69726var id = 0;
69727
69728// fallback for uncaught frozen keys
69729var uncaughtFrozenStore = function (that) {
69730  return that._l || (that._l = new UncaughtFrozenStore());
69731};
69732var UncaughtFrozenStore = function () {
69733  this.a = [];
69734};
69735var findUncaughtFrozen = function (store, key) {
69736  return arrayFind(store.a, function (it) {
69737    return it[0] === key;
69738  });
69739};
69740UncaughtFrozenStore.prototype = {
69741  get: function (key) {
69742    var entry = findUncaughtFrozen(this, key);
69743    if (entry) return entry[1];
69744  },
69745  has: function (key) {
69746    return !!findUncaughtFrozen(this, key);
69747  },
69748  set: function (key, value) {
69749    var entry = findUncaughtFrozen(this, key);
69750    if (entry) entry[1] = value;
69751    else this.a.push([key, value]);
69752  },
69753  'delete': function (key) {
69754    var index = arrayFindIndex(this.a, function (it) {
69755      return it[0] === key;
69756    });
69757    if (~index) this.a.splice(index, 1);
69758    return !!~index;
69759  }
69760};
69761
69762module.exports = {
69763  getConstructor: function (wrapper, NAME, IS_MAP, ADDER) {
69764    var C = wrapper(function (that, iterable) {
69765      anInstance(that, C, NAME, '_i');
69766      that._t = NAME;      // collection type
69767      that._i = id++;      // collection id
69768      that._l = undefined; // leak store for uncaught frozen objects
69769      if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that);
69770    });
69771    redefineAll(C.prototype, {
69772      // 23.3.3.2 WeakMap.prototype.delete(key)
69773      // 23.4.3.3 WeakSet.prototype.delete(value)
69774      'delete': function (key) {
69775        if (!isObject(key)) return false;
69776        var data = getWeak(key);
69777        if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key);
69778        return data && $has(data, this._i) && delete data[this._i];
69779      },
69780      // 23.3.3.4 WeakMap.prototype.has(key)
69781      // 23.4.3.4 WeakSet.prototype.has(value)
69782      has: function has(key) {
69783        if (!isObject(key)) return false;
69784        var data = getWeak(key);
69785        if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key);
69786        return data && $has(data, this._i);
69787      }
69788    });
69789    return C;
69790  },
69791  def: function (that, key, value) {
69792    var data = getWeak(anObject(key), true);
69793    if (data === true) uncaughtFrozenStore(that).set(key, value);
69794    else data[that._i] = value;
69795    return that;
69796  },
69797  ufstore: uncaughtFrozenStore
69798};
69799
69800},{"./_redefine-all":"node_modules/core-js/modules/_redefine-all.js","./_meta":"node_modules/core-js/modules/_meta.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_an-instance":"node_modules/core-js/modules/_an-instance.js","./_for-of":"node_modules/core-js/modules/_for-of.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_has":"node_modules/core-js/modules/_has.js","./_validate-collection":"node_modules/core-js/modules/_validate-collection.js"}],"node_modules/core-js/modules/es6.weak-map.js":[function(require,module,exports) {
69801
69802'use strict';
69803var global = require('./_global');
69804var each = require('./_array-methods')(0);
69805var redefine = require('./_redefine');
69806var meta = require('./_meta');
69807var assign = require('./_object-assign');
69808var weak = require('./_collection-weak');
69809var isObject = require('./_is-object');
69810var validate = require('./_validate-collection');
69811var NATIVE_WEAK_MAP = require('./_validate-collection');
69812var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
69813var WEAK_MAP = 'WeakMap';
69814var getWeak = meta.getWeak;
69815var isExtensible = Object.isExtensible;
69816var uncaughtFrozenStore = weak.ufstore;
69817var InternalMap;
69818
69819var wrapper = function (get) {
69820  return function WeakMap() {
69821    return get(this, arguments.length > 0 ? arguments[0] : undefined);
69822  };
69823};
69824
69825var methods = {
69826  // 23.3.3.3 WeakMap.prototype.get(key)
69827  get: function get(key) {
69828    if (isObject(key)) {
69829      var data = getWeak(key);
69830      if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
69831      return data ? data[this._i] : undefined;
69832    }
69833  },
69834  // 23.3.3.5 WeakMap.prototype.set(key, value)
69835  set: function set(key, value) {
69836    return weak.def(validate(this, WEAK_MAP), key, value);
69837  }
69838};
69839
69840// 23.3 WeakMap Objects
69841var $WeakMap = module.exports = require('./_collection')(WEAK_MAP, wrapper, methods, weak, true, true);
69842
69843// IE11 WeakMap frozen keys fix
69844if (NATIVE_WEAK_MAP && IS_IE11) {
69845  InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
69846  assign(InternalMap.prototype, methods);
69847  meta.NEED = true;
69848  each(['delete', 'has', 'get', 'set'], function (key) {
69849    var proto = $WeakMap.prototype;
69850    var method = proto[key];
69851    redefine(proto, key, function (a, b) {
69852      // store frozen objects on internal weakmap shim
69853      if (isObject(a) && !isExtensible(a)) {
69854        if (!this._f) this._f = new InternalMap();
69855        var result = this._f[key](a, b);
69856        return key == 'set' ? this : result;
69857      // store all the rest on native weakmap
69858      } return method.call(this, a, b);
69859    });
69860  });
69861}
69862
69863},{"./_global":"node_modules/core-js/modules/_global.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_redefine":"node_modules/core-js/modules/_redefine.js","./_meta":"node_modules/core-js/modules/_meta.js","./_object-assign":"node_modules/core-js/modules/_object-assign.js","./_collection-weak":"node_modules/core-js/modules/_collection-weak.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_validate-collection":"node_modules/core-js/modules/_validate-collection.js","./_collection":"node_modules/core-js/modules/_collection.js"}],"node_modules/core-js/modules/es6.weak-set.js":[function(require,module,exports) {
69864'use strict';
69865var weak = require('./_collection-weak');
69866var validate = require('./_validate-collection');
69867var WEAK_SET = 'WeakSet';
69868
69869// 23.4 WeakSet Objects
69870require('./_collection')(WEAK_SET, function (get) {
69871  return function WeakSet() { return get(this, arguments.length > 0 ? arguments[0] : undefined); };
69872}, {
69873  // 23.4.3.1 WeakSet.prototype.add(value)
69874  add: function add(value) {
69875    return weak.def(validate(this, WEAK_SET), value, true);
69876  }
69877}, weak, false, true);
69878
69879},{"./_collection-weak":"node_modules/core-js/modules/_collection-weak.js","./_validate-collection":"node_modules/core-js/modules/_validate-collection.js","./_collection":"node_modules/core-js/modules/_collection.js"}],"node_modules/core-js/modules/_typed.js":[function(require,module,exports) {
69880
69881var global = require('./_global');
69882var hide = require('./_hide');
69883var uid = require('./_uid');
69884var TYPED = uid('typed_array');
69885var VIEW = uid('view');
69886var ABV = !!(global.ArrayBuffer && global.DataView);
69887var CONSTR = ABV;
69888var i = 0;
69889var l = 9;
69890var Typed;
69891
69892var TypedArrayConstructors = (
69893  'Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array'
69894).split(',');
69895
69896while (i < l) {
69897  if (Typed = global[TypedArrayConstructors[i++]]) {
69898    hide(Typed.prototype, TYPED, true);
69899    hide(Typed.prototype, VIEW, true);
69900  } else CONSTR = false;
69901}
69902
69903module.exports = {
69904  ABV: ABV,
69905  CONSTR: CONSTR,
69906  TYPED: TYPED,
69907  VIEW: VIEW
69908};
69909
69910},{"./_global":"node_modules/core-js/modules/_global.js","./_hide":"node_modules/core-js/modules/_hide.js","./_uid":"node_modules/core-js/modules/_uid.js"}],"node_modules/core-js/modules/_to-index.js":[function(require,module,exports) {
69911// https://tc39.github.io/ecma262/#sec-toindex
69912var toInteger = require('./_to-integer');
69913var toLength = require('./_to-length');
69914module.exports = function (it) {
69915  if (it === undefined) return 0;
69916  var number = toInteger(it);
69917  var length = toLength(number);
69918  if (number !== length) throw RangeError('Wrong length!');
69919  return length;
69920};
69921
69922},{"./_to-integer":"node_modules/core-js/modules/_to-integer.js","./_to-length":"node_modules/core-js/modules/_to-length.js"}],"node_modules/core-js/modules/_typed-buffer.js":[function(require,module,exports) {
69923
69924'use strict';
69925var global = require('./_global');
69926var DESCRIPTORS = require('./_descriptors');
69927var LIBRARY = require('./_library');
69928var $typed = require('./_typed');
69929var hide = require('./_hide');
69930var redefineAll = require('./_redefine-all');
69931var fails = require('./_fails');
69932var anInstance = require('./_an-instance');
69933var toInteger = require('./_to-integer');
69934var toLength = require('./_to-length');
69935var toIndex = require('./_to-index');
69936var gOPN = require('./_object-gopn').f;
69937var dP = require('./_object-dp').f;
69938var arrayFill = require('./_array-fill');
69939var setToStringTag = require('./_set-to-string-tag');
69940var ARRAY_BUFFER = 'ArrayBuffer';
69941var DATA_VIEW = 'DataView';
69942var PROTOTYPE = 'prototype';
69943var WRONG_LENGTH = 'Wrong length!';
69944var WRONG_INDEX = 'Wrong index!';
69945var $ArrayBuffer = global[ARRAY_BUFFER];
69946var $DataView = global[DATA_VIEW];
69947var Math = global.Math;
69948var RangeError = global.RangeError;
69949// eslint-disable-next-line no-shadow-restricted-names
69950var Infinity = global.Infinity;
69951var BaseBuffer = $ArrayBuffer;
69952var abs = Math.abs;
69953var pow = Math.pow;
69954var floor = Math.floor;
69955var log = Math.log;
69956var LN2 = Math.LN2;
69957var BUFFER = 'buffer';
69958var BYTE_LENGTH = 'byteLength';
69959var BYTE_OFFSET = 'byteOffset';
69960var $BUFFER = DESCRIPTORS ? '_b' : BUFFER;
69961var $LENGTH = DESCRIPTORS ? '_l' : BYTE_LENGTH;
69962var $OFFSET = DESCRIPTORS ? '_o' : BYTE_OFFSET;
69963
69964// IEEE754 conversions based on https://github.com/feross/ieee754
69965function packIEEE754(value, mLen, nBytes) {
69966  var buffer = new Array(nBytes);
69967  var eLen = nBytes * 8 - mLen - 1;
69968  var eMax = (1 << eLen) - 1;
69969  var eBias = eMax >> 1;
69970  var rt = mLen === 23 ? pow(2, -24) - pow(2, -77) : 0;
69971  var i = 0;
69972  var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
69973  var e, m, c;
69974  value = abs(value);
69975  // eslint-disable-next-line no-self-compare
69976  if (value != value || value === Infinity) {
69977    // eslint-disable-next-line no-self-compare
69978    m = value != value ? 1 : 0;
69979    e = eMax;
69980  } else {
69981    e = floor(log(value) / LN2);
69982    if (value * (c = pow(2, -e)) < 1) {
69983      e--;
69984      c *= 2;
69985    }
69986    if (e + eBias >= 1) {
69987      value += rt / c;
69988    } else {
69989      value += rt * pow(2, 1 - eBias);
69990    }
69991    if (value * c >= 2) {
69992      e++;
69993      c /= 2;
69994    }
69995    if (e + eBias >= eMax) {
69996      m = 0;
69997      e = eMax;
69998    } else if (e + eBias >= 1) {
69999      m = (value * c - 1) * pow(2, mLen);
70000      e = e + eBias;
70001    } else {
70002      m = value * pow(2, eBias - 1) * pow(2, mLen);
70003      e = 0;
70004    }
70005  }
70006  for (; mLen >= 8; buffer[i++] = m & 255, m /= 256, mLen -= 8);
70007  e = e << mLen | m;
70008  eLen += mLen;
70009  for (; eLen > 0;
vendor: 7,247 bytes, lines 70009-70201
70009 buffer[i++] = e & 255, e /= 256, eLen -= 8);
70010  buffer[--i] |= s * 128;
70011  return buffer;
70012}
70013function unpackIEEE754(buffer, mLen, nBytes) {
70014  var eLen = nBytes * 8 - mLen - 1;
70015  var eMax = (1 << eLen) - 1;
70016  var eBias = eMax >> 1;
70017  var nBits = eLen - 7;
70018  var i = nBytes - 1;
70019  var s = buffer[i--];
70020  var e = s & 127;
70021  var m;
70022  s >>= 7;
70023  for (; nBits > 0; e = e * 256 + buffer[i], i--, nBits -= 8);
70024  m = e & (1 << -nBits) - 1;
70025  e >>= -nBits;
70026  nBits += mLen;
70027  for (; nBits > 0; m = m * 256 + buffer[i], i--, nBits -= 8);
70028  if (e === 0) {
70029    e = 1 - eBias;
70030  } else if (e === eMax) {
70031    return m ? NaN : s ? -Infinity : Infinity;
70032  } else {
70033    m = m + pow(2, mLen);
70034    e = e - eBias;
70035  } return (s ? -1 : 1) * m * pow(2, e - mLen);
70036}
70037
70038function unpackI32(bytes) {
70039  return bytes[3] << 24 | bytes[2] << 16 | bytes[1] << 8 | bytes[0];
70040}
70041function packI8(it) {
70042  return [it & 0xff];
70043}
70044function packI16(it) {
70045  return [it & 0xff, it >> 8 & 0xff];
70046}
70047function packI32(it) {
70048  return [it & 0xff, it >> 8 & 0xff, it >> 16 & 0xff, it >> 24 & 0xff];
70049}
70050function packF64(it) {
70051  return packIEEE754(it, 52, 8);
70052}
70053function packF32(it) {
70054  return packIEEE754(it, 23, 4);
70055}
70056
70057function addGetter(C, key, internal) {
70058  dP(C[PROTOTYPE], key, { get: function () { return this[internal]; } });
70059}
70060
70061function get(view, bytes, index, isLittleEndian) {
70062  var numIndex = +index;
70063  var intIndex = toIndex(numIndex);
70064  if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
70065  var store = view[$BUFFER]._b;
70066  var start = intIndex + view[$OFFSET];
70067  var pack = store.slice(start, start + bytes);
70068  return isLittleEndian ? pack : pack.reverse();
70069}
70070function set(view, bytes, index, conversion, value, isLittleEndian) {
70071  var numIndex = +index;
70072  var intIndex = toIndex(numIndex);
70073  if (intIndex + bytes > view[$LENGTH]) throw RangeError(WRONG_INDEX);
70074  var store = view[$BUFFER]._b;
70075  var start = intIndex + view[$OFFSET];
70076  var pack = conversion(+value);
70077  for (var i = 0; i < bytes; i++) store[start + i] = pack[isLittleEndian ? i : bytes - i - 1];
70078}
70079
70080if (!$typed.ABV) {
70081  $ArrayBuffer = function ArrayBuffer(length) {
70082    anInstance(this, $ArrayBuffer, ARRAY_BUFFER);
70083    var byteLength = toIndex(length);
70084    this._b = arrayFill.call(new Array(byteLength), 0);
70085    this[$LENGTH] = byteLength;
70086  };
70087
70088  $DataView = function DataView(buffer, byteOffset, byteLength) {
70089    anInstance(this, $DataView, DATA_VIEW);
70090    anInstance(buffer, $ArrayBuffer, DATA_VIEW);
70091    var bufferLength = buffer[$LENGTH];
70092    var offset = toInteger(byteOffset);
70093    if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset!');
70094    byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength);
70095    if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH);
70096    this[$BUFFER] = buffer;
70097    this[$OFFSET] = offset;
70098    this[$LENGTH] = byteLength;
70099  };
70100
70101  if (DESCRIPTORS) {
70102    addGetter($ArrayBuffer, BYTE_LENGTH, '_l');
70103    addGetter($DataView, BUFFER, '_b');
70104    addGetter($DataView, BYTE_LENGTH, '_l');
70105    addGetter($DataView, BYTE_OFFSET, '_o');
70106  }
70107
70108  redefineAll($DataView[PROTOTYPE], {
70109    getInt8: function getInt8(byteOffset) {
70110      return get(this, 1, byteOffset)[0] << 24 >> 24;
70111    },
70112    getUint8: function getUint8(byteOffset) {
70113      return get(this, 1, byteOffset)[0];
70114    },
70115    getInt16: function getInt16(byteOffset /* , littleEndian */) {
70116      var bytes = get(this, 2, byteOffset, arguments[1]);
70117      return (bytes[1] << 8 | bytes[0]) << 16 >> 16;
70118    },
70119    getUint16: function getUint16(byteOffset /* , littleEndian */) {
70120      var bytes = get(this, 2, byteOffset, arguments[1]);
70121      return bytes[1] << 8 | bytes[0];
70122    },
70123    getInt32: function getInt32(byteOffset /* , littleEndian */) {
70124      return unpackI32(get(this, 4, byteOffset, arguments[1]));
70125    },
70126    getUint32: function getUint32(byteOffset /* , littleEndian */) {
70127      return unpackI32(get(this, 4, byteOffset, arguments[1])) >>> 0;
70128    },
70129    getFloat32: function getFloat32(byteOffset /* , littleEndian */) {
70130      return unpackIEEE754(get(this, 4, byteOffset, arguments[1]), 23, 4);
70131    },
70132    getFloat64: function getFloat64(byteOffset /* , littleEndian */) {
70133      return unpackIEEE754(get(this, 8, byteOffset, arguments[1]), 52, 8);
70134    },
70135    setInt8: function setInt8(byteOffset, value) {
70136      set(this, 1, byteOffset, packI8, value);
70137    },
70138    setUint8: function setUint8(byteOffset, value) {
70139      set(this, 1, byteOffset, packI8, value);
70140    },
70141    setInt16: function setInt16(byteOffset, value /* , littleEndian */) {
70142      set(this, 2, byteOffset, packI16, value, arguments[2]);
70143    },
70144    setUint16: function setUint16(byteOffset, value /* , littleEndian */) {
70145      set(this, 2, byteOffset, packI16, value, arguments[2]);
70146    },
70147    setInt32: function setInt32(byteOffset, value /* , littleEndian */) {
70148      set(this, 4, byteOffset, packI32, value, arguments[2]);
70149    },
70150    setUint32: function setUint32(byteOffset, value /* , littleEndian */) {
70151      set(this, 4, byteOffset, packI32, value, arguments[2]);
70152    },
70153    setFloat32: function setFloat32(byteOffset, value /* , littleEndian */) {
70154      set(this, 4, byteOffset, packF32, value, arguments[2]);
70155    },
70156    setFloat64: function setFloat64(byteOffset, value /* , littleEndian */) {
70157      set(this, 8, byteOffset, packF64, value, arguments[2]);
70158    }
70159  });
70160} else {
70161  if (!fails(function () {
70162    $ArrayBuffer(1);
70163  }) || !fails(function () {
70164    new $ArrayBuffer(-1); // eslint-disable-line no-new
70165  }) || fails(function () {
70166    new $ArrayBuffer(); // eslint-disable-line no-new
70167    new $ArrayBuffer(1.5); // eslint-disable-line no-new
70168    new $ArrayBuffer(NaN); // eslint-disable-line no-new
70169    return $ArrayBuffer.name != ARRAY_BUFFER;
70170  })) {
70171    $ArrayBuffer = function ArrayBuffer(length) {
70172      anInstance(this, $ArrayBuffer);
70173      return new BaseBuffer(toIndex(length));
70174    };
70175    var ArrayBufferProto = $ArrayBuffer[PROTOTYPE] = BaseBuffer[PROTOTYPE];
70176    for (var keys = gOPN(BaseBuffer), j = 0, key; keys.length > j;) {
70177      if (!((key = keys[j++]) in $ArrayBuffer)) hide($ArrayBuffer, key, BaseBuffer[key]);
70178    }
70179    if (!LIBRARY) ArrayBufferProto.constructor = $ArrayBuffer;
70180  }
70181  // iOS Safari 7.x bug
70182  var view = new $DataView(new $ArrayBuffer(2));
70183  var $setInt8 = $DataView[PROTOTYPE].setInt8;
70184  view.setInt8(0, 2147483648);
70185  view.setInt8(1, 2147483649);
70186  if (view.getInt8(0) || !view.getInt8(1)) redefineAll($DataView[PROTOTYPE], {
70187    setInt8: function setInt8(byteOffset, value) {
70188      $setInt8.call(this, byteOffset, value << 24 >> 24);
70189    },
70190    setUint8: function setUint8(byteOffset, value) {
70191      $setInt8.call(this, byteOffset, value << 24 >> 24);
70192    }
70193  }, true);
70194}
70195setToStringTag($ArrayBuffer, ARRAY_BUFFER);
70196setToStringTag($DataView, DATA_VIEW);
70197hide($DataView[PROTOTYPE], $typed.VIEW, true);
70198exports[ARRAY_BUFFER] = $ArrayBuffer;
70199exports[DATA_VIEW] = $DataView;
70200
70201},{"./_global":"node_modules/core-js/modules/_global.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_library":"node_modules/core-js/modules/_library.js","./_typed":"node_modules/core-js/modules/_typed.js","./_hide":"node_modules/core-js/modules/_hide.js","./_redefine-all":"node_modules/core-js/modules/_redefine-all.js","./_fail
70201s":"node_modules/core-js/modules/_fails.js","./_an-instance":"node_modules/core-js/modules/_an-instance.js","./_to-integer":"node_modules/core-js/modules/_to-integer.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_to-index":"node_modules/core-js/modules/_to-index.js","./_object-gopn":"node_modules/core-js/modules/_object-gopn.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_array-fill":"node_modules/core-js/modules/_array-fill.js","./_set-to-string-tag":"node_modules/core-js/modules/_set-to-string-tag.js"}],"node_modules/core-js/modules/es6.typed.array-buffer.js":[function(require,module,exports) {
70202'use strict';
70203var $export = require('./_export');
70204var $typed = require('./_typed');
70205var buffer = require('./_typed-buffer');
70206var anObject = require('./_an-object');
70207var toAbsoluteIndex = require('./_to-absolute-index');
70208var toLength = require('./_to-length');
70209var isObject = require('./_is-object');
70210var ArrayBuffer = require('./_global').ArrayBuffer;
70211var speciesConstructor = require('./_species-constructor');
70212var $ArrayBuffer = buffer.ArrayBuffer;
70213var $DataView = buffer.DataView;
70214var $isView = $typed.ABV && ArrayBuffer.isView;
70215var $slice = $ArrayBuffer.prototype.slice;
70216var VIEW = $typed.VIEW;
70217var ARRAY_BUFFER = 'ArrayBuffer';
70218
70219$export($export.G + $export.W + $export.F * (ArrayBuffer !== $ArrayBuffer), { ArrayBuffer: $ArrayBuffer });
70220
70221$export($export.S + $export.F * !$typed.CONSTR, ARRAY_BUFFER, {
70222  // 24.1.3.1 ArrayBuffer.isView(arg)
70223  isView: function isView(it) {
70224    return $isView && $isView(it) || isObject(it) && VIEW in it;
70225  }
70226});
70227
70228$export($export.P + $export.U + $export.F * require('./_fails')(function () {
70229  return !new $ArrayBuffer(2).slice(1, undefined).byteLength;
70230}), ARRAY_BUFFER, {
70231  // 24.1.4.3 ArrayBuffer.prototype.slice(start, end)
70232  slice: function slice(start, end) {
70233    if ($slice !== undefined && end === undefined) return $slice.call(anObject(this), start); // FF fix
70234    var len = anObject(this).byteLength;
70235    var first = toAbsoluteIndex(start, len);
70236    var fin = toAbsoluteIndex(end === undefined ? len : end, len);
70237    var result = new (speciesConstructor(this, $ArrayBuffer))(toLength(fin - first));
70238    var viewS = new $DataView(this);
70239    var viewT = new $DataView(result);
70240    var index = 0;
70241    while (first < fin) {
70242      viewT.setUint8(index++, viewS.getUint8(first++));
70243    } return result;
70244  }
70245});
70246
70247require('./_set-species')(ARRAY_BUFFER);
70248
70249},{"./_export":"node_modules/core-js/modules/_export.js","./_typed":"node_modules/core-js/modules/_typed.js","./_typed-buffer":"node_modules/core-js/modules/_typed-buffer.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_to-absolute-index":"node_modules/core-js/modules/_to-absolute-index.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_global":"node_modules/core-js/modules/_global.js","./_species-constructor":"node_modules/core-js/modules/_species-constructor.js","./_fails":"node_modules/core-js/modules/_fails.js","./_set-species":"node_modules/core-js/modules/_set-species.js"}],"node_modules/core-js/modules/es6.typed.data-view.js":[function(require,module,exports) {
70250var $export = require('./_export');
70251$export($export.G + $export.W + $export.F * !require('./_typed').ABV, {
70252  DataView: require('./_typed-buffer').DataView
70253});
70254
70255},{"./_export":"node_modules/core-js/modules/_export.js","./_typed":"node_modules/core-js/modules/_typed.js","./_typed-buffer":"node_modules/core-js/modules/_typed-buffer.js"}],"node_modules/core-js/modules/_typed-array.js":[function(require,module,exports) {
70256var global = arguments[3];
70257'use strict';
70258if (require('./_descriptors')) {
70259  var LIBRARY = require('./_library');
70260  var global = require('./_global');
70261  var fails = require('./_fails');
70262  var $export = require('./_export');
70263  var $typed = require('./_typed');
70264  var $buffer = require('./_typed-buffer');
70265  var ctx = require('./_ctx');
70266  var anInstance = require('./_an-instance');
70267  var propertyDesc = require('./_property-desc');
70268  var hide = require('./_hide');
70269  var redefineAll = require('./_redefine-all');
70270  var toInteger = require('./_to-integer');
70271  var toLength = require('./_to-length');
70272  var toIndex = require('./_to-index');
70273  var toAbsoluteIndex = require('./_to-absolute-index');
70274  var toPrimitive = require('./_to-primitive');
70275  var has = require('./_has');
70276  var classof = require('./_classof');
70277  var isObject = require('./_is-object');
70278  var toObject = require('./_to-object');
70279  var isArrayIter = require('./_is-array-iter');
70280  var create = require('./_object-create');
70281  var getPrototypeOf = require('./_object-gpo');
70282  var gOPN = require('./_object-gopn').f;
70283  var getIterFn = require('./core.get-iterator-method');
70284  var uid = require('./_uid');
70285  var wks = require('./_wks');
70286  var createArrayMethod = require('./_array-methods');
70287  var createArrayIncludes = require('./_array-includes');
70288  var speciesConstructor = require('./_species-constructor');
70289  var ArrayIterators = require('./es6.array.iterator');
70290  var Iterators = require('./_iterators');
70291  var $iterDetect = require('./_iter-detect');
70292  var setSpecies = require('./_set-species');
70293  var arrayFill = require('./_array-fill');
70294  var arrayCopyWithin = require('./_array-copy-within');
70295  var $DP = require('./_object-dp');
70296  var $GOPD = require('./_object-gopd'
vendor: 8,586 bytes, lines 70296-70524
70296);
70297  var dP = $DP.f;
70298  var gOPD = $GOPD.f;
70299  var RangeError = global.RangeError;
70300  var TypeError = global.TypeError;
70301  var Uint8Array = global.Uint8Array;
70302  var ARRAY_BUFFER = 'ArrayBuffer';
70303  var SHARED_BUFFER = 'Shared' + ARRAY_BUFFER;
70304  var BYTES_PER_ELEMENT = 'BYTES_PER_ELEMENT';
70305  var PROTOTYPE = 'prototype';
70306  var ArrayProto = Array[PROTOTYPE];
70307  var $ArrayBuffer = $buffer.ArrayBuffer;
70308  var $DataView = $buffer.DataView;
70309  var arrayForEach = createArrayMethod(0);
70310  var arrayFilter = createArrayMethod(2);
70311  var arraySome = createArrayMethod(3);
70312  var arrayEvery = createArrayMethod(4);
70313  var arrayFind = createArrayMethod(5);
70314  var arrayFindIndex = createArrayMethod(6);
70315  var arrayIncludes = createArrayIncludes(true);
70316  var arrayIndexOf = createArrayIncludes(false);
70317  var arrayValues = ArrayIterators.values;
70318  var arrayKeys = ArrayIterators.keys;
70319  var arrayEntries = ArrayIterators.entries;
70320  var arrayLastIndexOf = ArrayProto.lastIndexOf;
70321  var arrayReduce = ArrayProto.reduce;
70322  var arrayReduceRight = ArrayProto.reduceRight;
70323  var arrayJoin = ArrayProto.join;
70324  var arraySort = ArrayProto.sort;
70325  var arraySlice = ArrayProto.slice;
70326  var arrayToString = ArrayProto.toString;
70327  var arrayToLocaleString = ArrayProto.toLocaleString;
70328  var ITERATOR = wks('iterator');
70329  var TAG = wks('toStringTag');
70330  var TYPED_CONSTRUCTOR = uid('typed_constructor');
70331  var DEF_CONSTRUCTOR = uid('def_constructor');
70332  var ALL_CONSTRUCTORS = $typed.CONSTR;
70333  var TYPED_ARRAY = $typed.TYPED;
70334  var VIEW = $typed.VIEW;
70335  var WRONG_LENGTH = 'Wrong length!';
70336
70337  var $map = createArrayMethod(1, function (O, length) {
70338    return allocate(speciesConstructor(O, O[DEF_CONSTRUCTOR]), length);
70339  });
70340
70341  var LITTLE_ENDIAN = fails(function () {
70342    // eslint-disable-next-line no-undef
70343    return new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
70344  });
70345
70346  var FORCED_SET = !!Uint8Array && !!Uint8Array[PROTOTYPE].set && fails(function () {
70347    new Uint8Array(1).set({});
70348  });
70349
70350  var toOffset = function (it, BYTES) {
70351    var offset = toInteger(it);
70352    if (offset < 0 || offset % BYTES) throw RangeError('Wrong offset!');
70353    return offset;
70354  };
70355
70356  var validate = function (it) {
70357    if (isObject(it) && TYPED_ARRAY in it) return it;
70358    throw TypeError(it + ' is not a typed array!');
70359  };
70360
70361  var allocate = function (C, length) {
70362    if (!(isObject(C) && TYPED_CONSTRUCTOR in C)) {
70363      throw TypeError('It is not a typed array constructor!');
70364    } return new C(length);
70365  };
70366
70367  var speciesFromList = function (O, list) {
70368    return fromList(speciesConstructor(O, O[DEF_CONSTRUCTOR]), list);
70369  };
70370
70371  var fromList = function (C, list) {
70372    var index = 0;
70373    var length = list.length;
70374    var result = allocate(C, length);
70375    while (length > index) result[index] = list[index++];
70376    return result;
70377  };
70378
70379  var addGetter = function (it, key, internal) {
70380    dP(it, key, { get: function () { return this._d[internal]; } });
70381  };
70382
70383  var $from = function from(source /* , mapfn, thisArg */) {
70384    var O = toObject(source);
70385    var aLen = arguments.length;
70386    var mapfn = aLen > 1 ? arguments[1] : undefined;
70387    var mapping = mapfn !== undefined;
70388    var iterFn = getIterFn(O);
70389    var i, length, values, result, step, iterator;
70390    if (iterFn != undefined && !isArrayIter(iterFn)) {
70391      for (iterator = iterFn.call(O), values = [], i = 0; !(step = iterator.next()).done; i++) {
70392        values.push(step.value);
70393      } O = values;
70394    }
70395    if (mapping && aLen > 2) mapfn = ctx(mapfn, arguments[2], 2);
70396    for (i = 0, length = toLength(O.length), result = allocate(this, length); length > i; i++) {
70397      result[i] = mapping ? mapfn(O[i], i) : O[i];
70398    }
70399    return result;
70400  };
70401
70402  var $of = function of(/* ...items */) {
70403    var index = 0;
70404    var length = arguments.length;
70405    var result = allocate(this, length);
70406    while (length > index) result[index] = arguments[index++];
70407    return result;
70408  };
70409
70410  // iOS Safari 6.x fails here
70411  var TO_LOCALE_BUG = !!Uint8Array && fails(function () { arrayToLocaleString.call(new Uint8Array(1)); });
70412
70413  var $toLocaleString = function toLocaleString() {
70414    return arrayToLocaleString.apply(TO_LOCALE_BUG ? arraySlice.call(validate(this)) : validate(this), arguments);
70415  };
70416
70417  var proto = {
70418    copyWithin: function copyWithin(target, start /* , end */) {
70419      return arrayCopyWithin.call(validate(this), target, start, arguments.length > 2 ? arguments[2] : undefined);
70420    },
70421    every: function every(callbackfn /* , thisArg */) {
70422      return arrayEvery(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
70423    },
70424    fill: function fill(value /* , start, end */) { // eslint-disable-line no-unused-vars
70425      return arrayFill.apply(validate(this), arguments);
70426    },
70427    filter: function filter(callbackfn /* , thisArg */) {
70428      return speciesFromList(this, arrayFilter(validate(this), callbackfn,
70429        arguments.length > 1 ? arguments[1] : undefined));
70430    },
70431    find: function find(predicate /* , thisArg */) {
70432      return arrayFind(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
70433    },
70434    findIndex: function findIndex(predicate /* , thisArg */) {
70435      return arrayFindIndex(validate(this), predicate, arguments.length > 1 ? arguments[1] : undefined);
70436    },
70437    forEach: function forEach(callbackfn /* , thisArg */) {
70438      arrayForEach(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
70439    },
70440    indexOf: function indexOf(searchElement /* , fromIndex */) {
70441      return arrayIndexOf(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
70442    },
70443    includes: function includes(searchElement /* , fromIndex */) {
70444      return arrayIncludes(validate(this), searchElement, arguments.length > 1 ? arguments[1] : undefined);
70445    },
70446    join: function join(separator) { // eslint-disable-line no-unused-vars
70447      return arrayJoin.apply(validate(this), arguments);
70448    },
70449    lastIndexOf: function lastIndexOf(searchElement /* , fromIndex */) { // eslint-disable-line no-unused-vars
70450      return arrayLastIndexOf.apply(validate(this), arguments);
70451    },
70452    map: function map(mapfn /* , thisArg */) {
70453      return $map(validate(this), mapfn, arguments.length > 1 ? arguments[1] : undefined);
70454    },
70455    reduce: function reduce(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars
70456      return arrayReduce.apply(validate(this), arguments);
70457    },
70458    reduceRight: function reduceRight(callbackfn /* , initialValue */) { // eslint-disable-line no-unused-vars
70459      return arrayReduceRight.apply(validate(this), arguments);
70460    },
70461    reverse: function reverse() {
70462      var that = this;
70463      var length = validate(that).length;
70464      var middle = Math.floor(length / 2);
70465      var index = 0;
70466      var value;
70467      while (index < middle) {
70468        value = that[index];
70469        that[index++] = that[--length];
70470        that[length] = value;
70471      } return that;
70472    },
70473    some: function some(callbackfn /* , thisArg */) {
70474      return arraySome(validate(this), callbackfn, arguments.length > 1 ? arguments[1] : undefined);
70475    },
70476    sort: function sort(comparefn) {
70477      return arraySort.call(validate(this), comparefn);
70478    },
70479    subarray: function subarray(begin, end) {
70480      var O = validate(this);
70481      var length = O.length;
70482      var $begin = toAbsoluteIndex(begin, length);
70483      return new (speciesConstructor(O, O[DEF_CONSTRUCTOR]))(
70484        O.buffer,
70485        O.byteOffset + $begin * O.BYTES_PER_ELEMENT,
70486        toLength((end === undefined ? length : toAbsoluteIndex(end, length)) - $begin)
70487      );
70488    }
70489  };
70490
70491  var $slice = function slice(start, end) {
70492    return speciesFromList(this, arraySlice.call(validate(this), start, end));
70493  };
70494
70495  var $set = function set(arrayLike /* , offset */) {
70496    validate(this);
70497    var offset = toOffset(arguments[1], 1);
70498    var length = this.length;
70499    var src = toObject(arrayLike);
70500    var len = toLength(src.length);
70501    var index = 0;
70502    if (len + offset > length) throw RangeError(WRONG_LENGTH);
70503    while (index < len) this[offset + index] = src[index++];
70504  };
70505
70506  var $iterators = {
70507    entries: function entries() {
70508      return arrayEntries.call(validate(this));
70509    },
70510    keys: function keys() {
70511      return arrayKeys.call(validate(this));
70512    },
70513    values: function values() {
70514      return arrayValues.call(validate(this));
70515    }
70516  };
70517
70518  var isTAIndex = function (target, key) {
70519    return isObject(target)
70520      && target[TYPED_ARRAY]
70521      && typeof key != 'symbol'
70522      && key in target
70523      && String(+key) == String(key);
70524  };
vendor: 7,985 bytes, lines 70525-70736
70525  var $getDesc = function getOwnPropertyDescriptor(target, key) {
70526    return isTAIndex(target, key = toPrimitive(key, true))
70527      ? propertyDesc(2, target[key])
70528      : gOPD(target, key);
70529  };
70530  var $setDesc = function defineProperty(target, key, desc) {
70531    if (isTAIndex(target, key = toPrimitive(key, true))
70532      && isObject(desc)
70533      && has(desc, 'value')
70534      && !has(desc, 'get')
70535      && !has(desc, 'set')
70536      // TODO: add validation descriptor w/o calling accessors
70537      && !desc.configurable
70538      && (!has(desc, 'writable') || desc.writable)
70539      && (!has(desc, 'enumerable') || desc.enumerable)
70540    ) {
70541      target[key] = desc.value;
70542      return target;
70543    } return dP(target, key, desc);
70544  };
70545
70546  if (!ALL_CONSTRUCTORS) {
70547    $GOPD.f = $getDesc;
70548    $DP.f = $setDesc;
70549  }
70550
70551  $export($export.S + $export.F * !ALL_CONSTRUCTORS, 'Object', {
70552    getOwnPropertyDescriptor: $getDesc,
70553    defineProperty: $setDesc
70554  });
70555
70556  if (fails(function () { arrayToString.call({}); })) {
70557    arrayToString = arrayToLocaleString = function toString() {
70558      return arrayJoin.call(this);
70559    };
70560  }
70561
70562  var $TypedArrayPrototype$ = redefineAll({}, proto);
70563  redefineAll($TypedArrayPrototype$, $iterators);
70564  hide($TypedArrayPrototype$, ITERATOR, $iterators.values);
70565  redefineAll($TypedArrayPrototype$, {
70566    slice: $slice,
70567    set: $set,
70568    constructor: function () { /* noop */ },
70569    toString: arrayToString,
70570    toLocaleString: $toLocaleString
70571  });
70572  addGetter($TypedArrayPrototype$, 'buffer', 'b');
70573  addGetter($TypedArrayPrototype$, 'byteOffset', 'o');
70574  addGetter($TypedArrayPrototype$, 'byteLength', 'l');
70575  addGetter($TypedArrayPrototype$, 'length', 'e');
70576  dP($TypedArrayPrototype$, TAG, {
70577    get: function () { return this[TYPED_ARRAY]; }
70578  });
70579
70580  // eslint-disable-next-line max-statements
70581  module.exports = function (KEY, BYTES, wrapper, CLAMPED) {
70582    CLAMPED = !!CLAMPED;
70583    var NAME = KEY + (CLAMPED ? 'Clamped' : '') + 'Array';
70584    var GETTER = 'get' + KEY;
70585    var SETTER = 'set' + KEY;
70586    var TypedArray = global[NAME];
70587    var Base = TypedArray || {};
70588    var TAC = TypedArray && getPrototypeOf(TypedArray);
70589    var FORCED = !TypedArray || !$typed.ABV;
70590    var O = {};
70591    var TypedArrayPrototype = TypedArray && TypedArray[PROTOTYPE];
70592    var getter = function (that, index) {
70593      var data = that._d;
70594      return data.v[GETTER](index * BYTES + data.o, LITTLE_ENDIAN);
70595    };
70596    var setter = function (that, index, value) {
70597      var data = that._d;
70598      if (CLAMPED) value = (value = Math.round(value)) < 0 ? 0 : value > 0xff ? 0xff : value & 0xff;
70599      data.v[SETTER](index * BYTES + data.o, value, LITTLE_ENDIAN);
70600    };
70601    var addElement = function (that, index) {
70602      dP(that, index, {
70603        get: function () {
70604          return getter(this, index);
70605        },
70606        set: function (value) {
70607          return setter(this, index, value);
70608        },
70609        enumerable: true
70610      });
70611    };
70612    if (FORCED) {
70613      TypedArray = wrapper(function (that, data, $offset, $length) {
70614        anInstance(that, TypedArray, NAME, '_d');
70615        var index = 0;
70616        var offset = 0;
70617        var buffer, byteLength, length, klass;
70618        if (!isObject(data)) {
70619          length = toIndex(data);
70620          byteLength = length * BYTES;
70621          buffer = new $ArrayBuffer(byteLength);
70622        } else if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
70623          buffer = data;
70624          offset = toOffset($offset, BYTES);
70625          var $len = data.byteLength;
70626          if ($length === undefined) {
70627            if ($len % BYTES) throw RangeError(WRONG_LENGTH);
70628            byteLength = $len - offset;
70629            if (byteLength < 0) throw RangeError(WRONG_LENGTH);
70630          } else {
70631            byteLength = toLength($length) * BYTES;
70632            if (byteLength + offset > $len) throw RangeError(WRONG_LENGTH);
70633          }
70634          length = byteLength / BYTES;
70635        } else if (TYPED_ARRAY in data) {
70636          return fromList(TypedArray, data);
70637        } else {
70638          return $from.call(TypedArray, data);
70639        }
70640        hide(that, '_d', {
70641          b: buffer,
70642          o: offset,
70643          l: byteLength,
70644          e: length,
70645          v: new $DataView(buffer)
70646        });
70647        while (index < length) addElement(that, index++);
70648      });
70649      TypedArrayPrototype = TypedArray[PROTOTYPE] = create($TypedArrayPrototype$);
70650      hide(TypedArrayPrototype, 'constructor', TypedArray);
70651    } else if (!fails(function () {
70652      TypedArray(1);
70653    }) || !fails(function () {
70654      new TypedArray(-1); // eslint-disable-line no-new
70655    }) || !$iterDetect(function (iter) {
70656      new TypedArray(); // eslint-disable-line no-new
70657      new TypedArray(null); // eslint-disable-line no-new
70658      new TypedArray(1.5); // eslint-disable-line no-new
70659      new TypedArray(iter); // eslint-disable-line no-new
70660    }, true)) {
70661      TypedArray = wrapper(function (that, data, $offset, $length) {
70662        anInstance(that, TypedArray, NAME);
70663        var klass;
70664        // `ws` module bug, temporarily remove validation length for Uint8Array
70665        // https://github.com/websockets/ws/pull/645
70666        if (!isObject(data)) return new Base(toIndex(data));
70667        if (data instanceof $ArrayBuffer || (klass = classof(data)) == ARRAY_BUFFER || klass == SHARED_BUFFER) {
70668          return $length !== undefined
70669            ? new Base(data, toOffset($offset, BYTES), $length)
70670            : $offset !== undefined
70671              ? new Base(data, toOffset($offset, BYTES))
70672              : new Base(data);
70673        }
70674        if (TYPED_ARRAY in data) return fromList(TypedArray, data);
70675        return $from.call(TypedArray, data);
70676      });
70677      arrayForEach(TAC !== Function.prototype ? gOPN(Base).concat(gOPN(TAC)) : gOPN(Base), function (key) {
70678        if (!(key in TypedArray)) hide(TypedArray, key, Base[key]);
70679      });
70680      TypedArray[PROTOTYPE] = TypedArrayPrototype;
70681      if (!LIBRARY) TypedArrayPrototype.constructor = TypedArray;
70682    }
70683    var $nativeIterator = TypedArrayPrototype[ITERATOR];
70684    var CORRECT_ITER_NAME = !!$nativeIterator
70685      && ($nativeIterator.name == 'values' || $nativeIterator.name == undefined);
70686    var $iterator = $iterators.values;
70687    hide(TypedArray, TYPED_CONSTRUCTOR, true);
70688    hide(TypedArrayPrototype, TYPED_ARRAY, NAME);
70689    hide(TypedArrayPrototype, VIEW, true);
70690    hide(TypedArrayPrototype, DEF_CONSTRUCTOR, TypedArray);
70691
70692    if (CLAMPED ? new TypedArray(1)[TAG] != NAME : !(TAG in TypedArrayPrototype)) {
70693      dP(TypedArrayPrototype, TAG, {
70694        get: function () { return NAME; }
70695      });
70696    }
70697
70698    O[NAME] = TypedArray;
70699
70700    $export($export.G + $export.W + $export.F * (TypedArray != Base), O);
70701
70702    $export($export.S, NAME, {
70703      BYTES_PER_ELEMENT: BYTES
70704    });
70705
70706    $export($export.S + $export.F * fails(function () { Base.of.call(TypedArray, 1); }), NAME, {
70707      from: $from,
70708      of: $of
70709    });
70710
70711    if (!(BYTES_PER_ELEMENT in TypedArrayPrototype)) hide(TypedArrayPrototype, BYTES_PER_ELEMENT, BYTES);
70712
70713    $export($export.P, NAME, proto);
70714
70715    setSpecies(NAME);
70716
70717    $export($export.P + $export.F * FORCED_SET, NAME, { set: $set });
70718
70719    $export($export.P + $export.F * !CORRECT_ITER_NAME, NAME, $iterators);
70720
70721    if (!LIBRARY && TypedArrayPrototype.toString != arrayToString) TypedArrayPrototype.toString = arrayToString;
70722
70723    $export($export.P + $export.F * fails(function () {
70724      new TypedArray(1).slice();
70725    }), NAME, { slice: $slice });
70726
70727    $export($export.P + $export.F * (fails(function () {
70728      return [1, 2].toLocaleString() != new TypedArray([1, 2]).toLocaleString();
70729    }) || !fails(function () {
70730      TypedArrayPrototype.toLocaleString.call([1, 2]);
70731    })), NAME, { toLocaleString: $toLocaleString });
70732
70733    Iterators[NAME] = CORRECT_ITER_NAME ? $nativeIterator : $iterator;
70734    if (!LIBRARY && !CORRECT_ITER_NAME) hide(TypedArrayPrototype, ITERATOR, $iterator);
70735  };
70736} else module.exports = function () { /* empty */ };
70737
70738},{"./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_library":"node_modules/core-js/modules/_library.js","./_global":"node_modules/core-js/modules/_global.js","./_fails":"node_modules/core-js/modules/_fails.js","./_export":"node_modules/core-js/modules/_export.js","./_typed":"node_modules/core-js/modules/_typed.js","./_typed-buffer":"node_modules/core-js/modules/_typed-buffer.js","./_ctx":"node_modules/core-js/modules/_ctx.js","./_an-instance":"node_modules/core-js/modules/_an-instance.js","./_property-desc":"node_modules/core-js/modules/_property-desc.js","./_hide":"node_modules/core-js/modules/_hide.js","./_redefine-all":"node_modules/core-js/modules/_redefine-all.js","./_to-integer":"node_modules/core-js/modules/_to-integer.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_to-index":"node_modules/core-js/modules/_to-index.js","./_to-absolute-index":"node_modules/core-js/modules/_to-absolute-index.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js","./_has":"node_modules/core-js/modules/_has.js","./_classof":"node_modules/core-js/modules/_classof.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_is-array-iter":"node_modules/core-js/modules/_is-array-iter.js","./_object-create":"node_modules/core-js/modules/_object-create.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js","./_object-gopn":"node_modules/core-js/modules/_object-gopn.js","./core.get-iterator-method":"node_modules/core-js/modules/core.get-iterator-method.js","./_uid":"node_modules/core-js/modules/_uid.js","./_wks":"node_modules/core-js/modules/_wks.js","./_array-methods":"node_modules/core-js/modules/_array-methods.js","./_array-includes":"node_modules/core-js/modules/_array-includes.js","./_species-constructor":"node_modules/core-js/modules/_species-constructor.js","./es6.array.iterator":"node_modules/core-js/modules/es6.array.iterator.js","./_iterators":"node_modules/core-js/modules/_iterators.js","./_iter-detect":"node_modules/core-js/modules/_iter-detect.js","./_set-species":"node_modules/core-js/modules/_set-species.js","./_array-fill":"node_modules/core-js/modules/_array-fill.js","./_array-copy-within":"node_modules/core-js/modules/_array-copy-within.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js"}],"node_modules/core-js/modules/es6.typed.int8-array.js":[function(require,module,exports) {
70739require('./_typed-array')('Int8', 1, function (init) {
70740  return function Int8Array(data, byteOffset, length) {
70741    return init(this, data, byteOffset, length);
70742  };
70743});
70744
70745},{"./_typed-array":"node_modules/core-js/modules/_typed-array.js"}],"node_modules/core-js/modules/es6.typed.uint8-array.js":[function(require,module,exports) {
70746require('./_typed-array')('Uint8', 1, function (init) {
70747  return function Uint8Array(data, byteOffset, length) {
70748    return init(this, data, byteOffset, length);
70749  };
70750});
70751
70752},{"./_typed-array":"node_modules/core-js/modules/_typed-array.js"}],"node_modules/core-js/modules/es6.typed.uint8-clamped-array.js":[function(require,module,exports) {
70753require('./_typed-array')('Uint8', 1, function (init) {
70754  return function Uint8ClampedArray(data, byteOffset, length) {
70755    return init(this, data, byteOffset, length);
70756  };
70757}, true);
70758
70759},{"./_typed-array":"node_modules/core-js/modules/_typed-array.js"}],"node_modules/core-js/modules/es6.typed.int16-array.js":[function(require,module,exports) {
70760require('./_typed-array')('Int16', 2, function (init) {
70761  return function Int16Array(data, byteOffset, length) {
70762    return init(this, data, byteOffset, length);
70763  };
70764});
70765
70766},{"./_typed-array":"node_modules/core-js/modules/_typed-array.js"}],"node_modules/core-js/modules/es6.typed.uint16-array.js":[function(require,module,exports) {
70767require('./_typed-array')('Uint16', 2, function (init) {
70768  return function Uint16Array(data, byteOffset, length) {
70769    return init(this, data, byteOffset, length);
70770  };
70771});
70772
70773},{"./_typed-array":"node_modules/core-js/modules/_typed-array.js"}],"node_modules/core-js/modules/es6.typed.int32-array.js":[function(require,module,exports) {
70774require('./_typed-array')('Int32', 4, function (init) {
70775  return function Int32Array(data, byteOffset, length) {
70776    return init(this, data, byteOffset, length);
70777  };
70778});
70779
70780},{"./_typed-array":"node_modules/core-js/modules/_typed-array.js"}],"node_modules/core-js/modules/es6.typed.uint32-array.js":[function(require,module,exports) {
70781require('./_typed-array')('Uint32', 4, function (init) {
70782  return function Uint32Array(data, byteOffset, length) {
70783    return init(this, data, byteOffset, length);
70784  };
70785});
70786
70787},{"./_typed-array":"node_modules/core-js/modules/_typed-array.js"}],"node_modules/core-js/modules/es6.typed.float32-array.js":[function(require,module,exports) {
70788require('./_typed-array')('Float32', 4, function (init) {
70789  return function Float32Array(data, byteOffset, length) {
70790    return init(this, data, byteOffset, length);
70791  };
70792});
70793
70794},{"./_typed-array":"node_modules/core-js/modules/_typed-array.js"}],"node_modules/core-js/modules/es6.typed.float64-array.js":[function(require,module,exports) {
70795require('./_typed-array')('Float64', 8, function (init) {
70796  return function Float64Array(data, byteOffset, length) {
70797    return init(this, data, byteOffset, length);
70798  };
70799});
70800
70801},{"./_typed-array":"node_modules/core-js/modules/_typed-array.js"}],"node_modules/core-js/modules/es6.reflect.apply.js":[function(require,module,exports) {
70802// 26.1.1 Reflect.apply(target, thisArgument, argumentsList)
vendor: 4,316 bytes, lines 70803-70888
70803var $export = require('./_export');
70804var aFunction = require('./_a-function');
70805var anObject = require('./_an-object');
70806var rApply = (require('./_global').Reflect || {}).apply;
70807var fApply = Function.apply;
70808// MS Edge argumentsList argument is optional
70809$export($export.S + $export.F * !require('./_fails')(function () {
70810  rApply(function () { /* empty */ });
70811}), 'Reflect', {
70812  apply: function apply(target, thisArgument, argumentsList) {
70813    var T = aFunction(target);
70814    var L = anObject(argumentsList);
70815    return rApply ? rApply(T, thisArgument, L) : fApply.call(T, thisArgument, L);
70816  }
70817});
70818
70819},{"./_export":"node_modules/core-js/modules/_export.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_global":"node_modules/core-js/modules/_global.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.reflect.construct.js":[function(require,module,exports) {
70820// 26.1.2 Reflect.construct(target, argumentsList [, newTarget])
70821var $export = require('./_export');
70822var create = require('./_object-create');
70823var aFunction = require('./_a-function');
70824var anObject = require('./_an-object');
70825var isObject = require('./_is-object');
70826var fails = require('./_fails');
70827var bind = require('./_bind');
70828var rConstruct = (require('./_global').Reflect || {}).construct;
70829
70830// MS Edge supports only 2 arguments and argumentsList argument is optional
70831// FF Nightly sets third argument as `new.target`, but does not create `this` from it
70832var NEW_TARGET_BUG = fails(function () {
70833  function F() { /* empty */ }
70834  return !(rConstruct(function () { /* empty */ }, [], F) instanceof F);
70835});
70836var ARGS_BUG = !fails(function () {
70837  rConstruct(function () { /* empty */ });
70838});
70839
70840$export($export.S + $export.F * (NEW_TARGET_BUG || ARGS_BUG), 'Reflect', {
70841  construct: function construct(Target, args /* , newTarget */) {
70842    aFunction(Target);
70843    anObject(args);
70844    var newTarget = arguments.length < 3 ? Target : aFunction(arguments[2]);
70845    if (ARGS_BUG && !NEW_TARGET_BUG) return rConstruct(Target, args, newTarget);
70846    if (Target == newTarget) {
70847      // w/o altered newTarget, optimization for 0-4 arguments
70848      switch (args.length) {
70849        case 0: return new Target();
70850        case 1: return new Target(args[0]);
70851        case 2: return new Target(args[0], args[1]);
70852        case 3: return new Target(args[0], args[1], args[2]);
70853        case 4: return new Target(args[0], args[1], args[2], args[3]);
70854      }
70855      // w/o altered newTarget, lot of arguments case
70856      var $args = [null];
70857      $args.push.apply($args, args);
70858      return new (bind.apply(Target, $args))();
70859    }
70860    // with altered newTarget, not support built-in constructors
70861    var proto = newTarget.prototype;
70862    var instance = create(isObject(proto) ? proto : Object.prototype);
70863    var result = Function.apply.call(Target, instance, args);
70864    return isObject(result) ? result : instance;
70865  }
70866});
70867
70868},{"./_export":"node_modules/core-js/modules/_export.js","./_object-create":"node_modules/core-js/modules/_object-create.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_fails":"node_modules/core-js/modules/_fails.js","./_bind":"node_modules/core-js/modules/_bind.js","./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/es6.reflect.define-property.js":[function(require,module,exports) {
70869// 26.1.3 Reflect.defineProperty(target, propertyKey, attributes)
70870var dP = require('./_object-dp');
70871var $export = require('./_export');
70872var anObject = require('./_an-object');
70873var toPrimitive = require('./_to-primitive');
70874
70875// MS Edge has broken Reflect.defineProperty - throwing instead of returning false
70876$export($export.S + $export.F * require('./_fails')(function () {
70877  // eslint-disable-next-line no-undef
70878  Reflect.defineProperty(dP.f({}, 1, { value: 1 }), 1, { value: 2 });
70879}), 'Reflect', {
70880  defineProperty: function defineProperty(target, propertyKey, attributes) {
70881    anObject(target);
70882    propertyKey = toPrimitive(propertyKey, true);
70883    anObject(attributes);
70884    try {
70885      dP.f(target, propertyKey, attributes);
70886      return true;
70887    } catch (e) {
70888      return false;
70889    }
70890  }
70891});
70892
70893},{"./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_export":"node_modules/core-js/modules/_export.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js","./_fails":"node_modules/core-js/modules/_fails.js"}],"node_modules/core-js/modules/es6.reflect.delete-property.js":[function(require,module,exports) {
70894// 26.1.4 Reflect.deleteProperty(target, propertyKey)
70895var $export = require('./_export');
70896var gOPD = require('./_object-gopd').f;
70897var anObject = require('./_an-object');
70898
70899$export($export.S, 'Reflect', {
70900  deleteProperty: function deleteProperty(target, propertyKey) {
70901    var desc = gOPD(anObject(target), propertyKey);
70902    return desc && !desc.configurable ? false : delete target[propertyKey];
70903  }
70904});
70905
70906},{"./_export":"node_modules/core-js/modules/_export.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es6.reflect.enumerate.js":[function(require,module,exports) {
70907'use strict';
70908// 26.1.5 Reflect.enumerate(target)
70909var $export = require('./_export');
70910var anObject = require('./_an-object');
70911var Enumerate = function (iterated) {
70912  this._t = anObject(iterated); // target
70913  this._i = 0;                  // next index
70914  var keys = this._k = [];      // keys
70915  var key;
70916  for (key in iterated) keys.push(key);
70917};
70918require('./_iter-create')(Enumerate, 'Object', function () {
70919  var that = this;
70920  var keys = that._k;
70921  var key;
70922  do {
70923    if (that._i >= keys.length) return { value: undefined, done: true };
70924  } while (!((key = keys[that._i++]) in that._t));
70925  return { value: key, done: false };
70926});
70927
70928$export($export.S, 'Reflect', {
70929  enumerate: function enumerate(target) {
70930    return new Enumerate(target);
70931  }
70932});
70933
70934},{"./_export":"node_modules/core-js/modules/_export.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_iter-create":"node_modules/core-js/modules/_iter-create.js"}],"node_modules/core-js/modules/es6.reflect.get.js":[function(require,module,exports) {
70935// 26.1.6 Reflect.get(target, propertyKey [, receiver])
70936var gOPD = require('./_object-gopd');
70937var getPrototypeOf = require('./_object-gpo');
70938var has = require('./_has');
70939var $export = require('./_export');
70940var isObject = require('./_is-object');
70941var anObject = require('./_an-object');
70942
70943function get(target, propertyKey /* , receiver */) {
70944  var receiver = arguments.length < 3 ? target : arguments[2];
70945  var desc, proto;
70946  if (anObject(target) === receiver) return target[propertyKey];
70947  if (desc = gOPD.f(target, propertyKey)) return has(desc, 'value')
70948    ? desc.value
70949    : desc.get !== undefined
70950      ? desc.get.call(receiver)
70951      : undefined;
70952  if (isObject(proto = getPrototypeOf(target))) return get(proto, propertyKey, receiver);
70953}
70954
70955$export($export.S, 'Reflect', { get: get });
70956
70957},{"./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js","./_has":"node_modules/core-js/modules/_has.js","./_export":"node_modules/core-js/modules/_export.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es6.reflect.get-own-property-descriptor.js":[function(require,module,exports) {
70958// 26.1.7 Reflect.getOwnPropertyDescriptor(target, propertyKey)
70959var gOPD = require('./_object-gopd');
70960var $export = require('./_export');
70961var anObject = require('./_an-object');
70962
70963$export($export.S, 'Reflect', {
70964  getOwnPropertyDescriptor: function getOwnPropertyDescriptor(target, propertyKey) {
70965    return gOPD.f(anObject(target), propertyKey);
70966  }
70967});
70968
70969},{"./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_export":"node_modules/core-js/modules/_export.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es6.reflect.get-prototype-of.js":[function(require,module,exports) {
70970// 26.1.8 Reflect.getPrototypeOf(target)
70971var $export = require('./_export');
70972var getProto = require('./_object-gpo');
70973var anObject = require('./_an-object');
70974
70975$export($export.S, 'Reflect', {
70976  getPrototypeOf: function getPrototypeOf(target) {
70977    return getProto(anObject(target));
70978  }
70979});
70980
70981},{"./_export":"node_modules/core-js/modules/_export.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es6.reflect.has.js":[function(require,module,exports) {
70982// 26.1.9 Reflect.has(target, propertyKey)
70983var $export = require('./_export');
70984
70985$export($export.S, 'Reflect', {
70986  has: function has(target, propertyKey) {
70987    return propertyKey in target;
70988  }
70989});
70990
70991},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es6.reflect.is-extensible.js":[function(require,module,exports) {
70992// 26.1.10 Reflect.isExtensible(target)
70993var $export = require('./_export');
70994var anObject = require('./_an-object');
70995var $isExtensible = Object.isExtensible;
70996
70997$export($export.S, 'Reflect', {
70998  isExtensible: function isExtensible(target) {
70999    anObject(target);
71000    return $isExtensible ? $isExtensible(target) : true;
71001  }
71002});
71003
71004},{"./_export":"node_modules/core-js/modules/_export.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/_own-keys.js":[function(require,module,exports) {
71005// all object keys, includes non-enumerable and symbols
71006var gOPN = require('./_object-gopn');
71007var gOPS = require('./_object-gops');
71008var anObject = require('./_an-object');
71009var Reflect = require('./_global').Reflect;
71010module.exports = Reflect && Reflect.ownKeys || function ownKeys(it) {
71011  var keys = gOPN.f(anObject(it));
71012  var getSymbols = gOPS.f;
71013  return getSymbols ? keys.concat(getSymbols(it)) : keys;
71014};
71015
71016},{"./_object-gopn":"node_modules/core-js/modules/_object-gopn.js","./_object-gops":"node_modules/core-js/modules/_object-gops.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/es6.reflect.own-keys.js":[function(require,module,exports) {
71017// 26.1.11 Reflect.ownKeys(target)
71018var $export = require('./_export');
71019
71020$export($export.S, 'Reflect', { ownKeys: require('./_own-keys') });
71021
71022},{"./_export":"node_modules/core-js/modules/_export.js","./_own-keys":"node_modules/core-js/modules/_own-keys.js"}],"node_modules/core-js/modules/es6.reflect.prevent-extensions.js":[function(require,module,exports) {
71023// 26.1.12 Reflect.preventExtensions(target)
71024var $export = require('./_export');
71025var anObject = require('./_an-object');
71026var $preventExtensions = Object.preventExtensions;
71027
71028$export($export.S, 'Reflect', {
71029  preventExtensions: function preventExtensions(target) {
71030    anObject(target);
71031    try {
71032      if ($preventExtensions) $preventExtensions(target);
71033      return true;
71034    } catch (e) {
71035      return false;
71036    }
71037  }
71038});
71039
71040},{"./_export":"node_modules/core-js/modules/_export.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es6.reflect.set.js":[function(require,module,exports) {
71041// 26.1.13 Reflect.set(target, propertyKey, V [, receiver])
71042var dP = require('./_object-dp');
71043var gOPD = require('./_object-gopd');
71044var getPrototypeOf = require('./_object-gpo');
71045var has = require('./_has');
71046var $export = require('./_export');
71047var createDesc = require('./_property-desc');
71048var anObject = require('./_an-object');
71049var isObject = require('./_is-object');
71050
71051function set(target, propertyKey, V /* , receiver */) {
71052  var receiver = arguments.length < 4 ? target : arguments[3];
71053  var ownDesc = gOPD.f(anObject(target), propertyKey);
71054  var existingDescriptor, proto;
71055  if (!ownDesc) {
71056    if (isObject(proto = getPrototypeOf(target))) {
71057      return set(proto, propertyKey, V, receiver);
71058    }
71059    ownDesc = createDesc(0);
71060  }
71061  if (has(ownDesc, 'value')) {
71062    if (ownDesc.writable === false || !isObject(receiver)) return false;
71063    if (existingDescriptor = gOPD.f(receiver, propertyKey)) {
71064      if (existingDescriptor.get || existingDescriptor.set || existingDescriptor.writable === false) return false;
71065      existingDescriptor.value = V;
71066      dP.f(receiver, propertyKey, existingDescriptor);
71067    }
71067 else dP.f(receiver, propertyKey, createDesc(0, V));
71068    return true;
71069  }
71070  return ownDesc.set === undefined ? false : (ownDesc.set.call(receiver, V), true);
71071}
71072
71073$export($export.S, 'Reflect', { set: set });
71074
71075},{"./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js","./_has":"node_modules/core-js/modules/_has.js","./_export":"node_modules/core-js/modules/_export.js","./_property-desc":"node_modules/core-js/modules/_property-desc.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_is-object":"node_modules/core-js/modules/_is-object.js"}],"node_modules/core-js/modules/es6.reflect.set-prototype-of.js":[function(require,module,exports) {
71076// 26.1.14 Reflect.setPrototypeOf(target, proto)
71077var $export = require('./_export');
71078var setProto = require('./_set-proto');
71079
71080if (setProto) $export($export.S, 'Reflect', {
71081  setPrototypeOf: function setPrototypeOf(target, proto) {
71082    setProto.check(target, proto);
71083    try {
71084      setProto.set(target, proto);
71085      return true;
71086    } catch (e) {
71087      return false;
71088    }
71089  }
71090});
71091
71092},{"./_export":"node_modules/core-js/modules/_export.js","./_set-proto":"node_modules/core-js/modules/_set-proto.js"}],"node_modules/core-js/modules/es7.array.includes.js":[function(require,module,exports) {
71093'use strict';
71094// https://github.com/tc39/Array.prototype.includes
71095var $export = require('./_export');
71096var $includes = require('./_array-includes')(true);
71097
71098$export($export.P, 'Array', {
71099  includes: function includes(el /* , fromIndex = 0 */) {
71100    return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
71101  }
71102});
71103
71104require('./_add-to-unscopables')('includes');
71105
71106},{"./_export":"node_modules/core-js/modules/_export.js","./_array-includes":"node_modules/core-js/modules/_array-includes.js","./_add-to-unscopables":"node_modules/core-js/modules/_add-to-unscopables.js"}],"node_modules/core-js/modules/_flatten-into-array.js":[function(require,module,exports) {
71107'use strict';
71108// https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
71109var isArray = require('./_is-array');
71110var isObject = require('./_is-object');
71111var toLength = require('./_to-length');
71112var ctx = require('./_ctx');
71113var IS_CONCAT_SPREADABLE = require('./_wks')('isConcatSpreadable');
71114
71115function flattenIntoArray(target, original, source, sourceLen, start, depth, mapper, thisArg) {
71116  var targetIndex = start;
71117  var sourceIndex = 0;
71118  var mapFn = mapper ? ctx(mapper, thisArg, 3) : false;
71119  var element, spreadable;
71120
71121  while (sourceIndex < sourceLen) {
71122    if (sourceIndex in source) {
71123      element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
71124
71125      spreadable = false;
71126      if (isObject(element)) {
71127        spreadable = element[IS_CONCAT_SPREADABLE];
71128        spreadable = spreadable !== undefined ? !!spreadable : isArray(element);
71129      }
71130
71131      if (spreadable && depth > 0) {
71132        targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;
71133      } else {
71134        if (targetIndex >= 0x1fffffffffffff) throw TypeError();
71135        target[targetIndex] = element;
71136      }
71137
71138      targetIndex++;
71139    }
71140    sourceIndex++;
71141  }
71142  return targetIndex;
71143}
71144
71145module.exports = flattenIntoArray;
71146
71147},{"./_is-array":"node_modules/core-js/modules/_is-array.js","./_is-object":"node_modules/core-js/modules/_is-object.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_ctx":"node_modules/core-js/modules/_ctx.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/modules/es7.array.flat-map.js":[function(require,module,exports) {
71148'use strict';
71149// https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatMap
71150var $export = require('./_export');
71151var flattenIntoArray = require('./_flatten-into-array');
71152var toObject = require('./_to-object');
71153var toLength = require('./_to-length');
71154var aFunction = require('./_a-function');
71155var arraySpeciesCreate = require('./_array-species-create');
71156
71157$export($export.P, 'Array', {
71158  flatMap: function flatMap(callbackfn /* , thisArg */) {
71159    var O = toObject(this);
71160    var sourceLen, A;
71161    aFunction(callbackfn);
71162    sourceLen = toLength(O.length);
71163    A = arraySpeciesCreate(O, 0);
71164    flattenIntoArray(A, O, O, sourceLen, 0, 1, callbackfn, arguments[1]);
71165    return A;
71166  }
71167});
71168
71169require('./_add-to-unscopables')('flatMap');
71170
71171},{"./_export":"node_modules/core-js/modules/_export.js","./_flatten-into-array":"node_modules/core-js/modules/_flatten-into-array.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_array-species-create":"node_modules/core-js/modules/_array-species-create.js","./_add-to-unscopables":"node_modules/core-js/modules/_add-to-unscopables.js"}],"node_modules/core-js/modules/es7.array.flatten.js":[function(require,module,exports) {
71172'use strict';
71173// https://tc39.github.io/proposal-flatMap/#sec-Array.prototype.flatten
71174var $export = require('./_export');
71175var flattenIntoArray = require('./_flatten-into-array');
71176var toObject = require('./_to-object');
71177var toLength = require('./_to-length');
71178var toInteger = require('./_to-integer');
71179var arraySpeciesCreate = require('./_array-species-create');
71180
71181$export($export.P, 'Array', {
71182  flatten: function flatten(/* depthArg = 1 */) {
71183    var depthArg = arguments[0];
71184    var O = toObject(this);
71185    var sourceLen = toLength(O.length);
71186    var A = arraySpeciesCreate(O, 0);
71187    flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toInteger(depthArg));
71188    return A;
71189  }
71190});
71191
71192require('./_add-to-unscopables')('flatten');
71193
71194},{"./_export":"node_modules/core-js/modules/_export.js","./_flatten-into-array":"node_modules/core-js/modules/_flatten-into-array.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_to-integer":"node_modules/core-js/modules/_to-integer.js","./_array-species-create":"node_modules/core-js/modules/_array-species-create.js","./_add-to-unscopables":"node_modules/core-js/modules/_add-to-unscopables.js"}],"node_modules/core-js/modules/es7.string.at.js":[function(require,module,exports) {
71195'use strict';
71196// https://github.com/mathiasbynens/String.prototype.at
71197var $export = require('./_export');
71198var $at = require('./_string-at')(true);
71199
71200$export($export.P, 'String', {
71201  at: function at(pos) {
71202    return $at(this, pos);
71203  }
71204});
71205
71206},{"./_export":"node_modules/core-js/modules/_export.js","./_string-at":"node_modules/core-js/modules/_string-at.js"}],"node_modules/core-js/modules/_string-pad.js":[function(require,module,exports) {
71207// https://github.com/tc39/proposal-string-pad-start-end
71208var toLength = require('./_to-length');
71209var repeat = require('./_string-repeat');
71210var defined = require('./_defined');
71211
71212module.exports = function (that, maxLength, fillString, left) {
71213  var S = String(defined(that));
71214  var stringLength = S.length;
71215  var fillStr = fillString === undefined ? ' ' : String(fillString);
71216  var intMaxLength = toLength(maxLength);
71217  if (intMaxLength <= stringLength || fillStr == '') return S;
71218  var fillLen = intMaxLength - stringLength;
71219  var stringFiller = repeat.call(fillStr, Math.ceil(fillLen / fillStr.length));
71220  if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
71221  return left ? stringFiller + S : S + stringFiller;
71222};
71223
71224},{"./_to-length":"node_modules/core-js/modules/_to-length.js","./_string-repeat":"node_modules/core-js/modules/_string-repeat.js","./_defined":"node_modules/core-js/modules/_defined.js"}],"node_modules/core-js/modules/es7.string.pad-start.js":[function(require,module,exports) {
71225'use strict';
71226// https://github.com/tc39/proposal-string-pad-start-end
71227var $export = require('./_export');
71228var $pad = require('./_string-pad');
71229var userAgent = require('./_user-agent');
71230
71231// https://github.com/zloirock/core-js/issues/280
71232var WEBKIT_BUG = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
71233
71234$export($export.P + $export.F * WEBKIT_BUG, 'String', {
71235  padStart: function padStart(maxLength /* , fillString = ' ' */) {
71236    return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, true);
71237  }
71238});
71239
71240},{"./_export":"node_modules/core-js/modules/_export.js","./_string-pad":"node_modules/core-js/modules/_string-pad.js","./_user-agent":"node_modules/core-js/modules/_user-agent.js"}],"node_modules/core-js/modules/es7.string.pad-end.js":[function(require,module,exports) {
71241'use strict';
71242// https://github.com/tc39/proposal-string-pad-start-end
71243var $export = require('./_export');
71244var $pad = require('./_string-pad');
71245var userAgent = require('./_user-agent');
71246
71247// https://github.com/zloirock/core-js/issues/280
71248var WEBKIT_BUG = /Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(userAgent);
71249
71250$export($export.P + $export.F * WEBKIT_BUG, 'String', {
71251  padEnd: function padEnd(maxLength /* , fillString = ' ' */) {
71252    return $pad(this, maxLength, arguments.length > 1 ? arguments[1] : undefined, false);
71253  }
71254});
71255
71256},{"./_export":"node_modules/core-js/modules/_export.js","./_string-pad":"node_modules/core-js/modules/_string-pad.js","./_user-agent":"node_modules/core-js/modules/_user-agent.js"}],"node_modules/core-js/modules/es7.string.trim-left.js":[function(require,module,exports) {
71257'use strict';
71258// https://github.com/sebmarkbage/ecmascript-string-left-right-trim
71259require('./_string-trim')('trimLeft', function ($trim) {
71260  return function trimLeft() {
71261    return $trim(this, 1);
71262  };
71263}, 'trimStart');
71264
71265},{"./_string-trim":"node_modules/core-js/modules/_string-trim.js"}],"node_modules/core-js/modules/es7.string.trim-right.js":[function(require,module,exports) {
71266'use strict';
71267// https://github.com/sebmarkbage/ecmascript-string-left-right-trim
71268require('./_string-trim')('trimRight', function ($trim) {
71269  return function trimRight() {
71270    return $trim(this, 2);
71271  };
71272}, 'trimEnd');
71273
71274},{"./_string-trim":"node_modules/core-js/modules/_string-trim.js"}],"node_modules/core-js/modules/es7.string.match-all.js":[function(require,module,exports) {
71275'use strict';
71276// https://tc39.github.io/String.prototype.matchAll/
71277var $export = require('./_export');
71278var defined = require('./_defined');
71279var toLength = require('./_to-length');
71280var isRegExp = require('./_is-regexp');
71281var getFlags = require('./_flags');
71282var RegExpProto = RegExp.prototype;
71283
71284var $RegExpStringIterator = function (regexp, string) {
71285  this._r = regexp;
71286  this._s = string;
71287};
71288
71289require('./_iter-create')($RegExpStringIterator, 'RegExp String', function next() {
71290  var match = this._r.exec(this._s);
71291  return { value: match, done: match === null };
71292});
71293
71294$export($export.P, 'String', {
71295  matchAll: function matchAll(regexp) {
71296    defined(this);
71297    if (!isRegExp(regexp)) throw TypeError(regexp + ' is not a regexp!');
71298    var S = String(this);
71299    var flags = 'flags' in RegExpProto ? String(regexp.flags) : getFlags.call(regexp);
71300    var rx = new RegExp(regexp.source, ~flags.indexOf('g') ? flags : 'g' + flags);
71301    rx.lastIndex = toLength(regexp.lastIndex);
71302    return new $RegExpStringIterator(rx, S);
71303  }
71304});
71305
71306},{"./_export":"node_modules/core-js/modules/_export.js","./_defined":"node_modules/core-js/modules/_defined.js","./_to-length":"node_modules/core-js/modules/_to-length.js","./_is-regexp":"node_modules/core-js/modules/_is-regexp.js","./_flags":"node_modules/core-js/modules/_flags.js","./_iter-create":"node_modules/core-js/modules/_iter-create.js"}],"node_modules/core-js/modules/es7.symbol.async-iterator.js":[function(require,module,exports) {
71307require('./_wks-define')('asyncIterator');
71308
71309},{"./_wks-define":"node_modules/core-js/modules/_wks-define.js"}],"node_modules/core-js/modules/es7.symbol.observable.js":[function(require,module,exports) {
71310require('./_wks-define')('observable');
71311
71312},{"./_wks-define":"node_modules/core-js/modules/_wks-define.js"}],"node_modules/core-js/modules/es7.object.get-own-property-descriptors.js":[function(require,module,exports) {
71313// https://github.com/tc39/proposal-object-getownpropertydescriptors
71314var $export = require('./_export');
71315var ownKeys = require('./_own-keys');
71316var toIObject = require('./_to-iobject');
71317var gOPD = require('./_object-gopd');
71318var createProperty = require('./_create-property');
71319
71320$export($export.S, 'Object', {
71321  getOwnPropertyDescriptors: function getOwnPropertyDescriptors(object) {
71322    var O = toIObject(object);
71323    var getDesc = gOPD.f;
71324    var keys = ownKeys(O);
71325    var result = {};
71326    var i = 0;
71327    var key, desc;
71328    while (keys.length > i) {
71329      desc = getDesc(O, key = keys[i++]);
71330      if (desc !== undefined) createProperty(result, key, desc);
71331    }
71332    return result;
71333  }
71334});
71335
71336},{"./_export":"node_modules/core-js/modules/_export.js","./_own-keys":"node_modules/core-js/modules/_own-keys.js","./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_create-property":"node_modules/core-js/modules/_create-property.js"}],"node_modules/core-js/modules/_object-to-array.js":[function(require,module,exports) {
71337var DESCRIPTORS = require('./_descriptors');
71338var getKeys = require('./_object-keys');
71339var toIObject = require('./_to-iobject');
71340var isEnum = require('./_object-pie').f;
71341module.exports = function (isEntries) {
71342  return function (it) {
71343    var O = toIObject(it);
71344    var keys = getKeys(O);
71345    var length = keys.length;
71346    var i = 0;
71347    var result = [];
71348    var key;
71349    while (length > i) {
71350      key = keys[i++];
71351      if (!DESCRIPTORS || isEnum.call(O, key)) {
71352        result.push(isEntries ? [key, O[key]] : O[key]);
71353      }
71354    }
71355    return result;
71356  };
71357};
71358
71359}
vendor: 5,046 bytes, lines 71359-71441
71359,{"./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_object-keys":"node_modules/core-js/modules/_object-keys.js","./_to-iobject":"node_modules/core-js/modules/_to-iobject.js","./_object-pie":"node_modules/core-js/modules/_object-pie.js"}],"node_modules/core-js/modules/es7.object.values.js":[function(require,module,exports) {
71360// https://github.com/tc39/proposal-object-values-entries
71361var $export = require('./_export');
71362var $values = require('./_object-to-array')(false);
71363
71364$export($export.S, 'Object', {
71365  values: function values(it) {
71366    return $values(it);
71367  }
71368});
71369
71370},{"./_export":"node_modules/core-js/modules/_export.js","./_object-to-array":"node_modules/core-js/modules/_object-to-array.js"}],"node_modules/core-js/modules/es7.object.entries.js":[function(require,module,exports) {
71371// https://github.com/tc39/proposal-object-values-entries
71372var $export = require('./_export');
71373var $entries = require('./_object-to-array')(true);
71374
71375$export($export.S, 'Object', {
71376  entries: function entries(it) {
71377    return $entries(it);
71378  }
71379});
71380
71381},{"./_export":"node_modules/core-js/modules/_export.js","./_object-to-array":"node_modules/core-js/modules/_object-to-array.js"}],"node_modules/core-js/modules/_object-forced-pam.js":[function(require,module,exports) {
71382'use strict';
71383// Forced replacement prototype accessors methods
71384module.exports = require('./_library') || !require('./_fails')(function () {
71385  var K = Math.random();
71386  // In FF throws only define methods
71387  // eslint-disable-next-line no-undef, no-useless-call
71388  __defineSetter__.call(null, K, function () { /* empty */ });
71389  delete require('./_global')[K];
71390});
71391
71392},{"./_library":"node_modules/core-js/modules/_library.js","./_fails":"node_modules/core-js/modules/_fails.js","./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/es7.object.define-getter.js":[function(require,module,exports) {
71393'use strict';
71394var $export = require('./_export');
71395var toObject = require('./_to-object');
71396var aFunction = require('./_a-function');
71397var $defineProperty = require('./_object-dp');
71398
71399// B.2.2.2 Object.prototype.__defineGetter__(P, getter)
71400require('./_descriptors') && $export($export.P + require('./_object-forced-pam'), 'Object', {
71401  __defineGetter__: function __defineGetter__(P, getter) {
71402    $defineProperty.f(toObject(this), P, { get: aFunction(getter), enumerable: true, configurable: true });
71403  }
71404});
71405
71406},{"./_export":"node_modules/core-js/modules/_export.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_object-forced-pam":"node_modules/core-js/modules/_object-forced-pam.js"}],"node_modules/core-js/modules/es7.object.define-setter.js":[function(require,module,exports) {
71407'use strict';
71408var $export = require('./_export');
71409var toObject = require('./_to-object');
71410var aFunction = require('./_a-function');
71411var $defineProperty = require('./_object-dp');
71412
71413// B.2.2.3 Object.prototype.__defineSetter__(P, setter)
71414require('./_descriptors') && $export($export.P + require('./_object-forced-pam'), 'Object', {
71415  __defineSetter__: function __defineSetter__(P, setter) {
71416    $defineProperty.f(toObject(this), P, { set: aFunction(setter), enumerable: true, configurable: true });
71417  }
71418});
71419
71420},{"./_export":"node_modules/core-js/modules/_export.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_object-dp":"node_modules/core-js/modules/_object-dp.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_object-forced-pam":"node_modules/core-js/modules/_object-forced-pam.js"}],"node_modules/core-js/modules/es7.object.lookup-getter.js":[function(require,module,exports) {
71421'use strict';
71422var $export = require('./_export');
71423var toObject = require('./_to-object');
71424var toPrimitive = require('./_to-primitive');
71425var getPrototypeOf = require('./_object-gpo');
71426var getOwnPropertyDescriptor = require('./_object-gopd').f;
71427
71428// B.2.2.4 Object.prototype.__lookupGetter__(P)
71429require('./_descriptors') && $export($export.P + require('./_object-forced-pam'), 'Object', {
71430  __lookupGetter__: function __lookupGetter__(P) {
71431    var O = toObject(this);
71432    var K = toPrimitive(P, true);
71433    var D;
71434    do {
71435      if (D = getOwnPropertyDescriptor(O, K)) return D.get;
71436    } while (O = getPrototypeOf(O));
71437  }
71438});
71439
71440},{"./_export":"node_modules/core-js/modules/_export.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_object-forced-pam":"node_modules/core-js/modules/_object-forced-pam.js"}],"node_modules/core-js/modules/es7.object.lookup-setter.js":[function(require,module,exports) {
71441'use strict';
71442var $export = require('./_export');
71443var toObject = require('./_to-object');
71444var toPrimitive = require('./_to-primitive');
71445var getPrototypeOf = require('./_object-gpo');
71446var getOwnPropertyDescriptor = require('./_object-gopd').f;
71447
71448// B.2.2.5 Object.prototype.__lookupSetter__(P)
71449require('./_descriptors') && $export($export.P + require('./_object-forced-pam'), 'Object', {
71450  __lookupSetter__: function __lookupSetter__(P) {
71451    var O = toObject(this);
71452    var K = toPrimitive(P, true);
71453    var D;
71454    do {
71455      if (D = getOwnPropertyDescriptor(O, K)) return D.set;
71456    } while (O = getPrototypeOf(O));
71457  }
71458});
71459
71460},{"./_export":"node_modules/core-js/modules/_export.js","./_to-object":"node_modules/core-js/modules/_to-object.js","./_to-primitive":"node_modules/core-js/modules/_to-primitive.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js","./_object-gopd":"node_modules/core-js/modules/_object-gopd.js","./_descriptors":"node_modules/core-js/modules/_descriptors.js","./_object-forced-pam":"node_modules/core-js/modules/_object-forced-pam.js"}],"node_modules/core-js/modules/_array-from-iterable.js":[function(require,module,exports) {
71461var forOf = require('./_for-of');
71462
71463module.exports = function (iter, ITERATOR) {
71464  var result = [];
71465  forOf(iter, false, result.push, result, ITERATOR);
71466  return result;
71467};
71468
71469},{"./_for-of":"node_modules/core-js/modules/_for-of.js"}],"node_modules/core-js/modules/_collection-to-json.js":[function(require,module,exports) {
71470// https://github.com/DavidBruant/Map-Set.prototype.toJSON
71471var classof = require('./_classof');
71472var from = require('./_array-from-iterable');
71473module.exports = function (NAME) {
71474  return function toJSON() {
71475    if (classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic");
71476    return from(this);
71477  };
71478};
71479
71480},{"./_classof":"node_modules/core-js/modules/_classof.js","./_array-from-iterable":"node_modules/core-js/modules/_array-from-iterable.js"}],"node_modules/core-js/modules/es7.map.to-json.js":[function(require,module,exports) {
71481// https://github.com/DavidBruant/Map-Set.prototype.toJSON
71482var $export = require('./_export');
71483
71484$export($export.P + $export.R, 'Map', { toJSON: require('./_collection-to-json')('Map') });
71485
71486},{"./_export":"node_modules/core-js/modules/_export.js","./_collection-to-json":"node_modules/core-js/modules/_collection-to-json.js"}],"node_modules/core-js/modules/es7.set.to-json.js":[function(require,module,exports) {
71487// https://github.com/DavidBruant/Map-Set.prototype.toJSON
71488var $export = require('./_export');
71489
71490$export($export.P + $export.R, 'Set', { toJSON: require('./_collection-to-json')('Set') });
71491
71492},{"./_export":"node_modules/core-js/modules/_export.js","./_collection-to-json":"node_modules/core-js/modules/_collection-to-json.js"}],"node_modules/core-js/modules/_set-collection-of.js":[function(require,module,exports) {
71493'use strict';
71494// https://tc39.github.io/proposal-setmap-offrom/
71495var $export = require('./_export');
71496
71497module.exports = function (COLLECTION) {
71498  $export($export.S, COLLECTION, { of: function of() {
71499    var length = arguments.length;
71500    var A = new Array(length);
71501    while (length--) A[length] = arguments[length];
71502    return new this(A);
71503  } });
71504};
71505
71506},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.map.of.js":[function(require,module,exports) {
71507// https://tc39.github.io/proposal-setmap-offrom/#sec-map.of
71508require('./_set-collection-of')('Map');
71509
71510},{"./_set-collection-of":"node_modules/core-js/modules/_set-collection-of.js"}],"node_modules/core-js/modules/es7.set.of.js":[function(require,module,exports) {
71511// https://tc39.github.io/proposal-setmap-offrom/#sec-set.of
71512require('./_set-collection-of')('Set');
71513
71514},{"./_set-collection-of":"node_modules/core-js/modules/_set-collection-of.js"}],"node_modules/core-js/modules/es7.weak-map.of.js":[function(require,module,exports) {
71515// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of
71516require('./_set-collection-of')('WeakMap');
71517
71518},{"./_set-collection-of":"node_modules/core-js/modules/_set-collection-of.js"}],"node_modules/core-js/modules/es7.weak-set.of.js":[function(require,module,exports) {
71519// https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.of
71520require('./_set-collection-of')('WeakSet');
71521
71522},{"./_set-collection-of":"node_modules/core-js/modules/_set-collection-of.js"}],"node_modules/core-js/modules/_set-collection-from.js":[function(require,module,exports) {
71523'use strict';
71524// https://tc39.github.io/proposal-setmap-offrom/
71525var $export = require('./_export');
71526var aFunction = require('./_a-function');
71527var ctx = require('./_ctx');
71528var forOf = require('./_for-of');
71529
71530module.exports = function (COLLECTION) {
71531  $export($export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) {
71532    var mapFn = arguments[1];
71533    var mapping, A, n, cb;
71534    aFunction(this);
71535    mapping = mapFn !== undefined;
71536    if (mapping) aFunction(mapFn);
71537    if (source == undefined) return new this();
71538    A = [];
71539    if (mapping) {
71540      n = 0;
71541      cb = ctx(mapFn, arguments[2], 2);
71542      forOf(source, false, function (nextItem) {
71543        A.push(cb(nextItem, n++));
71544      });
71545    } else {
71546      forOf(source, false, A.push, A);
71547    }
71548    return new this(A);
71549  } });
71550};
71551
71552},{"./_export":"node_modules/core-js/modules/_export.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_ctx":"node_modules/core-js/modules/_ctx.js","./_for-of":"node_modules/core-js/modules/_for-of.js"}],"node_modules/core-js/modules/es7.map.from.js":[function(require,module,exports) {
71553// https://tc39.github.io/proposal-setmap-offrom/#sec-map.from
71554require('./_set-collection-from')('Map');
71555
71556},{"./_set-collection-from":"node_modules/core-js/modules/_set-collection-from.js"}],"node_modules/core-js/modules/es7.set.from.js":[function(require,module,exports) {
71557// https://tc39.github.io/proposal-setmap-offrom/#sec-set.from
71558require('./_set-collection-from')('Set');
71559
71560},{"./_set-collection-from":"node_modules/core-js/modules/_set-collection-from.js"}],"node_modules/core-js/modules/es7.weak-map.from.js":[function(require,module,exports) {
71561// https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from
71562require('./_set-collection-from')('WeakMap');
71563
71564},{"./_set-collection-from":"node_modules/core-js/modules/_set-collection-from.js"}],"node_modules/core-js/modules/es7.weak-set.from.js":[function(require,module,exports) {
71565// https://tc39.github.io/proposal-setmap-offrom/#sec-weakset.from
71566require('./_set-collection-from')('WeakSet');
71567
71568},{"./_set-collection-from":"node_modules/core-js/modules/_set-collection-from.js"}],"node_modules/core-js/modules/es7.global.js":[function(require,module,exports) {
71569// https://github.com/tc39/proposal-global
71570var $export = require('./_export');
71571
71572$export($export.G, { global: require('./_global') });
71573
71574},{"./_export":"node_modules/core-js/modules/_export.js","./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/es7.system.global.js":[function(require,module,exports) {
71575// https://github.com/tc39/proposal-global
71576var $export = require('./_export');
71577
71578$export($export.S, 'System', { global: require('./_global') });
71579
71580},{"./_export":"node_modules/core-js/modules/_export.js","./_global":"node_modules/core-js/modules/_global.js"}],"node_modules/core-js/modules/es7.error.is-error.js":[function(require,module,exports) {
71581// https://github.com/ljharb/proposal-is-error
71582var $export = require('./_export');
71583var cof = require('./_cof');
71584
71585$export($export.S, 'Error', {
71586  isError: function isError(it) {
71587    return cof(it) === 'Error';
71588  }
71589});
71590
71591},{"./_export":"node_modules/core-js/modules/_export.js","./_cof":"node_modules/core-js/modules/_cof.js"}],"node_modules/core-js/modules/es7.math.clamp.js":[function(require,module,exports) {
71592// https://rwaldron.github.io/proposal-math-extensions/
71593var $export = require('./_export');
71594
71595$export($export.S, 'Math', {
71596  clamp: function clamp(x, lower, upper) {
71597    return Math.min(upper, Math.max(lower, x));
71598  }
71599});
71600
71601},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.math.deg-per-rad.js":[function(require,module,exports) {
71602// https://rwaldron.github.io/proposal-math-extensions/
71603var $export = require('./_export');
71604
71605$export($export.S, 'Math', { DEG_PER_RAD: Math.PI / 180 });
71606
71607},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.math.degrees.js":[function(require,module,exports) {
71608// https://rwaldron.github.io/proposal-math-extensions/
71609var $export = require('./_export');
71610var RAD_PER_DEG = 180 / Math.PI;
71611
71612$export($export.S, 'Math', {
71613  degrees: function degrees(radians) {
71614    return radians * RAD_PER_DEG;
71615  }
71616});
71617
71618},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/_math-scale.js":[function(require,module,exports) {
71619// https://rwaldron.github.io/proposal-math-extensions/
71620module.exports = Math.scale || function scale(x, inLow, inHigh, outLow, outHigh) {
71621  if (
71622    arguments.length === 0
71623      // eslint-disable-next-line no-self-compare
71624      || x != x
71625      // eslint-disable-next-line no-self-compare
71626      || inLow != inLow
71627      // eslint-disable-next-line no-self-compare
71628      || inHigh != inHigh
71629      // eslint-disable-next-line no-self-compare
71630      || outLow != outLow
71631      // eslint-disable-next-line no-self-compare
71632      || outHigh != outHigh
71633  ) return NaN;
71634  if (x === Infinity || x === -Infinity) return x;
71635  return (x - inLow) * (outHigh - outLow) / (inHigh - inLow) + outLow;
71636};
71637
71638},{}],"node_modules/core-js/modules/es7.math.fscale.js":[function(require,module,exports) {
71639// https://rwaldron.github.io/proposal-math-extensions/
71640var $export = require('./_export');
71641var scale = require('./_math-scale');
71642var fround = require('./_math-fround');
71643
71644$export($export.S, 'Math', {
71645  fscale: function fscale(x, inLow, inHigh, outLow, outHigh) {
71646    return fround(scale(x, inLow, inHigh, outLow, outHigh));
71647  }
71648});
71649
71650},{"./_export":"node_modules/core-js/modules/_export.js","./_math-scale":"node_modules/core-js/modules/_math-scale.js","./_math-fround":"node_modules/core-js/modules/_math-fround.js"}],"node_modules/core-js/modules/es7.math.iaddh.js":[function(require,module,exports) {
71651// https://gist.github.com/BrendanEich/4294d5c212a6d2254703
71652var $export = require('./_export');
71653
71654$export($export.S, 'Math', {
71655  iaddh: function iaddh(x0, x1, y0, y1) {
71656    var $x0 = x0 >>> 0;
71657    var $x1 = x1 >>> 0;
71658    var $y0 = y0 >>> 0;
71659    return $x1 + (y1 >>> 0) + (($x0 & $y0 | ($x0 | $y0) & ~($x0 + $y0 >>> 0)) >>> 31) | 0;
71660  }
71661});
71662
71663},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.math.isubh.js":[function(require,module,exports) {
71664// https://gist.github.com/BrendanEich/4294d5c212a6d2254703
71665var $export = require('./_export');
71666
71667$export($export.S, 'Math', {
71668  isubh: function isubh(x0, x1, y0, y1) {
71669    var $x0 = x0 >>> 0;
71670    var $x1 = x1 >>> 0;
71671    var $y0 = y0 >>> 0;
71672    return $x1 - (y1 >>> 0) - ((~$x0 & $y0 | ~($x0 ^ $y0) & $x0 - $y0 >>> 0) >>> 31) | 0;
71673  }
71674});
71675
71676},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.math.imulh.js":[function(require,module,exports) {
71677// https://gist.github.com/BrendanEich/4294d5c212a6d2254703
71678var $export = require('./_export');
71679
71680$export($export.S, 'Math', {
71681  imulh: function imulh(u, v) {
71682    var UINT16 = 0xffff;
71683    var $u = +u;
71684    var $v = +v;
71685    var u0 = $u & UINT16;
71686    var v0 = $v & UINT16;
71687    var u1 = $u >> 16;
71688    var v1 = $v >> 16;
71689    var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
71690    return u1 * v1 + (t >> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >> 16);
71691  }
71692});
71693
71694},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.math.rad-per-deg.js":[function(require,module,exports) {
71695// https://rwaldron.github.io/proposal-math-extensions/
71696var $export = require('./_export');
71697
71698$export($export.S, 'Math', { RAD_PER_DEG: 180 / Math.PI });
71699
71700},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.math.radians.js":[function(require,module,exports) {
71701// https://rwaldron.github.io/proposal-math-extensions/
71702var $export = require('./_export');
71703var DEG_PER_RAD = Math.PI / 180;
71704
71705$export($export.S, 'Math', {
71706  radians: function radians(degrees) {
71707    return degrees * DEG_PER_RAD;
71708  }
71709});
71710
71711},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.math.scale.js":[function(require,module,exports) {
71712// https://rwaldron.github.io/proposal-math-extensions/
71713var $export = require('./_export');
71714
71715$export($export.S, 'Math', { scale: require('./_math-scale') });
71716
71717},{"./_export":"node_modules/core-js/modules/_export.js","./_math-scale":"node_modules/core-js/modules/_math-scale.js"}],"node_modules/core-js/modules/es7.math.umulh.js":[function(require,module,exports) {
71718// https://gist.github.com/BrendanEich/4294d5c212a6d2254703
71719var $export = require('./_export');
71720
71721$export($export.S, 'Math', {
71722  umulh: function umulh(u, v) {
71723    var UINT16 = 0xffff;
71724    var $u = +u;
71725    var $v = +v;
71726    var u0 = $u & UINT16;
71727    var v0 = $v & UINT16;
71728    var u1 = $u >>> 16;
71729    var v1 = $v >>> 16;
71730    var t = (u1 * v0 >>> 0) + (u0 * v0 >>> 16);
71731    return u1 * v1 + (t >>> 16) + ((u0 * v1 >>> 0) + (t & UINT16) >>> 16);
71732  }
71733});
71734
71735},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.math.signbit.js":[function(require,module,exports) {
71736// http://jfbastien.github.io/papers/Math.signbit.html
71737var $export = require('./_export');
71738
71739$export($export.S, 'Math', { signbit: function signbit(x) {
71740  // eslint-disable-next-line no-self-compare
71741  return (x = +x) != x ? x : x == 0 ? 1 / x == Infinity : x > 0;
71742} });
71743
71744},{"./_export":"node_modules/core-js/modules/_export.js"}],"node_modules/core-js/modules/es7.promise.finally.js":[function(require,module,exports) {
71745
71746// https://github.com/tc39/proposal-promise-finally
71747'use strict';
71748var $export = require('./_export');
71749var core = require('./_core');
71750var global = require('./_global');
71751var speciesConstructor = require('./_species-constructor');
71752var promiseResolve = require('./_promise-resolve');
71753
71754$export($export.P + $export.R, 'Promise', { 'finally': function (onFinally) {
71755  var C = speciesConstructor(this, core.Promise || global.Promise);
71756  var isFunction = typeof onFinally == 'function';
71757  return this.then(
71758    isFunction ? function (x) {
71759      return promiseResolve(C, onFinally()).then(function () { return x; });
71760    } : onFinally,
71761    isFunction ? function (e) {
71762      return promiseResolve(C, onFinally()).then(function () { throw e; });
71763    } : onFinally
71764  );
71765} });
71766
71767},{"./_export":"node_modules/core-js/modules/_export.js","./_core":"node_modules/core-js/modules/_core.js","./_global":"node_modules/core-js/modules/_global.js","./_species-constructor":"node_modules/core-js/modules/_species-constructor.js","./_promise-resolve":"node_modules/core-js/modules/_promise-resolve.js"}],"node_modules/core-js/modules/es7.promise.try.js":[function(require,module,exports) {
71768'use strict';
71769// https://github.com/tc39/proposal-promise-try
71770var $export = require('./_export');
71771var newPromiseCapability = require('./_new-promise-capability');
71772var perform = require('./_perform');
71773
71774$export($export.S, 'Promise', { 'try': function (callbackfn) {
71775  var promiseCapability = newPromiseCapability.f(this);
71776  var result = perform(callbackfn);
71777  (result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
71778  return promiseCapability.promise;
71779} });
71780
71781},{"./_export":"node_modules/core-js/modules/_export.js","./_new-promise-capability":"node_modules/core-js/modules/_new-promise-capability.js","./_perform":"node_modules/core-js/modules/_perform.js"}],"node_modules/core-js/modules/_metadata.js":[function(require,module,exports) {
71782var Map = require('./es6.map');
71783var $export = require('./_export');
71784var shared = require('./_shared')('metadata');
71785var store = shared.store || (shared.store = new (require('./es6.weak-map'))());
71786
71787var getOrCreateMetadataMap = function (target, targetKey, create) {
71788  var targetMetadata = store.get(target);
71789  if (!targetMetadata) {
71790    if (!create) return undefined;
71791    store.set(target, targetMetadata = new Map());
71792  }
71793  var keyMetadata = targetMetadata.get(targetKey);
71794  if (!keyMetadata) {
71795    if (!create) return undefined;
vendor: 7,012 bytes, lines 71796-71933
71796    targetMetadata.set(targetKey, keyMetadata = new Map());
71797  } return keyMetadata;
71798};
71799var ordinaryHasOwnMetadata = function (MetadataKey, O, P) {
71800  var metadataMap = getOrCreateMetadataMap(O, P, false);
71801  return metadataMap === undefined ? false : metadataMap.has(MetadataKey);
71802};
71803var ordinaryGetOwnMetadata = function (MetadataKey, O, P) {
71804  var metadataMap = getOrCreateMetadataMap(O, P, false);
71805  return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey);
71806};
71807var ordinaryDefineOwnMetadata = function (MetadataKey, MetadataValue, O, P) {
71808  getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);
71809};
71810var ordinaryOwnMetadataKeys = function (target, targetKey) {
71811  var metadataMap = getOrCreateMetadataMap(target, targetKey, false);
71812  var keys = [];
71813  if (metadataMap) metadataMap.forEach(function (_, key) { keys.push(key); });
71814  return keys;
71815};
71816var toMetaKey = function (it) {
71817  return it === undefined || typeof it == 'symbol' ? it : String(it);
71818};
71819var exp = function (O) {
71820  $export($export.S, 'Reflect', O);
71821};
71822
71823module.exports = {
71824  store: store,
71825  map: getOrCreateMetadataMap,
71826  has: ordinaryHasOwnMetadata,
71827  get: ordinaryGetOwnMetadata,
71828  set: ordinaryDefineOwnMetadata,
71829  keys: ordinaryOwnMetadataKeys,
71830  key: toMetaKey,
71831  exp: exp
71832};
71833
71834},{"./es6.map":"node_modules/core-js/modules/es6.map.js","./_export":"node_modules/core-js/modules/_export.js","./_shared":"node_modules/core-js/modules/_shared.js","./es6.weak-map":"node_modules/core-js/modules/es6.weak-map.js"}],"node_modules/core-js/modules/es7.reflect.define-metadata.js":[function(require,module,exports) {
71835var metadata = require('./_metadata');
71836var anObject = require('./_an-object');
71837var toMetaKey = metadata.key;
71838var ordinaryDefineOwnMetadata = metadata.set;
71839
71840metadata.exp({ defineMetadata: function defineMetadata(metadataKey, metadataValue, target, targetKey) {
71841  ordinaryDefineOwnMetadata(metadataKey, metadataValue, anObject(target), toMetaKey(targetKey));
71842} });
71843
71844},{"./_metadata":"node_modules/core-js/modules/_metadata.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es7.reflect.delete-metadata.js":[function(require,module,exports) {
71845var metadata = require('./_metadata');
71846var anObject = require('./_an-object');
71847var toMetaKey = metadata.key;
71848var getOrCreateMetadataMap = metadata.map;
71849var store = metadata.store;
71850
71851metadata.exp({ deleteMetadata: function deleteMetadata(metadataKey, target /* , targetKey */) {
71852  var targetKey = arguments.length < 3 ? undefined : toMetaKey(arguments[2]);
71853  var metadataMap = getOrCreateMetadataMap(anObject(target), targetKey, false);
71854  if (metadataMap === undefined || !metadataMap['delete'](metadataKey)) return false;
71855  if (metadataMap.size) return true;
71856  var targetMetadata = store.get(target);
71857  targetMetadata['delete'](targetKey);
71858  return !!targetMetadata.size || store['delete'](target);
71859} });
71860
71861},{"./_metadata":"node_modules/core-js/modules/_metadata.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es7.reflect.get-metadata.js":[function(require,module,exports) {
71862var metadata = require('./_metadata');
71863var anObject = require('./_an-object');
71864var getPrototypeOf = require('./_object-gpo');
71865var ordinaryHasOwnMetadata = metadata.has;
71866var ordinaryGetOwnMetadata = metadata.get;
71867var toMetaKey = metadata.key;
71868
71869var ordinaryGetMetadata = function (MetadataKey, O, P) {
71870  var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
71871  if (hasOwn) return ordinaryGetOwnMetadata(MetadataKey, O, P);
71872  var parent = getPrototypeOf(O);
71873  return parent !== null ? ordinaryGetMetadata(MetadataKey, parent, P) : undefined;
71874};
71875
71876metadata.exp({ getMetadata: function getMetadata(metadataKey, target /* , targetKey */) {
71877  return ordinaryGetMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
71878} });
71879
71880},{"./_metadata":"node_modules/core-js/modules/_metadata.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js"}],"node_modules/core-js/modules/es7.reflect.get-metadata-keys.js":[function(require,module,exports) {
71881var Set = require('./es6.set');
71882var from = require('./_array-from-iterable');
71883var metadata = require('./_metadata');
71884var anObject = require('./_an-object');
71885var getPrototypeOf = require('./_object-gpo');
71886var ordinaryOwnMetadataKeys = metadata.keys;
71887var toMetaKey = metadata.key;
71888
71889var ordinaryMetadataKeys = function (O, P) {
71890  var oKeys = ordinaryOwnMetadataKeys(O, P);
71891  var parent = getPrototypeOf(O);
71892  if (parent === null) return oKeys;
71893  var pKeys = ordinaryMetadataKeys(parent, P);
71894  return pKeys.length ? oKeys.length ? from(new Set(oKeys.concat(pKeys))) : pKeys : oKeys;
71895};
71896
71897metadata.exp({ getMetadataKeys: function getMetadataKeys(target /* , targetKey */) {
71898  return ordinaryMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
71899} });
71900
71901},{"./es6.set":"node_modules/core-js/modules/es6.set.js","./_array-from-iterable":"node_modules/core-js/modules/_array-from-iterable.js","./_metadata":"node_modules/core-js/modules/_metadata.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js"}],"node_modules/core-js/modules/es7.reflect.get-own-metadata.js":[function(require,module,exports) {
71902var metadata = require('./_metadata');
71903var anObject = require('./_an-object');
71904var ordinaryGetOwnMetadata = metadata.get;
71905var toMetaKey = metadata.key;
71906
71907metadata.exp({ getOwnMetadata: function getOwnMetadata(metadataKey, target /* , targetKey */) {
71908  return ordinaryGetOwnMetadata(metadataKey, anObject(target)
71909    , arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
71910} });
71911
71912},{"./_metadata":"node_modules/core-js/modules/_metadata.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es7.reflect.get-own-metadata-keys.js":[function(require,module,exports) {
71913var metadata = require('./_metadata');
71914var anObject = require('./_an-object');
71915var ordinaryOwnMetadataKeys = metadata.keys;
71916var toMetaKey = metadata.key;
71917
71918metadata.exp({ getOwnMetadataKeys: function getOwnMetadataKeys(target /* , targetKey */) {
71919  return ordinaryOwnMetadataKeys(anObject(target), arguments.length < 2 ? undefined : toMetaKey(arguments[1]));
71920} });
71921
71922},{"./_metadata":"node_modules/core-js/modules/_metadata.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es7.reflect.has-metadata.js":[function(require,module,exports) {
71923var metadata = require('./_metadata');
71924var anObject = require('./_an-object');
71925var getPrototypeOf = require('./_object-gpo');
71926var ordinaryHasOwnMetadata = metadata.has;
71927var toMetaKey = metadata.key;
71928
71929var ordinaryHasMetadata = function (MetadataKey, O, P) {
71930  var hasOwn = ordinaryHasOwnMetadata(MetadataKey, O, P);
71931  if (hasOwn) return true;
71932  var parent = getPrototypeOf(O);
71933  return parent !== null ? ordinaryHasMetadata(MetadataKey, parent, P) : false;
vendor: 9,004 bytes, lines 71934-72188
71934};
71935
71936metadata.exp({ hasMetadata: function hasMetadata(metadataKey, target /* , targetKey */) {
71937  return ordinaryHasMetadata(metadataKey, anObject(target), arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
71938} });
71939
71940},{"./_metadata":"node_modules/core-js/modules/_metadata.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_object-gpo":"node_modules/core-js/modules/_object-gpo.js"}],"node_modules/core-js/modules/es7.reflect.has-own-metadata.js":[function(require,module,exports) {
71941var metadata = require('./_metadata');
71942var anObject = require('./_an-object');
71943var ordinaryHasOwnMetadata = metadata.has;
71944var toMetaKey = metadata.key;
71945
71946metadata.exp({ hasOwnMetadata: function hasOwnMetadata(metadataKey, target /* , targetKey */) {
71947  return ordinaryHasOwnMetadata(metadataKey, anObject(target)
71948    , arguments.length < 3 ? undefined : toMetaKey(arguments[2]));
71949} });
71950
71951},{"./_metadata":"node_modules/core-js/modules/_metadata.js","./_an-object":"node_modules/core-js/modules/_an-object.js"}],"node_modules/core-js/modules/es7.reflect.metadata.js":[function(require,module,exports) {
71952var $metadata = require('./_metadata');
71953var anObject = require('./_an-object');
71954var aFunction = require('./_a-function');
71955var toMetaKey = $metadata.key;
71956var ordinaryDefineOwnMetadata = $metadata.set;
71957
71958$metadata.exp({ metadata: function metadata(metadataKey, metadataValue) {
71959  return function decorator(target, targetKey) {
71960    ordinaryDefineOwnMetadata(
71961      metadataKey, metadataValue,
71962      (targetKey !== undefined ? anObject : aFunction)(target),
71963      toMetaKey(targetKey)
71964    );
71965  };
71966} });
71967
71968},{"./_metadata":"node_modules/core-js/modules/_metadata.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_a-function":"node_modules/core-js/modules/_a-function.js"}],"node_modules/core-js/modules/es7.asap.js":[function(require,module,exports) {
71969
71970// https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-09/sept-25.md#510-globalasap-for-enqueuing-a-microtask
71971var $export = require('./_export');
71972var microtask = require('./_microtask')();
71973var process = require('./_global').process;
71974var isNode = require('./_cof')(process) == 'process';
71975
71976$export($export.G, {
71977  asap: function asap(fn) {
71978    var domain = isNode && process.domain;
71979    microtask(domain ? domain.bind(fn) : fn);
71980  }
71981});
71982
71983},{"./_export":"node_modules/core-js/modules/_export.js","./_microtask":"node_modules/core-js/modules/_microtask.js","./_global":"node_modules/core-js/modules/_global.js","./_cof":"node_modules/core-js/modules/_cof.js"}],"node_modules/core-js/modules/es7.observable.js":[function(require,module,exports) {
71984
71985'use strict';
71986// https://github.com/zenparsing/es-observable
71987var $export = require('./_export');
71988var global = require('./_global');
71989var core = require('./_core');
71990var microtask = require('./_microtask')();
71991var OBSERVABLE = require('./_wks')('observable');
71992var aFunction = require('./_a-function');
71993var anObject = require('./_an-object');
71994var anInstance = require('./_an-instance');
71995var redefineAll = require('./_redefine-all');
71996var hide = require('./_hide');
71997var forOf = require('./_for-of');
71998var RETURN = forOf.RETURN;
71999
72000var getMethod = function (fn) {
72001  return fn == null ? undefined : aFunction(fn);
72002};
72003
72004var cleanupSubscription = function (subscription) {
72005  var cleanup = subscription._c;
72006  if (cleanup) {
72007    subscription._c = undefined;
72008    cleanup();
72009  }
72010};
72011
72012var subscriptionClosed = function (subscription) {
72013  return subscription._o === undefined;
72014};
72015
72016var closeSubscription = function (subscription) {
72017  if (!subscriptionClosed(subscription)) {
72018    subscription._o = undefined;
72019    cleanupSubscription(subscription);
72020  }
72021};
72022
72023var Subscription = function (observer, subscriber) {
72024  anObject(observer);
72025  this._c = undefined;
72026  this._o = observer;
72027  observer = new SubscriptionObserver(this);
72028  try {
72029    var cleanup = subscriber(observer);
72030    var subscription = cleanup;
72031    if (cleanup != null) {
72032      if (typeof cleanup.unsubscribe === 'function') cleanup = function () { subscription.unsubscribe(); };
72033      else aFunction(cleanup);
72034      this._c = cleanup;
72035    }
72036  } catch (e) {
72037    observer.error(e);
72038    return;
72039  } if (subscriptionClosed(this)) cleanupSubscription(this);
72040};
72041
72042Subscription.prototype = redefineAll({}, {
72043  unsubscribe: function unsubscribe() { closeSubscription(this); }
72044});
72045
72046var SubscriptionObserver = function (subscription) {
72047  this._s = subscription;
72048};
72049
72050SubscriptionObserver.prototype = redefineAll({}, {
72051  next: function next(value) {
72052    var subscription = this._s;
72053    if (!subscriptionClosed(subscription)) {
72054      var observer = subscription._o;
72055      try {
72056        var m = getMethod(observer.next);
72057        if (m) return m.call(observer, value);
72058      } catch (e) {
72059        try {
72060          closeSubscription(subscription);
72061        } finally {
72062          throw e;
72063        }
72064      }
72065    }
72066  },
72067  error: function error(value) {
72068    var subscription = this._s;
72069    if (subscriptionClosed(subscription)) throw value;
72070    var observer = subscription._o;
72071    subscription._o = undefined;
72072    try {
72073      var m = getMethod(observer.error);
72074      if (!m) throw value;
72075      value = m.call(observer, value);
72076    } catch (e) {
72077      try {
72078        cleanupSubscription(subscription);
72079      } finally {
72080        throw e;
72081      }
72082    } cleanupSubscription(subscription);
72083    return value;
72084  },
72085  complete: function complete(value) {
72086    var subscription = this._s;
72087    if (!subscriptionClosed(subscription)) {
72088      var observer = subscription._o;
72089      subscription._o = undefined;
72090      try {
72091        var m = getMethod(observer.complete);
72092        value = m ? m.call(observer, value) : undefined;
72093      } catch (e) {
72094        try {
72095          cleanupSubscription(subscription);
72096        } finally {
72097          throw e;
72098        }
72099      } cleanupSubscription(subscription);
72100      return value;
72101    }
72102  }
72103});
72104
72105var $Observable = function Observable(subscriber) {
72106  anInstance(this, $Observable, 'Observable', '_f')._f = aFunction(subscriber);
72107};
72108
72109redefineAll($Observable.prototype, {
72110  subscribe: function subscribe(observer) {
72111    return new Subscription(observer, this._f);
72112  },
72113  forEach: function forEach(fn) {
72114    var that = this;
72115    return new (core.Promise || global.Promise)(function (resolve, reject) {
72116      aFunction(fn);
72117      var subscription = that.subscribe({
72118        next: function (value) {
72119          try {
72120            return fn(value);
72121          } catch (e) {
72122            reject(e);
72123            subscription.unsubscribe();
72124          }
72125        },
72126        error: reject,
72127        complete: resolve
72128      });
72129    });
72130  }
72131});
72132
72133redefineAll($Observable, {
72134  from: function from(x) {
72135    var C = typeof this === 'function' ? this : $Observable;
72136    var method = getMethod(anObject(x)[OBSERVABLE]);
72137    if (method) {
72138      var observable = anObject(method.call(x));
72139      return observable.constructor === C ? observable : new C(function (observer) {
72140        return observable.subscribe(observer);
72141      });
72142    }
72143    return new C(function (observer) {
72144      var done = false;
72145      microtask(function () {
72146        if (!done) {
72147          try {
72148            if (forOf(x, false, function (it) {
72149              observer.next(it);
72150              if (done) return RETURN;
72151            }) === RETURN) return;
72152          } catch (e) {
72153            if (done) throw e;
72154            observer.error(e);
72155            return;
72156          } observer.complete();
72157        }
72158      });
72159      return function () { done = true; };
72160    });
72161  },
72162  of: function of() {
72163    for (var i = 0, l = arguments.length, items = new Array(l); i < l;) items[i] = arguments[i++];
72164    return new (typeof this === 'function' ? this : $Observable)(function (observer) {
72165      var done = false;
72166      microtask(function () {
72167        if (!done) {
72168          for (var j = 0; j < items.length; ++j) {
72169            observer.next(items[j]);
72170            if (done) return;
72171          } observer.complete();
72172        }
72173      });
72174      return function () { done = true; };
72175    });
72176  }
72177});
72178
72179hide($Observable.prototype, OBSERVABLE, function () { return this; });
72180
72181$export($export.G, { Observable: $Observable });
72182
72183require('./_set-species')('Observable');
72184
72185},{"./_export":"node_modules/core-js/modules/_export.js","./_global":"node_modules/core-js/modules/_global.js","./_core":"node_modules/core-js/modules/_core.js","./_microtask":"node_modules/core-js/modules/_microtask.js","./_wks":"node_modules/core-js/modules/_wks.js","./_a-function":"node_modules/core-js/modules/_a-function.js","./_an-object":"node_modules/core-js/modules/_an-object.js","./_an-instance":"node_modules/core-js/modules/_an-instance.js","./_redefine-all":"node_modules/core-js/modules/_redefine-all.js","./_hide":"node_modules/core-js/modules/_hide.js","./_for-of":"node_modules/core-js/modules/_for-of.js","./_set-species":"node_modules/core-js/modules/_set-species.js"}],"node_modules/core-js/modules/web.timers.js":[function(require,module,exports) {
72186
72187// ie9- setTimeout & setInterval additional parameters fix
72188var global = require('./_global');
72189var $export = require('./_export');
72190var userAgent = require('./_user-agent');
72191var slice = [].slice;
72192var MSIE = /MSIE .\./.test(userAgent); // <- dirty ie9- check
72193var wrap = function (set) {
72194  return function (fn, time /* , ...args */) {
72195    var boundArgs = arguments.length > 2;
72196    var args = boundArgs ? slice.call(arguments, 2) : false;
72197    return set(boundArgs ? function () {
72198      // eslint-disable-next-line no-new-func
72199      (typeof fn == 'function' ? fn : Function(fn)).apply(this, args);
72200    } : fn, time);
72201  };
72202};
72203$export($export.G + $export.B + $export.F * MSIE, {
72204  setTimeout: wrap(global.setTimeout),
72205  setInterval: wrap(global.setInterval)
72206});
72207
72208},{"./_global":"node_modules/core-js/modules/_global.js","./_export":"node_modules/core-js/modules/_export.js","./_user-agent":"node_modules/core-js/modules/_user-agent.js"}],"node_modules/core-js/modules/web.immediate.js":[function(require,module,exports) {
72209var $export = require('./_export');
72210var $task = require('./_task');
72211$export($export.G + $export.B, {
72212  setImmediate: $task.set,
72213  clearImmediate: $task.clear
72214});
72215
72216},{"./_export":"node_modules/core-js/modules/_export.js","./_task":"node_modules/core-js/modules/_task.js"}],"node_modules/core-js/modules/web.dom.iterable.js":[function(require,module,exports) {
72217
72218var $iterators = require('./es6.array.iterator');
72219var getKeys = require('./_object-keys');
72220var redefine = require('./_redefine');
72221var global = require('./_global');
72222var hide = require('./_hide');
72223var Iterators = require('./_iterators');
72224var wks = require('./_wks');
72225var ITERATOR = wks('iterator');
72226var TO_STRING_TAG = wks('toStringTag');
72227var ArrayValues = Iterators.Array;
72228
72229var DOMIterables = {
72230  CSSRuleList: true, // TODO: Not spec compliant, should be false.
72231  CSSStyleDeclaration: false,
72232  CSSValueList: false,
72233  ClientRectList: false,
72234  DOMRectList: false,
72235  DOMStringList: false,
72236  DOMTokenList: true,
72237  DataTransferItemList: false,
72238  FileList: false,
72239  HTMLAllCollection: false,
72240  HTMLCollection: false,
72241  HTMLFormElement: false,
72242  HTMLSelectElement: false,
72243  MediaList: true, // TODO: Not spec compliant, should be false.
72244  MimeTypeArray: false,
72245  NamedNodeMap: false,
72246  NodeList: true,
72247  PaintRequestList: false,
72248  Plugin: false,
72249  PluginArray: false,
72250  SVGLengthList: false,
72251  SVGNumberList: false,
72252  SVGPathSegList: false,
72253  SVGPointList: false,
72254  SVGStringList: false,
72255  SVGTransformList: false,
72256  SourceBufferList: false,
72257  StyleSheetList: true, // TODO: Not spec compliant, should be false.
72258  TextTrackCueList: false,
72259  TextTrackList: false,
72260  TouchList: false
72261};
72262
72263for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) {
72264  var NAME = collections[i];
72265  var explicit = DOMIterables[NAME];
72266  var Collection = global[NAME];
72267  var proto = Collection && Collection.prototype;
72268  var key;
72269  if (proto) {
72270    if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues);
72271    if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME);
72272    Iterators[NAME] = ArrayValues;
72273    if (explicit) for (key in $iterators) if (!proto[key]) redefine(proto, key, $iterators[key], true);
72274  }
72275}
72276
72277},{"./es6.array.iterator":"node_modules/core-js/modules/es6.array.iterator.js","./_object-keys":"node_modules/core-js/modules/_object-keys.js","./_redefine":"node_modules/core-js/modules/_redefine.js","./_global":"node_modules/core-js/modules/_global.js","./_hide":"node_modules/core-js/modules/_hide.js","./_iterators":"node_modules/core-js/modules/_iterators.js","./_wks":"node_modules/core-js/modules/_wks.js"}],"node_modules/core-js/shim.js":[function(require,module,exports) {
72278require('./modules/es6.symbol');
72279require('./modules/es6.object.create');
72280require('./modules/es6.object.define-property');
72281require('./modules/es6.object.define-properties');
72282require('./modules/es6.object.get-own-property-descriptor');
72283require('./modules/es6.object.get-prototype-of');
72284require('./modules/es6.object.keys');
72285require('./modules/es6.object.get-own-property-names');
72286require('./modules/es6.object.freeze');
72287require('./modules/es6.object.seal');
72288require('./modules/es6.object.prevent-extensions');
72289require('./modules/es6.object.is-frozen');
72290require('./modules/es6.object.is-sealed');
72291require('./modules/es6.object.is-extensible');
72292require('./modules/es6.object.assign');
72293require('./modules/es6.object.is');
72294require('./modules/es6.object.set-prototype-of');
72295require('./modules/es6.object.to-string');
72296require('./modules/es6.function.bind');
72297require('./modules/es6.function.name');
72298require('./modules/es6.function.has-instance');
72299require('./modules/es6.parse-int');
72300require('./modules/es6.parse-float');
72301require('./modules/es6.number.constructor');
72302require('./modules/es6.number.to-fixed');
72303require('./modules/es6.number.to-precision');
72304require('./modules/es6.number.epsilon');
72305require('./modules/es6.number.is-finite');
72306require('./modules/es6.number.is-integer');
72307require('./modules/es6.number.is-nan');
72308require('./modules/es6.number.is-safe-integer');
72309require('./modules/es6.number.max-safe-integer');
72310require('./modules/es6.number.min-safe-integer');
72311require('./modules/es6.number.parse-float');
72312require('./modules/es6.number.parse-int');
72313require('./modules/es6.math.acosh');
72314require('./modules/es6.math.asinh');
72315require('./modules/es6.math.atanh');
72316require('./modules/es6.math.cbrt');
72317require('./modules/es6.math.clz32');
72318require('./modules/es6.math.cosh');
72319require('./modules/es6.math.expm1');
72320require('./modules/es6.math.fround');
72321require('./modules/es6.math.hypot');
72322require('./modules/es6.math.imul');
72323require('./modules/es6.math.log10');
72324require('./modules/es6.math.log1p');
72325require('./modules/es6.math.log2');
72326require('./modules/es6.math.sign');
72327require('./modules/es6.math.sinh');
72328require('./modules/es6.math.tanh');
72329require('./modules/es6.math.trunc');
72330require('./modules/es6.string.from-code-point');
72331require('./modules/es6.string.raw');
72332require('./modules/es6.string.trim');
72333require('./modules/es6.string.iterator');
72334require('./modules/es6.string.code-point-at');
72335require('./modules/es6.string.ends-with');
72336require('./modules/es6.string.includes');
72337require('./modules/es6.string.repeat');
72338require('./modules/es6.string.starts-with');
72339require('./modules/es6.string.anchor');
72340require('./modules/es6.string.big');
72341require('./modules/es6.string.blink');
72342require('./modules/es6.string.bold');
72343require('./modules/es6.string.fixed');
72344require('./modules/es6.string.fontcolor');
72345require('./modules/es6.string.fontsize');
72346require('./modules/es6.string.italics');
72347require('./modules/es6.string.link');
72348require('./modules/es6.string.small');
72349require('./modules/es6.string.strike');
72350require('./modules/es6.string.sub');
72351require('./modules/es6.string.sup');
72352require('./modules/es6.date.now');
72353require('./modules/es6.date.to-json');
72354require('./modules/es6.date.to-iso-string');
72355require('./modules/es6.date.to-string');
72356require('./modules/es6.date.to-primitive');
72357require('./modules/es6.array.is-array');
72358require('./modules/es6.array.from');
72359require('./modules/es6.array.of');
72360require('./modules/es6.array.join');
72361require('./modules/es6.array.slice');
72362require('./modules/es6.array.sort');
72363require('./modules/es6.array.for-each');
72364require('./modules/es6.array.map');
72365require('./modules/es6.array.filter');
72366require('./modules/es6.array.some');
72367require('./modules/es6.array.every');
72368require('./modules/es6.array.reduce');
72369require('./modules/es6.array.reduce-right');
72370require('./modules/es6.array.index-of');
72371require('./modules/es6.array.last-index-of');
72372require('./modules/es6.array.copy-within');
72373require('./modules/es6.array.fill');
72374require('./modules/es6.array.find');
72375require('./modules/es6.array.find-index');
72376require('./modules/es6.array.species');
72377require('./modules/es6.array.iterator');
72378require('./modules/es6.regexp.constructor');
72379require('./modules/es6.regexp.exec');
72380require('./modules/es6.regexp.to-string');
72381require('./modules/es6.regexp.flags');
72382require('./modules/es6.regexp.match');
72383require('./modules/es6.regexp.replace');
72384require('./modules/es6.regexp.search');
72385require('./modules/es6.regexp.split');
72386require('./modules/es6.promise');
72387require('./modules/es6.map');
72388require('./modules/es6.set');
72389require('./modules/es6.weak-map');
72390require('./modules/es6.weak-set');
72391require('./modules/es6.typed.array-buffer');
72392require('./modules/es6.typed.data-view');
72393require('./modules/es6.typed.int8-array');
72394require('./modules/es6.typed.uint8-array');
72395require('./modules/es6.typed.uint8-clamped-array');
72396require('./modules/es6.typed.int16-array');
72397require('./modules/es6.typed.uint16-array');
72398require('./modules/es6.typed.int32-array');
72399require('./modules/es6.typed.uint32-array');
72400require('./modules/es6.typed.float32-array');
72401require('./modules/es6.typed.float64-array');
72402require('./modules/es6.reflect.apply');
72403require('./modules/es6.reflect.construct');
72404require('./modules/es6.reflect.define-property');
72405require('./modules/es6.reflect.delete-property');
72406require('./modules/es6.reflect.enumerate');
72407require('./modules/es6.reflect.get');
72408require('./modules/es6.reflect.get-own-property-descriptor');
72409require('./modules/es6.reflect.get-prototype-of');
72410require('./modules/es6.reflect.has');
72411require('./modules/es6.reflect.is-extensible');
72412require('./modules/es6.reflect.own-keys');
72413require('./modules/es6.reflect.prevent-extensions');
72414require('./modules/es6.reflect.set');
72415require('./modules/es6.reflect.set-prototype-of');
72416require('./modules/es7.array.includes');
72417require('./modules/es7.array.flat-map');
72418require('./modules/es7.array.flatten');
72419require('./modules/es7.string.at');
72420require('./modules/es7.string.pad-start');
72421require('./modules/es7.string.pad-end');
72422require('./modules/es7.string.trim-left');
72423require('./modules/es7.string.trim-right');
72424require('./modules/es7.string.match-all');
72425require('./modules/es7.symbol.async-iterator');
72426require('./modules/es7.symbol.observable');
72427require('./modules/es7.object.get-own-property-descriptors');
72428require('./modules/es7.object.values');
72429require('./modules/es7.object.entries');
72430require('./modules/es7.object.define-getter');
72431require('./modules/es7.object.define-setter');
72432require('./modules/es7.object.lookup-getter');
72433require('./modules/es7.object.lookup-setter');
72434require('./modules/es7.map.to-json');
72435require('./modules/es7.set.to-json');
72436require('./modules/es7.map.of');
72437require('./modules/es7.set.of');
72438require('./modules/es7.weak-map.of');
72439require('./modules/es7.weak-set.of');
72440require('./modules/es7.map.from');
72441require('./modules/es7.set.from');
72442require('./modules/es7.weak-map.from');
72443require('./modules/es7.weak-set.from');
72444require('./modules/es7.global');
72445require('./modules/es7.system.global');
72446require('./modules/es7.error.is-error');
72447require('./modules/es7.math.clamp');
72448require('./modules/es7.math.deg-per-rad');
72449require('./modules/es7.math.degrees');
72450require('./modules/es7.math.fscale');
72451require('./modules/es7.math.iaddh');
72452require('./modules/es7.math.isubh');
72453require('./modules/es7.math.imulh');
72454require('./modules/es7.math.rad-per-deg');
72455require('./modules/es7.math.radians');
72456require('./modules/es7.math.scale');
72457require('./modules/es7.math.umulh');
72458require('./modules/es7.math.signbit');
72459require('./modules/es7.promise.finally');
72460require('./modules/es7.promise.try');
72461require('./modules/es7.reflect.define-metadata');
72462require('./modules/es7.reflect.delete-metadata');
72463require('./modules/es7.reflect.get-metadata');
72464require('./modules/es7.reflect.get-metadata-keys');
72465require('./modules/es7.reflect.get-own-metadata');
72466require('./modules/es7.reflect.get-own-metadata-keys');
72467require('./modules/es7.reflect.has-metadata');
72468require('./modules/es7.reflect.has-own-metadata');
72469require('./modules/es7.reflect.metadata');
72470require('./modules/es7.asap');
72471require('./modules/es7.observable');
72472require('./modules/web.timers');
72473require('./modules/web.immediate');
72474require('./modules/web.dom.iterable');
72475module.exports = require('./modules/_core');
72476
72477},{"./modules/es6.symbol":"node_modules/core-js/modules/es6.symbol.js","./modules/es6.object.create":"node_modules/core-js/modules/es6.object.create.js","./modules/es6.object.define-property":"node_modules/core-js/modules/es6.object.define-property.js","./modules/es6.object.define-properties":"node_modules/core-js/modules/es6.object.define-properties.js","./modules/es6.object.get-own-property-descriptor":"node_modules/core-js/modules/es6.object.get-own-property-descriptor.js","./modules/es6.object.get-prototype-of":"node_modules/core-js/modules/es6.object.get-prototype-of.js","./modules/es6.object.keys":"node_modules/core-js/modules/es6.object.keys.js","./modules/es6.object.get-own-property-names":"node_modules/core-js/modules/es6.object.get-own-property-names.js","./modules/es6.object.freeze":"node_modules/core-js/modules/es6.object.freeze.js","./modules/es6.object.seal":"node_modules/core-js/modules/es6.object.seal.js","./modules/es6.object.prevent-extensions":"node_modules/core-js/modules/es6.object.prevent-extensions.js","./modules/es6.object.is-frozen":"node_modules/core-js/modules/es6.object.is-frozen.js","./modules/es6.object.is-sealed":"node_modules/core-js/modules/es6.object.is-sealed.js","./modules/es6.object.is-extensible":"node_modules/core-js/modules/es6.object.is-extensible.js","./modules/es6.object.assign":"node_modules/core-js/modules/es6.object.assign.js","./modules/es6.object.is":"node_modules/core-js/modules/es6.object.is.js","./modules/es6.object.set-prototype-of":"node_modules/core-js/modules/es6.object.set-prototype-of.js","./modules/es6.object.to-string":"node_modules/core-js/modules/es6.object.to-string.js","./modules/es6.function.bind":"node_modules/core-js/modules/es6.function.bind.js","./modules/es6.function.name":"node_modules/core-js/modules/es6.function.name.js","./modules/es6.function.has-instance":"node_modules/core-js/modules/es6.function.has-instance.js","./modules/es6.parse-int":"node_modules/core-js/modules/es6.parse-int.js","./modules/es6.parse-float":"node_modules/core-js/modules/es6.parse-float.js","./modules/es6.number.constructor":"node_modules/core-js/modules/es6.number.constructor.js","./modules/es6.number.to-fixed":"node_modules/core-js/modules/es6.number.to-fixed.js","./modules/es6.number.to-precision":"node_modules/core-js/modules/es6.number.to-precision.js","./modules/es6.number.epsilon":"node_modules/core-js/modules/es6.number.epsilon.js","./modules/es6.number.is-finite":"node_modules/core-js/modules/es6.number.is-finite.js","./modules/es6.number.is-integer":"node_modules/core-js/modules/es6.number.is-integer.js","./modules/es6.number.is-nan":"node_modules/core-js/modules/es6.number.is-nan.js","./modules/es6.number.is-safe-integer":"node_modules/core-js/modules/es6.number.is-safe-integer.js","./modules/es6.number.max-safe-integer":"node_modules/core-js/modules/es6.number.max-safe-integer.js","./modules/es6.number.min-safe-integer":"node_modules/core-js/modules/es6.number.min-safe-integer.js","./modules/es6.number.parse-float":"node_modules/core-js/modules/es6.number.parse-float.js","./modules/es6.number.parse-int":"node_modules/core-js/modules/es6.number.parse-int.js","./modules/es6.math.acosh":"node_modules/core-js/modules/es6.math.acosh.js","./modules/es6.math.asinh":"node_modules/core-js/modules/es6.math.asinh.js","./modules/es6.math.atanh":"node_modules/core-js/modules/es6.math.atanh.js","./modules/es6.math.cbrt":"node_modules/core-js/modules/es6.math.cbrt.js","./modules/es6.math.clz32":"node_modules/core-js/modules/es6.math.clz32.js","./modules/es6.math.cosh":"node_modules/core-js/modules/es6.math.cosh.js","./modules/es6.math.expm1":"node_modules/core-js/modules/es6.math.expm1.js","./modules/es6.math.fround":"node_modules/core-js/modules/es6.math.fround.js","./modules/es6.math.hypot":"node_modules/core-js/modules/es6.math.hypot.js","./modules/es6.math.imul":"node_modules/core-js/modules/es6.math.imul.js","./modules/es6.math.log10":"node_modules/core-js/modules/es6.math.log10.js","./modules/es6.math.log1p":"node_modules/core-js/modules/es6.math.log1p.js","./modules/es6.math.log2":"node_modules/core-js/modules/es6.math.log2.js","./modules/es6.math.sign":"node_modules/core-js/modules/es6.math.sign.js","./modules/es6.math.sinh":"node_modules/core-js/modules/es6.math.sinh.js","./modules/es6.math.tanh":"node_modules/core-js/modules/es6.math.tanh.js","./modules/es6.math.trunc":"node_modules/core-js/modules/es6.math.trunc.js","./modules/es6.string.from-code-point":"node_modules/core-js/modules/es6.string.from-code-point.js","./modules/es6.string.raw":"node_modules/core-js/modules/es6.string.raw.js","./modules/es6.string.trim":"node_modules/core-js/modules/es6.string.trim.js","./modules/es6.string.iterator":"node_modules/core-js/modules/es6.string.iterator.js","./modules/es6.string.code-point-at":"node_modules/core-js/modules/es6.string.code-point-at.js","./modules/es6.string.ends-with":"node_modules/core-js/modules/es6.string.ends-with.js","./modules/es6.string.includes":"node_modules/core-js/modules/es6.string.includes.js","./modules/es6.string.repeat":"node_modules/core-js/modules/es6.string.repeat.js","./modules/es6.string.starts-with":"node_modules/core-js/modules/es6.string.starts-with.js","./modules/es6.string.anchor":"node_modules/core-js/modules/es6.string.anchor.js","./modules/es6.string.big":"node_modules/core-js/modules/es6.string.big.js","./modules/es6.string.blink":"node_modules/core-js/modules/es6.string.blink.js","./modules/es6.string.bold":"node_modules/core-js/modules/es6.string.bold.js","./modules/es6.string.fixed":"node_modules/core-js/modules/es6.string.fixed.js","./modules/es6.string.fontc
72477olor":"node_modules/core-js/modules/es6.string.fontcolor.js","./modules/es6.string.fontsize":"node_modules/core-js/modules/es6.string.fontsize.js","./modules/es6.string.italics":"node_modules/core-js/modules/es6.string.italics.js","./modules/es6.string.link":"node_modules/core-js/modules/es6.string.link.js","./modules/es6.string.small":"node_modules/core-js/modules/es6.string.small.js","./modules/es6.string.strike":"node_modules/core-js/modules/es6.string.strike.js","./modules/es6.string.sub":"node_modules/core-js/modules/es6.string.sub.js","./modules/es6.string.sup":"node_modules/core-js/modules/es6.string.sup.js","./modules/es6.date.now":"node_modules/core-js/modules/es6.date.now.js","./modules/es6.date.to-json":"node_modules/core-js/modules/es6.date.to-json.js","./modules/es6.date.to-iso-string":"node_modules/core-js/modules/es6.date.to-iso-string.js","./modules/es6.date.to-string":"node_modules/core-js/modules/es6.date.to-string.js","./modules/es6.date.to-primitive":"node_modules/core-js/modules/es6.date.to-primitive.js","./modules/es6.array.is-array":"node_modules/core-js/modules/es6.array.is-array.js","./modules/es6.array.from":"node_modules/core-js/modules/es6.array.from.js","./modules/es6.array.of":"node_modules/core-js/modules/es6.array.of.js","./modules/es6.array.join":"node_modules/core-js/modules/es6.array.join.js","./modules/es6.array.slice":"node_modules/core-js/modules/es6.array.slice.js","./modules/es6.array.sort":"node_modules/core-js/modules/es6.array.sort.js","./modules/es6.array.for-each":"node_modules/core-js/modules/es6.array.for-each.js","./modules/es6.array.map":"node_modules/core-js/modules/es6.array.map.js","./modules/es6.array.filter":"node_modules/core-js/modules/es6.array.filter.js","./modules/es6.array.some":"node_modules/core-js/modules/es6.array.some.js","./modules/es6.array.every":"node_modules/core-js/modules/es6.array.every.js","./modules/es6.array.reduce":"node_modules/core-js/modules/es6.array.reduce.js","./modules/es6.array.reduce-right":"node_modules/core-js/modules/es6.array.reduce-right.js","./modules/es6.array.index-of":"node_modules/core-js/modules/es6.array.index-of.js","./modules/es6.array.last-index-of":"node_modules/core-js/modules/es6.array.last-index-of.js","./modules/es6.array.copy-within":"node_modules/core-js/modules/es6.array.copy-within.js","./modules/es6.array.fill":"node_modules/core-js/modules/es6.array.fill.js","./modules/es6.array.find":"node_modules/core-js/modules/es6.array.find.js","./modules/es6.array.find-index":"node_modules/core-js/modules/es6.array.find-index.js","./modules/es6.array.species":"node_modules/core-js/modules/es6.array.species.js","./modules/es6.array.iterator":"node_modules/core-js/modules/es6.array.iterator.js","./modules/es6.regexp.constructor":"node_modules/core-js/modules/es6.regexp.constructor.js","./modules/es6.regexp.exec":"node_modules/core-js/modules/es6.regexp.exec.js","./modules/es6.regexp.to-string":"node_modules/core-js/modules/es6.regexp.to-string.js","./modules/es6.regexp.flags":"node_modules/core-js/modules/es6.regexp.flags.js","./modules/es6.regexp.match":"node_modules/core-js/modules/es6.regexp.match.js","./modules/es6.regexp.replace":"node_modules/core-js/modules/es6.regexp.replace.js","./modules/es6.regexp.search":"node_modules/core-js/modules/es6.regexp.search.js","./modules/es6.regexp.split":"node_modules/core-js/modules/es6.regexp.split.js","./modules/es6.promise":"node_modules/core-js/modules/es6.promise.js","./modules/es6.map":"node_modules/core-js/modules/es6.map.js","./modules/es6.set":"node_modules/core-js/modules/es6.set.js","./modules/es6.weak-map":"node_modules/core-js/modules/es6.weak-map.js","./modules/es6.weak-set":"node_modules/core-js/modules/es6.weak-set.js","./modules/es6.typed.array-buffer":"node_modules/core-js/modules/es6.typed.array-buffer.js","./modules/es6.typed.data-view":"node_modules/core-js/modules/es6.typed.data-view.js","./modules/es6.typed.int8-array":"node_modules/core-js/modules/es6.typed.int8-array.js","./modules/es6.typed.uint8-array":"node_modules/core-js/modules/es6.typed.uint8-array.js","./modules/es6.typed.uint8-clamped-array":"node_modules/core-js/modules/es6.typed.uint8-clamped-array.js","./modules/es6.typed.int16-array":"node_modules/core-js/modules/es6.typed.int16-array.js","./modules/es6.typed.uint16-array":"node_modules/core-js/modules/es6.typed.uint16-array.js","./modules/es6.typed.int32-array":"node_modules/core-js/modules/es6.typed.int32-array.js","./modules/es6.typed.uint32-array":"node_modules/core-js/modules/es6.typed.uint32-array.js","./modules/es6.typed.float32-array":"node_modules/core-js/modules/es6.typed.float32-array.js","./modules/es6.typed.float64-array":"node_modules/core-js/modules/es6.typed.float64-array.js","./modules/es6.reflect.apply":"node_modules/core-js/modules/es6.reflect.apply.js","./modules/es6.reflect.construct":"node_modules/core-js/modules/es6.reflect.construct.js","./modules/es6.reflect.define-property":"node_modules/core-js/modules/es6.reflect.define-property.js","./modules/es6.reflect.delete-property":"node_modules/core-js/modules/es6.reflect.delete-property.js","./modules/es6.reflect.enumerate":"node_modules/core-js/modules/es6.reflect.enumerate.js","./modules/es6.reflect.get":"node_modules/core-js/modules/es6.reflect.get.js","./modules/es6.reflect.get-own-property-descriptor":"node_modules/core-js/modules/es6.reflect.get-own-property-descriptor.js","./modules/es6.reflect.get-prototype-of":"node_modules/core-js/modules/es6.reflect.get-prototype-of.js","./modules/es6.reflect.has":"node_modules/core-js/modules/es6.reflect.has.js","./modules/es6.reflect.is-extensible":"node_modules/core-js/modules/es6.reflect.is-extensible.js","./modules/es6.reflect.own-keys":"node_modules/core-js/modules/es6.reflect.own-keys.js","./modules/es6.reflect.prevent-extensions":"node_modules/core-js/modules/es6.reflect.prevent-extensions.js","./modules/es6.reflect.set":"node_modules/core-js/modules/es6.reflect.set.js","./modules/es6.reflect.set-prototype-of":"node_modules/core-js/modules/es6.reflect.set-prototype-of.js","./modules/es7.array.includes":"node_modules/core-js/modules/es7.array.includes.js","./modules/es7.array.flat-map":"node_modules/core-js/modules/es7.array.flat-map.js","./modules/es7.array.flatten":"node_modules/core-js/modules/es7.array.flatten.js","./modules/es7.string.at":"node_modules/core-js/modules/es7.string.at.js","./modules/es7.string.pad-start":"node_modules/core-js/modules/es7.string.pad-start.js","./modules/es7.string.pad-end":"node_modules/core-js/modules/es7.string.pad-end.js","./modules/es7.string.trim-left":"node_modules/core-js/modules/es7.string.trim-left.js","./modules/es7.string.trim-right":"node_modules/core-js/modules/es7.string.trim-right.js","./modules/es7.string.match-all":"node_modules/core-js/modules/es7.string.match-all.js","./modules/es7.symbol.async-iterator":"node_modules/core-js/modules/es7.symbol.async-iterator.js","./modules/es7.symbol.observable":"node_modules/core-js/modules/es7.symbol.observable.js","./modules/es7.object.get-own-property-descriptors":"node_modules/core-js/modules/es7.object.get-own-property-descriptors.js","./modules/es7.object.values":"node_modules/core-js/modules/es7.object.values.js","./modules/es7.object.entries":"node_modules/core-js/modules/es7.object.entries.js","./modules/es7.object.define-getter":"node_modules/core-js/modules/es7.object.define-getter.js","./modules/es7.object.define-setter":"node_modules/core-js/modules/es7.object.define-setter.js","./modules/es7.object.lookup-getter":"node_modules/core-js/modules/es7.object.lookup-getter.js","./modules/es7.object.lookup-setter":"node_modules/core-js/modules/es7.object.lookup-setter.js","./modules/es7.map.to-json":"node_modules/core-js/modules/es7.map.to-json.js","./modules/es7.set.to-json":"node_modules/core-js/modules/es7.set.to-json.js","./modules/es7.map.of":"node_modules/core-js/modules/es7.map.of.js","./modules/es7.set.of":"node_modules/core-js/modules/es7.set.of.js","./modules/es7.weak-map.of":"node_modules/core-js/modules/es7.weak-map.of.js","./modules/es7.weak-set.of":"node_modules/core-js/modules/es7.weak-set.of.js","./modules/es7.map.from":"node_modules/core-js/modules/es7.map.from.js","./modules/es7.set.from":"node_modules/core-js/modules/es7.set.from.js","./modules/es7.weak-map.from":"node_modules/core-js/modules/es7.weak-map.from.js","./modules/es7.weak-set.from":"node_modules/core-js/modules/es7.weak-set.from.js","./modules/es7.global":"node_modules/core-js/modules/es7.global.js","./modules/es7.system.global":"node_modules/core-js/modules/es7.system.global.js","./modules/es7.error.is-error":"node_modules/core-js/modules/es7.error.is-error.js","./modules/es7.math.clamp":"node_modules/core-js/modules/es7.math.clamp.js","./modules/es7.math.deg-per-rad":"node_modules/core-js/modules/es7.math.deg-per-rad.js","./modules/es7.math.degrees":"node_modules/core-js/modules/es7.math.degrees.js","./modules/es7.math.fscale":"node_modules/core-js/modules/es7.math.fscale.js","./modules/es7.math.iad
72477dh":"node_modules/core-js/modules/es7.math.iaddh.js","./modules/es7.math.isubh":"node_modules/core-js/modules/es7.math.isubh.js","./modules/es7.math.imulh":"node_modules/core-js/modules/es7.math.imulh.js","./modules/es7.math.rad-per-deg":"node_modules/core-js/modules/es7.math.rad-per-deg.js","./modules/es7.math.radians":"node_modules/core-js/modules/es7.math.radians.js","./modules/es7.math.scale":"node_modules/core-js/modules/es7.math.scale.js","./modules/es7.math.umulh":"node_modules/core-js/modules/es7.math.umulh.js","./modules/es7.math.signbit":"node_modules/core-js/modules/es7.math.signbit.js","./modules/es7.promise.finally":"node_modules/core-js/modules/es7.promise.finally.js","./modules/es7.promise.try":"node_modules/core-js/modules/es7.promise.try.js","./modules/es7.reflect.define-metadata":"node_modules/core-js/modules/es7.reflect.define-metadata.js","./modules/es7.reflect.delete-metadata":"node_modules/core-js/modules/es7.reflect.delete-metadata.js","./modules/es7.reflect.get-metadata":"node_modules/core-js/modules/es7.reflect.get-metadata.js","./modules/es7.reflect.get-metadata-keys":"node_modules/core-js/modules/es7.reflect.get-metadata-keys.js","./modules/es7.reflect.get-own-metadata":"node_modules/core-js/modules/es7.reflect.get-own-metadata.js","./modules/es7.reflect.get-own-metadata-keys":"node_modules/core-js/modules/es7.reflect.get-own-metadata-keys.js","./modules/es7.reflect.has-metadata":"node_modules/core-js/modules/es7.reflect.has-metadata.js","./modules/es7.reflect.has-own-metadata":"node_modules/core-js/modules/es7.reflect.has-own-metadata.js","./modules/es7.reflect.metadata":"node_modules/core-js/modules/es7.reflect.metadata.js","./modules/es7.asap":"node_modules/core-js/modules/es7.asap.js","./modules/es7.observable":"node_modules/core-js/modules/es7.observable.js","./modules/web.timers":"node_modules/core-js/modules/web.timers.js","./modules/web.immediate":"node_modules/core-js/modules/web.immediate.js","./modules/web.dom.iterable":"node_modules/core-js/modules/web.dom.iterable.js","./modules/_core":"node_modules/core-js/modules/_core.js"}],"node_modules/regenerator-runtime/runtime.js":[function(require,module,exports) {
72478var global = arguments[3];
vendor: 13,633 bytes, lines 72478-72830
72478
72479/**
72480 * Copyright (c) 2014, Facebook, Inc.
72481 * All rights reserved.
72482 *
72483 * This source code is licensed under the BSD-style license found in the
72484 * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
72485 * additional grant of patent rights can be found in the PATENTS file in
72486 * the same directory.
72487 */
72488
72489!(function(global) {
72490  "use strict";
72491
72492  var Op = Object.prototype;
72493  var hasOwn = Op.hasOwnProperty;
72494  var undefined; // More compressible than void 0.
72495  var $Symbol = typeof Symbol === "function" ? Symbol : {};
72496  var iteratorSymbol = $Symbol.iterator || "@@iterator";
72497  var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
72498  var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
72499
72500  var inModule = typeof module === "object";
72501  var runtime = global.regeneratorRuntime;
72502  if (runtime) {
72503    if (inModule) {
72504      // If regeneratorRuntime is defined globally and we're in a module,
72505      // make the exports object identical to regeneratorRuntime.
72506      module.exports = runtime;
72507    }
72508    // Don't bother evaluating the rest of this file if the runtime was
72509    // already defined globally.
72510    return;
72511  }
72512
72513  // Define the runtime globally (as expected by generated code) as either
72514  // module.exports (if we're in a module) or a new, empty object.
72515  runtime = global.regeneratorRuntime = inModule ? module.exports : {};
72516
72517  function wrap(innerFn, outerFn, self, tryLocsList) {
72518    // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
72519    var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
72520    var generator = Object.create(protoGenerator.prototype);
72521    var context = new Context(tryLocsList || []);
72522
72523    // The ._invoke method unifies the implementations of the .next,
72524    // .throw, and .return methods.
72525    generator._invoke = makeInvokeMethod(innerFn, self, context);
72526
72527    return generator;
72528  }
72529  runtime.wrap = wrap;
72530
72531  // Try/catch helper to minimize deoptimizations. Returns a completion
72532  // record like context.tryEntries[i].completion. This interface could
72533  // have been (and was previously) designed to take a closure to be
72534  // invoked without arguments, but in all the cases we care about we
72535  // already have an existing method we want to call, so there's no need
72536  // to create a new function object. We can even get away with assuming
72537  // the method takes exactly one argument, since that happens to be true
72538  // in every case, so we don't have to touch the arguments object. The
72539  // only additional allocation required is the completion record, which
72540  // has a stable shape and so hopefully should be cheap to allocate.
72541  function tryCatch(fn, obj, arg) {
72542    try {
72543      return { type: "normal", arg: fn.call(obj, arg) };
72544    } catch (err) {
72545      return { type: "throw", arg: err };
72546    }
72547  }
72548
72549  var GenStateSuspendedStart = "suspendedStart";
72550  var GenStateSuspendedYield = "suspendedYield";
72551  var GenStateExecuting = "executing";
72552  var GenStateCompleted = "completed";
72553
72554  // Returning this object from the innerFn has the same effect as
72555  // breaking out of the dispatch switch statement.
72556  var ContinueSentinel = {};
72557
72558  // Dummy constructor functions that we use as the .constructor and
72559  // .constructor.prototype properties for functions that return Generator
72560  // objects. For full spec compliance, you may wish to configure your
72561  // minifier not to mangle the names of these two functions.
72562  function Generator() {}
72563  function GeneratorFunction() {}
72564  function GeneratorFunctionPrototype() {}
72565
72566  // This is a polyfill for %IteratorPrototype% for environments that
72567  // don't natively support it.
72568  var IteratorPrototype = {};
72569  IteratorPrototype[iteratorSymbol] = function () {
72570    return this;
72571  };
72572
72573  var getProto = Object.getPrototypeOf;
72574  var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
72575  if (NativeIteratorPrototype &&
72576      NativeIteratorPrototype !== Op &&
72577      hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
72578    // This environment has a native %IteratorPrototype%; use it instead
72579    // of the polyfill.
72580    IteratorPrototype = NativeIteratorPrototype;
72581  }
72582
72583  var Gp = GeneratorFunctionPrototype.prototype =
72584    Generator.prototype = Object.create(IteratorPrototype);
72585  GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
72586  GeneratorFunctionPrototype.constructor = GeneratorFunction;
72587  GeneratorFunctionPrototype[toStringTagSymbol] =
72588    GeneratorFunction.displayName = "GeneratorFunction";
72589
72590  // Helper for defining the .next, .throw, and .return methods of the
72591  // Iterator interface in terms of a single ._invoke method.
72592  function defineIteratorMethods(prototype) {
72593    ["next", "throw", "return"].forEach(function(method) {
72594      prototype[method] = function(arg) {
72595        return this._invoke(method, arg);
72596      };
72597    });
72598  }
72599
72600  runtime.isGeneratorFunction = function(genFun) {
72601    var ctor = typeof genFun === "function" && genFun.constructor;
72602    return ctor
72603      ? ctor === GeneratorFunction ||
72604        // For the native GeneratorFunction constructor, the best we can
72605        // do is to check its .name property.
72606        (ctor.displayName || ctor.name) === "GeneratorFunction"
72607      : false;
72608  };
72609
72610  runtime.mark = function(genFun) {
72611    if (Object.setPrototypeOf) {
72612      Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
72613    } else {
72614      genFun.__proto__ = GeneratorFunctionPrototype;
72615      if (!(toStringTagSymbol in genFun)) {
72616        genFun[toStringTagSymbol] = "GeneratorFunction";
72617      }
72618    }
72619    genFun.prototype = Object.create(Gp);
72620    return genFun;
72621  };
72622
72623  // Within the body of any async function, `await x` is transformed to
72624  // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
72625  // `hasOwn.call(value, "__await")` to determine if the yielded value is
72626  // meant to be awaited.
72627  runtime.awrap = function(arg) {
72628    return { __await: arg };
72629  };
72630
72631  function AsyncIterator(generator) {
72632    function invoke(method, arg, resolve, reject) {
72633      var record = tryCatch(generator[method], generator, arg);
72634      if (record.type === "throw") {
72635        reject(record.arg);
72636      } else {
72637        var result = record.arg;
72638        var value = result.value;
72639        if (value &&
72640            typeof value === "object" &&
72641            hasOwn.call(value, "__await")) {
72642          return Promise.resolve(value.__await).then(function(value) {
72643            invoke("next", value, resolve, reject);
72644          }, function(err) {
72645            invoke("throw", err, resolve, reject);
72646          });
72647        }
72648
72649        return Promise.resolve(value).then(function(unwrapped) {
72650          // When a yielded Promise is resolved, its final value becomes
72651          // the .value of the Promise<{value,done}> result for the
72652          // current iteration. If the Promise is rejected, however, the
72653          // result for this iteration will be rejected with the same
72654          // reason. Note that rejections of yielded Promises are not
72655          // thrown back into the generator function, as is the case
72656          // when an awaited Promise is rejected. This difference in
72657          // behavior between yield and await is important, because it
72658          // allows the consumer to decide what to do with the yielded
72659          // rejection (swallow it and continue, manually .throw it back
72660          // into the generator, abandon iteration, whatever). With
72661          // await, by contrast, there is no opportunity to examine the
72662          // rejection reason outside the generator function, so the
72663          // only option is to throw it from the await expression, and
72664          // let the generator function handle the exception.
72665          result.value = unwrapped;
72666          resolve(result);
72667        }, reject);
72668      }
72669    }
72670
72671    if (typeof global.process === "object" && global.process.domain) {
72672      invoke = global.process.domain.bind(invoke);
72673    }
72674
72675    var previousPromise;
72676
72677    function enqueue(method, arg) {
72678      function callInvokeWithMethodAndArg() {
72679        return new Promise(function(resolve, reject) {
72680          invoke(method, arg, resolve, reject);
72681        });
72682      }
72683
72684      return previousPromise =
72685        // If enqueue has been called before, then we want to wait until
72686        // all previous Promises have been resolved before calling invoke,
72687        // so that results are always delivered in the correct order. If
72688        // enqueue has not been called before, then it is important to
72689        // call invoke immediately, without waiting on a callback to fire,
72690        // so that the async generator function has the opportunity to do
72691        // any necessary setup in a predictable way. This predictability
72692        // is why the Promise constructor synchronously invokes its
72693        // executor callback, and why async functions synchronously
72694        // execute code before the first await. Since we implement simple
72695        // async functions in terms of async generators, it is especially
72696        // important to get this right, even though it requires care.
72697        previousPromise ? previousPromise.then(
72698          callInvokeWithMethodAndArg,
72699          // Avoid propagating failures to Promises returned by later
72700          // invocations of the iterator.
72701          callInvokeWithMethodAndArg
72702        ) : callInvokeWithMethodAndArg();
72703    }
72704
72705    // Define the unified helper method that is used to implement .next,
72706    // .throw, and .return (see defineIteratorMethods).
72707    this._invoke = enqueue;
72708  }
72709
72710  defineIteratorMethods(AsyncIterator.prototype);
72711  AsyncIterator.prototype[asyncIteratorSymbol] = function () {
72712    return this;
72713  };
72714  runtime.AsyncIterator = AsyncIterator;
72715
72716  // Note that simple async functions are implemented on top of
72717  // AsyncIterator objects; they just return a Promise for the value of
72718  // the final result produced by the iterator.
72719  runtime.async = function(innerFn, outerFn, self, tryLocsList) {
72720    var iter = new AsyncIterator(
72721      wrap(innerFn, outerFn, self, tryLocsList)
72722    );
72723
72724    return runtime.isGeneratorFunction(outerFn)
72725      ? iter // If outerFn is a generator, return the full iterator.
72726      : iter.next().then(function(result) {
72727          return result.done ? result.value : iter.next();
72728        });
72729  };
72730
72731  function makeInvokeMethod(innerFn, self, context) {
72732    var state = GenStateSuspendedStart;
72733
72734    return function invoke(method, arg) {
72735      if (state === GenStateExecuting) {
72736        throw new Error("Generator is already running");
72737      }
72738
72739      if (state === GenStateCompleted) {
72740        if (method === "throw") {
72741          throw arg;
72742        }
72743
72744        // Be forgiving, per 25.3.3.3.3 of the spec:
72745        // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
72746        return doneResult();
72747      }
72748
72749      context.method = method;
72750      context.arg = arg;
72751
72752      while (true) {
72753        var delegate = context.delegate;
72754        if (delegate) {
72755          var delegateResult = maybeInvokeDelegate(delegate, context);
72756          if (delegateResult) {
72757            if (delegateResult === ContinueSentinel) continue;
72758            return delegateResult;
72759          }
72760        }
72761
72762        if (context.method === "next") {
72763          // Setting context._sent for legacy support of Babel's
72764          // function.sent implementation.
72765          context.sent = context._sent = context.arg;
72766
72767        } else if (context.method === "throw") {
72768          if (state === GenStateSuspendedStart) {
72769            state = GenStateCompleted;
72770            throw context.arg;
72771          }
72772
72773          context.dispatchException(context.arg);
72774
72775        } else if (context.method === "return") {
72776          context.abrupt("return", context.arg);
72777        }
72778
72779        state = GenStateExecuting;
72780
72781        var record = tryCatch(innerFn, self, context);
72782        if (record.type === "normal") {
72783          // If an exception is thrown from innerFn, we leave state ===
72784          // GenStateExecuting and loop back for another invocation.
72785          state = context.done
72786            ? GenStateCompleted
72787            : GenStateSuspendedYield;
72788
72789          if (record.arg === ContinueSentinel) {
72790            continue;
72791          }
72792
72793          return {
72794            value: record.arg,
72795            done: context.done
72796          };
72797
72798        } else if (record.type === "throw") {
72799          state = GenStateCompleted;
72800          // Dispatch the exception by looping back around to the
72801          // context.dispatchException(context.arg) call above.
72802          context.method = "throw";
72803          context.arg = record.arg;
72804        }
72805      }
72806    };
72807  }
72808
72809  // Call delegate.iterator[context.method](context.arg) and handle the
72810  // result, either by returning a { value, done } result from the
72811  // delegate iterator, or by modifying context.method and context.arg,
72812  // setting context.delegate to null, and returning the ContinueSentinel.
72813  function maybeInvokeDelegate(delegate, context) {
72814    var method = delegate.iterator[context.method];
72815    if (method === undefined) {
72816      // A .throw or .return when the delegate iterator has no .throw
72817      // method always terminates the yield* loop.
72818      context.delegate = null;
72819
72820      if (context.method === "throw") {
72821        if (delegate.iterator.return) {
72822          // If the delegate iterator has a return method, give it a
72823          // chance to clean up.
72824          context.method = "return";
72825          context.arg = undefined;
72826          maybeInvokeDelegate(delegate, context);
72827
72828          if (context.method === "throw") {
72829            // If maybeInvokeDelegate(context) changed context.method from
72830            // "return" to "throw", let that override the TypeError below.
vendor: 10,473 bytes, lines 72831-73208
72831            return ContinueSentinel;
72832          }
72833        }
72834
72835        context.method = "throw";
72836        context.arg = new TypeError(
72837          "The iterator does not provide a 'throw' method");
72838      }
72839
72840      return ContinueSentinel;
72841    }
72842
72843    var record = tryCatch(method, delegate.iterator, context.arg);
72844
72845    if (record.type === "throw") {
72846      context.method = "throw";
72847      context.arg = record.arg;
72848      context.delegate = null;
72849      return ContinueSentinel;
72850    }
72851
72852    var info = record.arg;
72853
72854    if (! info) {
72855      context.method = "throw";
72856      context.arg = new TypeError("iterator result is not an object");
72857      context.delegate = null;
72858      return ContinueSentinel;
72859    }
72860
72861    if (info.done) {
72862      // Assign the result of the finished delegate to the temporary
72863      // variable specified by delegate.resultName (see delegateYield).
72864      context[delegate.resultName] = info.value;
72865
72866      // Resume execution at the desired location (see delegateYield).
72867      context.next = delegate.nextLoc;
72868
72869      // If context.method was "throw" but the delegate handled the
72870      // exception, let the outer generator proceed normally. If
72871      // context.method was "next", forget context.arg since it has been
72872      // "consumed" by the delegate iterator. If context.method was
72873      // "return", allow the original .return call to continue in the
72874      // outer generator.
72875      if (context.method !== "return") {
72876        context.method = "next";
72877        context.arg = undefined;
72878      }
72879
72880    } else {
72881      // Re-yield the result returned by the delegate method.
72882      return info;
72883    }
72884
72885    // The delegate iterator is finished, so forget it and continue with
72886    // the outer generator.
72887    context.delegate = null;
72888    return ContinueSentinel;
72889  }
72890
72891  // Define Generator.prototype.{next,throw,return} in terms of the
72892  // unified ._invoke helper method.
72893  defineIteratorMethods(Gp);
72894
72895  Gp[toStringTagSymbol] = "Generator";
72896
72897  // A Generator should always return itself as the iterator object when the
72898  // @@iterator function is called on it. Some browsers' implementations of the
72899  // iterator prototype chain incorrectly implement this, causing the Generator
72900  // object to not be returned from this call. This ensures that doesn't happen.
72901  // See https://github.com/facebook/regenerator/issues/274 for more details.
72902  Gp[iteratorSymbol] = function() {
72903    return this;
72904  };
72905
72906  Gp.toString = function() {
72907    return "[object Generator]";
72908  };
72909
72910  function pushTryEntry(locs) {
72911    var entry = { tryLoc: locs[0] };
72912
72913    if (1 in locs) {
72914      entry.catchLoc = locs[1];
72915    }
72916
72917    if (2 in locs) {
72918      entry.finallyLoc = locs[2];
72919      entry.afterLoc = locs[3];
72920    }
72921
72922    this.tryEntries.push(entry);
72923  }
72924
72925  function resetTryEntry(entry) {
72926    var record = entry.completion || {};
72927    record.type = "normal";
72928    delete record.arg;
72929    entry.completion = record;
72930  }
72931
72932  function Context(tryLocsList) {
72933    // The root entry object (effectively a try statement without a catch
72934    // or a finally block) gives us a place to store values thrown from
72935    // locations where there is no enclosing try statement.
72936    this.tryEntries = [{ tryLoc: "root" }];
72937    tryLocsList.forEach(pushTryEntry, this);
72938    this.reset(true);
72939  }
72940
72941  runtime.keys = function(object) {
72942    var keys = [];
72943    for (var key in object) {
72944      keys.push(key);
72945    }
72946    keys.reverse();
72947
72948    // Rather than returning an object with a next method, we keep
72949    // things simple and return the next function itself.
72950    return function next() {
72951      while (keys.length) {
72952        var key = keys.pop();
72953        if (key in object) {
72954          next.value = key;
72955          next.done = false;
72956          return next;
72957        }
72958      }
72959
72960      // To avoid creating an additional object, we just hang the .value
72961      // and .done properties off the next function object itself. This
72962      // also ensures that the minifier will not anonymize the function.
72963      next.done = true;
72964      return next;
72965    };
72966  };
72967
72968  function values(iterable) {
72969    if (iterable) {
72970      var iteratorMethod = iterable[iteratorSymbol];
72971      if (iteratorMethod) {
72972        return iteratorMethod.call(iterable);
72973      }
72974
72975      if (typeof iterable.next === "function") {
72976        return iterable;
72977      }
72978
72979      if (!isNaN(iterable.length)) {
72980        var i = -1, next = function next() {
72981          while (++i < iterable.length) {
72982            if (hasOwn.call(iterable, i)) {
72983              next.value = iterable[i];
72984              next.done = false;
72985              return next;
72986            }
72987          }
72988
72989          next.value = undefined;
72990          next.done = true;
72991
72992          return next;
72993        };
72994
72995        return next.next = next;
72996      }
72997    }
72998
72999    // Return an iterator with no values.
73000    return { next: doneResult };
73001  }
73002  runtime.values = values;
73003
73004  function doneResult() {
73005    return { value: undefined, done: true };
73006  }
73007
73008  Context.prototype = {
73009    constructor: Context,
73010
73011    reset: function(skipTempReset) {
73012      this.prev = 0;
73013      this.next = 0;
73014      // Resetting context._sent for legacy support of Babel's
73015      // function.sent implementation.
73016      this.sent = this._sent = undefined;
73017      this.done = false;
73018      this.delegate = null;
73019
73020      this.method = "next";
73021      this.arg = undefined;
73022
73023      this.tryEntries.forEach(resetTryEntry);
73024
73025      if (!skipTempReset) {
73026        for (var name in this) {
73027          // Not sure about the optimal order of these conditions:
73028          if (name.charAt(0) === "t" &&
73029              hasOwn.call(this, name) &&
73030              !isNaN(+name.slice(1))) {
73031            this[name] = undefined;
73032          }
73033        }
73034      }
73035    },
73036
73037    stop: function() {
73038      this.done = true;
73039
73040      var rootEntry = this.tryEntries[0];
73041      var rootRecord = rootEntry.completion;
73042      if (rootRecord.type === "throw") {
73043        throw rootRecord.arg;
73044      }
73045
73046      return this.rval;
73047    },
73048
73049    dispatchException: function(exception) {
73050      if (this.done) {
73051        throw exception;
73052      }
73053
73054      var context = this;
73055      function handle(loc, caught) {
73056        record.type = "throw";
73057        record.arg = exception;
73058        context.next = loc;
73059
73060        if (caught) {
73061          // If the dispatched exception was caught by a catch block,
73062          // then let that catch block handle the exception normally.
73063          context.method = "next";
73064          context.arg = undefined;
73065        }
73066
73067        return !! caught;
73068      }
73069
73070      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
73071        var entry = this.tryEntries[i];
73072        var record = entry.completion;
73073
73074        if (entry.tryLoc === "root") {
73075          // Exception thrown outside of any try block that could handle
73076          // it, so set the completion value of the entire function to
73077          // throw the exception.
73078          return handle("end");
73079        }
73080
73081        if (entry.tryLoc <= this.prev) {
73082          var hasCatch = hasOwn.call(entry, "catchLoc");
73083          var hasFinally = hasOwn.call(entry, "finallyLoc");
73084
73085          if (hasCatch && hasFinally) {
73086            if (this.prev < entry.catchLoc) {
73087              return handle(entry.catchLoc, true);
73088            } else if (this.prev < entry.finallyLoc) {
73089              return handle(entry.finallyLoc);
73090            }
73091
73092          } else if (hasCatch) {
73093            if (this.prev < entry.catchLoc) {
73094              return handle(entry.catchLoc, true);
73095            }
73096
73097          } else if (hasFinally) {
73098            if (this.prev < entry.finallyLoc) {
73099              return handle(entry.finallyLoc);
73100            }
73101
73102          } else {
73103            throw new Error("try statement without catch or finally");
73104          }
73105        }
73106      }
73107    },
73108
73109    abrupt: function(type, arg) {
73110      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
73111        var entry = this.tryEntries[i];
73112        if (entry.tryLoc <= this.prev &&
73113            hasOwn.call(entry, "finallyLoc") &&
73114            this.prev < entry.finallyLoc) {
73115          var finallyEntry = entry;
73116          break;
73117        }
73118      }
73119
73120      if (finallyEntry &&
73121          (type === "break" ||
73122           type === "continue") &&
73123          finallyEntry.tryLoc <= arg &&
73124          arg <= finallyEntry.finallyLoc) {
73125        // Ignore the finally entry if control is not jumping to a
73126        // location outside the try/catch block.
73127        finallyEntry = null;
73128      }
73129
73130      var record = finallyEntry ? finallyEntry.completion : {};
73131      record.type = type;
73132      record.arg = arg;
73133
73134      if (finallyEntry) {
73135        this.method = "next";
73136        this.next = finallyEntry.finallyLoc;
73137        return ContinueSentinel;
73138      }
73139
73140      return this.complete(record);
73141    },
73142
73143    complete: function(record, afterLoc) {
73144      if (record.type === "throw") {
73145        throw record.arg;
73146      }
73147
73148      if (record.type === "break" ||
73149          record.type === "continue") {
73150        this.next = record.arg;
73151      } else if (record.type === "return") {
73152        this.rval = this.arg = record.arg;
73153        this.method = "return";
73154        this.next = "end";
73155      } else if (record.type === "normal" && afterLoc) {
73156        this.next = afterLoc;
73157      }
73158
73159      return ContinueSentinel;
73160    },
73161
73162    finish: function(finallyLoc) {
73163      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
73164        var entry = this.tryEntries[i];
73165        if (entry.finallyLoc === finallyLoc) {
73166          this.complete(entry.completion, entry.afterLoc);
73167          resetTryEntry(entry);
73168          return ContinueSentinel;
73169        }
73170      }
73171    },
73172
73173    "catch": function(tryLoc) {
73174      for (var i = this.tryEntries.length - 1; i >= 0; --i) {
73175        var entry = this.tryEntries[i];
73176        if (entry.tryLoc === tryLoc) {
73177          var record = entry.completion;
73178          if (record.type === "throw") {
73179            var thrown = record.arg;
73180            resetTryEntry(entry);
73181          }
73182          return thrown;
73183        }
73184      }
73185
73186      // The context.catch method must only be called with a location
73187      // argument that corresponds to a known catch block.
73188      throw new Error("illegal catch attempt");
73189    },
73190
73191    delegateYield: function(iterable, resultName, nextLoc) {
73192      this.delegate = {
73193        iterator: values(iterable),
73194        resultName: resultName,
73195        nextLoc: nextLoc
73196      };
73197
73198      if (this.method === "next") {
73199        // Deliberately forget the last sent value so that we don't
73200        // accidentally pass it on to the delegate.
73201        this.arg = undefined;
73202      }
73203
73204      return ContinueSentinel;
73205    }
73206  };
73207})(
73208  // 
73208Among the various tricks for obtaining a reference to the global
73209  // object, this seems to be the most reliable technique that does not
73210  // use indirect eval (which violates Content Security Policy).
73211  typeof global === "object" ? global :
73212  typeof window === "object" ? window :
73213  typeof self === "object" ? self : this
73214);
73215
73216},{}],"node_modules/core-js/modules/_replacer.js":[function(require,module,exports) {
73217module.exports = function (regExp, replace) {
73218  var replacer = replace === Object(replace) ? function (part) {
73219    return replace[part];
73220  } : replace;
73221  return function (it) {
73222    return String(it).replace(regExp, replacer);
73223  };
73224};
73225
73226},{}],"node_modules/core-js/modules/core.regexp.escape.js":[function(require,module,exports) {
73227// https://github.com/benjamingr/RexExp.escape
73228var $export = require('./_export');
73229var $re = require('./_replacer')(/[\\^$*+?.()|[\]{}]/g, '\\$&');
73230
73231$export($export.S, 'RegExp', { escape: function escape(it) { return $re(it); } });
73232
73233},{"./_export":"node_modules/core-js/modules/_export.js","./_replacer":"node_modules/core-js/modules/_replacer.js"}],"node_modules/core-js/fn/regexp/escape.js":[function(require,module,exports) {
73234require('../../modules/core.regexp.escape');
73235module.exports = require('../../modules/_core').RegExp.escape;
73236
73237},{"../../modules/core.regexp.escape":"node_modules/core-js/modules/core.regexp.escape.js","../../modules/_core":"node_modules/core-js/modules/_core.js"}],"node_modules/babel-polyfill/lib/index.js":[function(require,module,exports) {
73238var global = arguments[3];
73239
73240"use strict";
73241
73242require("core-js/shim");
73243
73244require("regenerator-runtime/runtime");
73245
73246require("core-js/fn/regexp/escape");
73247
73248if (global._babelPolyfill) {
73249  throw new Error("only one instance of babel-polyfill is allowed");
73250}
73251global._babelPolyfill = true;
73252
73253var DEFINE_PROPERTY = "defineProperty";
73254function define(O, key, value) {
73255  O[key] || Object[DEFINE_PROPERTY](O, key, {
73256    writable: true,
73257    configurable: true,
73258    value: value
73259  });
73260}
73261
73262define(String.prototype, "padLeft", "".padStart);
73263define(String.prototype, "padRight", "".padEnd);
73264
73265"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function (key) {
73266  [][key] && define(Array, key, Function.call.bind([][key]));
73267});
73268},{"core-js/shim":"node_modules/core-js/shim.js","regenerator-runtime/runtime":"node_modules/regenerator-runtime/runtime.js","core-js/fn/regexp/escape":"node_modules/core-js/fn/regexp/escape.js"}],"utils/demoUtils.js":[function(require,module,exports) {
73269"use strict";
73270
73271Object.defineProperty(exports, "__esModule", {
73272  value: true
73273});
73274exports.isMobile = isMobile;
73275exports.toggleLoadingUI = toggleLoadingUI;
73276exports.drawPoint = drawPoint;
73277exports.drawSegment = drawSegment;
73278exports.drawSkeleton = drawSkeleton;
73279exports.drawKeypoints = drawKeypoints;
73280exports.renderImageToCanvas = renderImageToCanvas;
73281exports.setStatusText = setStatusText;
73282
73283var posenet = _interopRequireWildcard(require("@tensorflow-models/posenet"));
73284
73285var tf = _interopRequireWildcard(require("@tensorflow/tfjs"));
73286
73287function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
73288
73289function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
73290
73291function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
73292
73293function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
73294
73295function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
73296
73297function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
73298
73299function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
73300
73301function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
73302
73303var color = 'aqua';
73304var boundingBoxColor = 'red';
73305var lineWidth = 2;
73306
73307function isAndroid() {
73308  return /Android/i.test(navigator.userAgent);
73309}
73310
73311function isiOS() {
73312  return /iPhone|iPad|iPod/i.test(navigator.userAgent);
73313}
73314
73315function isMobile() {
73316  return isAndroid() || isiOS();
73317}
73318
73319function setDatGuiPropertyCss(propertyText, liCssString) {
73320  var spanCssString = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
73321  var spans = document.getElementsByClassName('property-name');
73322
73323  for (var i = 0; i < spans.length; i++) {
73324    var text = spans[i].textContent || spans[i].innerText;
73325
73326    if (text == propertyText) {
73327      spans[i].parentNode.parentNode.style = liCssString;
73328
73329      if (spanCssString !== '') {
73330        spans[i].style = spanCssString;
73331      }
73332    }
73333  }
73334}
73335/**
73336 * Toggles between the loading UI and the main canvas UI.
73337 */
73338
73339
73340function toggleLoadingUI(showLoadingUI) {
73341  var loadingDivId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'loading';
73342  var mainDivId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'main';
73343
73344  if (showLoadingUI) {
73345    document.getElementById(loadingDivId).style.display = 'block';
73346    document.getElementById(mainDivId).style.display = 'none';
73347  } else {
73348    document.getElementById(loadingDivId).style.display = 'none';
73349    document.getElementById(mainDivId).style.display = 'block';
73350  }
73351}
73352
73353function toTuple(_ref) {
73354  var y = _ref.y,
73355      x = _ref.x;
73356  return [y, x];
73357}
73358
73359function drawPoint(ctx, y, x, r, color) {
73360  ctx.beginPath();
73361  ctx.arc(x, y, r, 0, 2 * Math.PI);
73362  ctx.fillStyle = color;
73363  ctx.fill();
73364}
73365/**
73366 * Draws a line on a canvas, i.e. a joint
73367 */
73368
73369
73370function drawSegment(_ref2, _ref3, color, scale, ctx) {
73371  var _ref4 = _slicedToArray(_ref2, 2),
73372      ay = _ref4[0],
73373      ax = _ref4[1];
73374
73375  var _ref5 = _slicedToArray(_ref3, 2),
73376      by = _ref5[0],
73377      bx = _ref5[1];
73378
73379  ctx.beginPath();
73380  ctx.moveTo(ax * scale, ay * scale);
73381  ctx.lineTo(bx * scale, by * scale);
73382  ctx.lineWidth = lineWidth;
73383  ctx.strokeStyle = color;
73384  ctx.stroke();
73385}
73386/**
73387 * Draws a pose skeleton by looking up all adjacent keypoints/joints
73388 */
73389
73390
73391function drawSkeleton(keypoints, minConfidence, ctx) {
73392  var scale = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
73393  var adjacentKeyPoints = posenet.getAdjacentKeyPoints(keypoints, minConfidence);
73394  adjacentKeyPoints.forEach(function (keypoints) {
73395    drawSegment(toTuple(keypoints[0].position), toTuple(keypoints[1].position), color, scale, ctx);
73396  });
73397}
73398/**
73399 * Draw pose keypoints onto a canvas
73400 */
73401
73402
73403function drawKeypoints(keypoints, minConfidence, ctx) {
73404  var scale = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
73405
73406  for (var i = 0; i < keypoints.length; i++) {
73407    var keypoint = keypoints[i];
73408
73409    if (keypoint.score < minConfidence) {
73410      continue;
73411    }
73412
73413    var _keypoint$position = keypoint.position,
73414        y = _keypoint$position.y,
73415        x = _keypoint$position.x;
73416    drawPoint(ctx, y * scale, x * scale, 3, color);
73417  }
73418}
73419/**
73420 * Draw an image on a canvas
73421 */
73422
73423
73424function renderImageToCanvas(image, size, canvas) {
73425  canvas.width = size[0];
73426  canvas.height = size[1];
73427  var ctx = canvas.getContext('2d');
73428  ctx.drawImage(image, 0, 0);
73429}
73430
73431function setStatusText(text) {
73432  var resultElement = document.getElementById('status');
73433  resultElement.innerText = text;
73434}
73435},{"@tensorflow-models/posenet":"node_modules/@tensorflow-models/posenet/dist/posenet.esm.js","@tensorflow/tfjs":"node_modules/@tensorflow/tfjs/dist/tf.esm.js"}],"utils/svgUtils.js":[function(require,module,exports) {
73436"use strict";
73437
73438Object.defineProperty(exports, "__esModule", {
73439  value: true
73440});
73441exports.SVGUtils = void 0;
73442
73443var paper = _interopRequireWildcard(require("paper"));
73444
73445function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
73446
73447function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
73448
73449function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
73450
73451function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
73452
73453function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
73454
73455var SVGUtils = /*#__PURE__*/function () {
73456  function SVGUtils() {
73457    _classCallCheck(this, SVGUtils);
73458  }
73459
73460  _createClass(SVGUtils, null, [{
73461    key: "importSVG",
73462    value: function importSVG(file) {
73463      var svgScope = new paper.default.PaperScope();
73464      var canvas = svgScope.createCanvas(0, 0);
73465      svgScope.setup(canvas);
73466      return new Promise(function (resolve, reject) {
73467        svgScope.project.importSVG(file, function () {
73468          console.log('** SVG imported **');
73469          resolve(svgScope);
73470        }, function (e) {
73471          console.log('** SVG improt error: ', e);
73472          reject(svgScope);
73473        });
73474      });
73475    }
73476  }, {
73477    key: "drawEllipse",
73478    value: function drawEllipse(p, va, vb, ctrlDA, ctrlDB, scope, options) {
73479      var va1 = va.multiply(-1);
73480      var vb1 = vb.multiply(-1);
73481      var p0 = p.add(va);
73482      var p1 = p.add(vb);
73483      var p2 = p.add(va1);
73484      var p3 = p.add(vb1);
73485      var path = new scope.Path(options);
73486      path.addSegment(p0, vb1.normalize().multiply(ctrlDB), vb.normalize().multiply(ctrlDB));
73487      path.addSegment(p1, va.normalize().multiply(ctrlDA), va1.normalize().multiply(ctrlDA));
73488      path.addSegment(p2, vb.normalize().multiply(ctrlDB), vb1.normalize().multiply(ctrlDB)
73488);
73489      path.addSegment(p3, va1.normalize().multiply(ctrlDA), va.normalize().multiply(ctrlDA));
73490      path.closePath();
73491      return path;
73492    }
73493  }, {
73494    key: "genPathWithSpline",
73495    value: function genPathWithSpline(path, spline, height, options, scope) {
73496      var pathLen = path.length;
73497
73498      if (pathLen == 0) {
73499        return path.clone();
73500      }
73501
73502      var to = [];
73503      var back = [];
73504      ;
73505      var segCount = Math.max(pathLen / 3, 1.0);
73506
73507      for (var i = 0; i < segCount; i++) {
73508        var perc = i / (segCount - 1);
73509        var p = path.getPointAt(perc * pathLen);
73510        var n = path.getNormalAt(perc * pathLen);
73511        var easeHeight = spline.get(perc);
73512        if (!p || !n) continue;
73513        var pp0 = p.add(n.multiply(height * easeHeight));
73514        var pp1 = p.subtract(n.multiply(height * easeHeight));
73515        to.push(pp0);
73516        back.unshift(pp1);
73517      }
73518
73519      var outPath = new scope.Path(options);
73520      outPath.addSegments(to.concat(back));
73521      outPath.simplify();
73522      return outPath;
73523    }
73524  }, {
73525    key: "isPath",
73526    value: function isPath(item) {
73527      return item.constructor === item.project._scope.Path;
73528    }
73529  }, {
73530    key: "isShape",
73531    value: function isShape(item) {
73532      return item.constructor === item.project._scope.Shape;
73533    }
73534  }, {
73535    key: "isGroup",
73536    value: function isGroup(item) {
73537      return item.constructor === item.project._scope.Group;
73538    }
73539  }, {
73540    key: "findFirstItemWithPrefix",
73541    value: function findFirstItemWithPrefix(root, prefix) {
73542      var items = root.getItems({
73543        recursive: true
73544      });
73545
73546      for (var i = 0; i < items.length; i++) {
73547        if (items[i].name && items[i].name.startsWith(prefix)) {
73548          return items[i];
73549        }
73550      }
73551
73552      return null;
73553    }
73554  }]);
73555
73556  return SVGUtils;
73557}();
73558
73559exports.SVGUtils = SVGUtils;
73560},{"paper":"node_modules/paper/dist/paper-full.js"}],"utils/mathUtils.js":[function(require,module,exports) {
73561"use strict";
73562
73563Object.defineProperty(exports, "__esModule", {
73564  value: true
73565});
73566exports.MultiSpline = exports.MathUtils = void 0;
73567
73568function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
73569
73570function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
73571
73572function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
73573
73574/**
73575 * @license
73576 * Copyright 2020 Google Inc. All Rights Reserved.
73577 * Licensed under the Apache License, Version 2.0 (the "License");
73578 * you may not use this file except in compliance with the License.
73579 * You may obtain a copy of the License at
73580 *
73581 * https://www.apache.org/licenses/LICENSE-2.0
73582 *
73583 * Unless required by applicable law or agreed to in writing, software
73584 * distributed under the License is distributed on an "AS IS" BASIS,
73585 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
73586 * See the License for the specific language governing permissions and
73587 * limitations under the License.
73588 * =============================================================================
73589 */
73590function getDistance(p0, p1) {
73591  return Math.sqrt((p0.x - p1.x) * (p0.x - p1.x) + (p0.y - p1.y) * (p0.y - p1.y));
73592}
73593
73594var MathUtils = /*#__PURE__*/function () {
73595  function MathUtils() {
73596    _classCallCheck(this, MathUtils);
73597  }
73598
73599  _createClass(MathUtils, null, [{
73600    key: "lerp",
73601    value: function lerp(v0, v1, perc) {
73602      return v0 + (v1 - v0) * perc;
73603    }
73604  }, {
73605    key: "random",
73606    value: function random(v0, v1) {
73607      return v0 + Math.random() * (v1 - v0);
73608    }
73609  }, {
73610    key: "smoothStep",
73611    value: function smoothStep(v, min, max) {
73612      var x = Math.max(0, Math.min(1, (v - min) / (max - min)));
73613      return x * x * (3 - 2 * x);
73614    } // Generate a transform function of p in the coordinate system defined by p0 and p1.
73615
73616  }, {
73617    key: "getTransformFunc",
73618    value: function getTransformFunc(p0, p1, p) {
73619      var d = p1.subtract(p0);
73620      var dir = d.normalize();
73621      var l0 = d.length;
73622      var n = dir.clone();
73623      n.angle += 90;
73624      var v = p.subtract(p0);
73625      var x = v.dot(dir);
73626      var y = v.dot(n);
73627      return function (p0New, p1New) {
73628        var d = p1New.subtract(p0New);
73629
73630        if (d.length === 0) {
73631          return p0New.clone();
73632        }
73633
73634        var scale = d.length / l0;
73635        var dirNew = d.normalize();
73636        var nNew = dirNew.clone();
73637        nNew.angle += 90;
73638        return p0New.add(dirNew.multiply(x * scale)).add(nNew.multiply(y * scale));
73639      };
73640    }
73641  }, {
73642    key: "getClosestPointOnSegment",
73643    value: function getClosestPointOnSegment(p0, p1, p) {
73644      var d = p1.subtract(p0);
73645      var c = p.subtract(p0).dot(d) / d.dot(d);
73646
73647      if (c >= 1) {
73648        return p1.clone();
73649      } else if (c <= 0) {
73650        return p0.clone();
73651      } else {
73652        return p0.add(d.multiply(c));
73653      }
73654    } // Check if v0 and v1 are collinear.
73655    // Returns true if cosine of the angle between v0 and v1 is within threshold to 1.
73656
73657  }, {
73658    key: "isCollinear",
73659    value: function isCollinear(v0, v1) {
73660      var threshold = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.01;
73661      var colinear = false;
73662
73663      if (v0 && v1) {
73664        var n0 = v0.normalize();
73665        var n1 = v1.normalize();
73666        colinear = Math.abs(n0.dot(n1)) > 1 - threshold;
73667      }
73668
73669      return colinear;
73670    }
73671  }, {
73672    key: "gaussian",
73673    value: function gaussian(mean, variance) {
73674      var u = 0,
73675          v = 0;
73676
73677      while (u === 0) {
73678        u = Math.random();
73679      } //Converting [0,1) to (0,1)
73680
73681
73682      while (v === 0) {
73683        v = Math.random();
73684      }
73685
73686      var value = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v);
73687      return value * variance + mean;
73688    }
73689  }, {
73690    key: "clamp",
73691    value: function clamp(v, minV, maxV) {
73692      return Math.min(Math.max(v, minV), maxV);
73693    }
73694  }, {
73695    key: "selectSegments",
73696    value: function selectSegments(selectPerc, count, selectVar, segVar) {
73697      var segments = [];
73698      var totalSeg = 0;
73699
73700      for (var i = 0; i < count; i++) {
73701        var seg = MathUtils.gaussian(1, segVar);
73702        segments.push(seg);
73703        totalSeg += seg;
73704      }
73705
73706      for (var _i = 0; _i < segments.length; _i++) {
73707        segments[_i] = segments[_i] / totalSeg;
73708      }
73709
73710      var cursor = 0;
73711      var selected = [];
73712
73713      for (var _i2 = 0; _i2 < count; _i2++) {
73714        var s0 = cursor;
73715        var s1 = cursor + segments[_i2] * MathUtils.clamp(MathUtils.gaussian(1, selectVar) * selectPerc, 0, 1);
73716        selected.push([s0, s1]);
73717        cursor += segments[_i2];
73718      }
73719
73720      return selected;
73721    }
73722  }, {
73723    key: "isLeft",
73724    value: function isLeft(p0, p1, p) {
73725      return (p1.x - p0.x) * (p.y - p0.y) - (p1.y - p0.y) * (p.x - p0.x) > 0;
73726    }
73727  }, {
73728    key: "packCircles",
73729    value: function packCircles(center, radius, seedCount, maxR, minR) {
73730      var maxIter = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 10;
73731      var circles = [];
73732      var iterCount = 0;
73733
73734      var _loop = function _loop() {
73735        var _loop2 = function _loop2() {
73736          var c = {
73737            x: radius * (Math.random() * 2 - 1) + center.x,
73738            y: radius * (Math.random() * 2 - 1) + center.y
73739          };
73740          if (getDistance(c, center) > radius || circles.some(function (circle) {
73741            return getDistance(circle, c) < circle.radius;
73742          })) return "continue";
73743          circles.push({
73744            c: c,
73745            r: 0
73746          });
73747        };
73748
73749        while (circles.length < seedCount) {
73750          var _ret = _loop2();
73751
73752          if (_ret === "continue") continue;
73753        }
73754
73755        var growthIterCount = 20;
73756
73757        var intersects = function intersects(c0, c1) {
73758          var d = getDistance(c0.c, c1.c);
73759          return d < c0.r + c1.r && d > Math.abs(c0.r - c1.r);
73760        };
73761
73762        var bound = {
73763          c: center,
73764          r: radius
73765        };
73766
73767        for (var i = 0; i < growthIterCount; i++) {
73768          var grew = false;
73769          circles.forEach(function (s) {
73770            var intersecting = circles.some(function (other) {
73771              return s !== other && (intersects(s, other) || intersects(s, bound));
73772            });
73773
73774            if (!intersecting && s.r < maxR) {
73775              s.r += maxR / growthIterCount;
73776              grew = true;
73777            }
73778          });
73779          if (!grew) break;
73780        }
73781
73782        circles = circles.filter(function (c) {
73783          return c.r >= minR;
73784        });
73785        iterCount++;
73786      };
73787
73788      while (circles.length < seedCount && iterCount < maxIter) {
73789        _loop();
73790      }
73791
73792      return circles;
73793    }
73794  }]);
73795
73796  return MathUtils;
73797}();
73798
73799exports.MathUtils = MathUtils;
73800
73801var KeySpline = /*#__PURE__*/function () {
73802  function KeySpline(mX1, mY1, mX2, mY2) {
73803    _classCallCheck(this, KeySpline);
73804
73805    this.mX1 = mX1;
73806    this.mY1 = mY1;
73807    this.mX2 = mX2;
73808    this.mY2 = mY2;
73809  }
73810
73811  _createClass(KeySpline, [{
73812    key: "get",
73813    value: function get(aX) {
73814      if (this.mX1 == this.mY1 && this.mX2 == this.mY2) return aX; // linear
73815
73816      return this.CalcBezier(this.GetTForX(aX), this.mY1, this.mY2);
73817    }
73818  }, {
73819    key: "A",
73820    value: function A(aA1, aA2) {
73821      return 1.0 - 3.0 * aA2 + 3.0 * aA1;
73822    }
73823  }, {
73824    key: "B",
73825    value: function B(aA1, aA2) {
73826      return 3.0 * aA2 - 6.0 * aA1;
73827    }
73828  }, {
73829    key: "C",
73830    value: function C(aA1) {
73831      return 3.0 * aA1;
73832    } // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
73833
73834  }, {
73835    key: "CalcBezier",
73836    value: function CalcBezier(aT, aA1, aA2) {
73837      return ((this.A(aA1, aA2) * aT + this.B(aA1, aA2)) * aT + this.C(aA1)) * aT;
73838    } // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
73839
73840  }, {
73841    key: "GetSlope",
73842    value: function GetSlope(aT, aA1, aA2) {
73843      return 3.0 * this.A(aA1, aA2) * aT * aT + 2.0 * this.B(aA1, aA2) * aT + this.C(aA1);
73844    }
73845  }, {
73846    key: "GetTForX",
73847    value: function GetTForX(aX) {
73848      // Newton raphson iteration
73849      var aGuessT = aX;
73850
73851      for (var i = 0; i < 4; ++i) {
73852        var currentSlope = this.GetSlope(aGuessT, this.mX1, this.mX2);
73853        if (currentSlope == 0.0) return aGuessT;
73854        var currentX = this.CalcBezier(aGuessT, this.mX1, this.mX2) - aX;
73855        aGuessT -= currentX / currentSlope;
73856      }
73857
73858      return aGuessT;
73859    }
73860  }]);
73861
73862  return KeySpline;
73863}();
73864
73865;
73866
73867var MultiSpline = /*#__PURE__*/function () {
73868  function MultiSpline() {
73869    _classCallCheck(this, MultiSpline);
73870
73871    this.keySplines = [];
73872    this.segments = [];
73873    this.x0 = 0;
73874    this.y0 = 0;
73875  }
73876
73877  _createClass(MultiSpline, [{
73878    key: "add",
73879    value: function add(mX1, mY1, mX2, mY2, x1, y1) {
73880      var ks = new KeySpline(mX1, mY1, mX2, mY2);
73881      var x0 = this.x0;
73882      var y0 = this.y0;
73883
73884      if (this.segments.length) {
73885        x0 = this.segments[this.segments.length - 1][1].x;
73886        y0 = this.segments[this.segments.length - 1][1].y;
73887      }
73888
73889      this.keySplines.push(ks);
73890      this.segments.push([{
73891        x: x0,
73892        y: y0
73893      }, {
73894        x: x1,
73895        y: y1
73896      }]);
73897    }
73898  }, {
73899    key: "get",
73900    value: function get(x) {
73901      var index = -1;
73902
73903      for (var i = 0; i < this.segments.length; i++) {
73904        if (x >= this.segments[i][0].x && x < this.segments[i][1].x) {
73905          index = i;
73906          break;
73907        }
73908      }
73909
73910      if (index < 0) {
73911        return 0;
73912      }
73913
73914      var seg = this.segments[index];
73915      var ks = this.keySplines[index];
73916      var perc = (x - seg[0].x) / (seg[1].x - seg[0].x);
73917
73918      if (index % 2 == 0) {
73919        return MathUtils.lerp(seg[0].y, seg[1].y, ks.get(perc));
73920      } else {
73921        return MathUtils.lerp(seg[1].y, seg[0].y, ks.get(1 - perc));
73922      }
73923    }
73924  }]);
73925
73926  return MultiSpline;
73927}();
73928
73929exports.MultiSpline = MultiSpline;
73930},{}],"utils/colorUtils.js":[function(require,module,exports) {
73931"use strict";
73932
73933Object.defineProperty(exports, "__esModule", {
73934  value: true
73935});
73936exports.ColorUtils = exports.Palette = void 0;
73937
73938var _mathUtils = require("./mathUtils");
73939
73940var paper = _interopRequireWildcard(require("paper"));
73941
73942function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
73943
73944function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
73945
73946function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
73947
73948function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
73949
73950function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
73951
73952var Palette = /*#__PURE__*/function () {
73953  function Palette(colors) {
73954    _classCallCheck(this, Palette);
73955
73956    var scope = paper.default;
73957    this.colors = colors.map(function (c) {
73958      return {
73959        light: new scope.Color(c[0]).convert('hsb'),
73960        dark: new scope.Color(c[1]).convert('hsb')
73961      };
73962    });
73963  }
73964
73965  _createClass(Palette, [{
73966    key: "select",
73967    value: function select(variance) {
73968      var scope = paper.default;
73969      var pair = this.colors[Math.floor(Math.random() * this.colors.length)];
73970
73971      var varColor = function varColor(c) {
73972        return new scope.Color({
73973          hue: c.hue + 360 * _mathUtils.MathUtils.gaussian(0, variance),
73974          saturation: c.saturation + _mathUtils.MathUtils.gaussian(0, variance),
73975          brightness: c.brightness + _mathUtils.MathUtils.gaussian(0, variance)
73976        });
73977      };
73978
73979      return {
73980        light: varColor(pair.light),
73981        dark: varColor(pair.dark)
73982      };
73983    }
73984  }]);
73985
73986  return Palette;
73987}();
73988
73989exports.Palette = Palette;
73990
73991var ColorUtils = /*#__PURE__*/function () {
73992  function ColorUtils() {
73993    _classCallCheck(this, ColorUtils);
73994  }
73995
73996  _createClass(ColorUtils, null, [{
73997    key: "addRGB",
73998    value: function addRGB(color, red, green, blue) {
73999      color.red = color.red + red;
74000      color.green = color.green + green;
74001      color.blue = color.blue + blue;
74002    }
74003  }, {
74004    key: "lerp",
74005    value: function lerp(color0, color1, amt) {
74006      return new paper.default.Color(_mathUtils.MathUtils.lerp(color0.red, color1.red, amt), _mathUtils.MathUtils.lerp(color0.green, color1.green, amt), _mathUtils.MathUtils.lerp(color0.blue, color1.blue, amt));
74007    } // Generates random color from string hash.
74008
74009  }, {
74010    key: "fromStringHash",
74011    value: function fromStringHash(str) {
74012      // Compute hash from string
74013      // Source http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
74014      var hash = 0,
74015          i,
74016          chr;
74017
74018      for (i = 0; i < str.length; i++) {
74019        chr = str.charCodeAt(i);
74020        hash = (hash << 5) - hash + chr;
74021        hash |= 0; // Convert to 32bit integer
74022      } // Hash to rgb color.
74023
74024
74025      var r = hash & 255;
74026      var g = (hash & 255 << 8) >> 8;
74027      var b = (hash & 255 << 16) >> 16;
74028      return new paper.default.Color(r / 255, g / 255, b / 255);
74029    }
74030  }]);
74031
74032  return ColorUtils;
74033}();
74034
74035exports.ColorUtils = ColorUtils;
74036},{"./mathUtils":"utils/mathUtils.js","paper":"node_modules/paper/dist/paper-full.js"}],"illustrationGen/skeleton.js":[function(require,module,exports) {
74037"use strict";
74038
74039Object.defineProperty(exports, "__esModule", {
74040  value: true
74041});
74042exports.Skeleton = exports.Bone = exports.allPartNames = exports.facePartName2Index = void 0;
74043
74044var paper = _interopRequireWildcard(require("paper"));
74045
74046var _svgUtils = require("../utils/svgUtils");
74047
74048var _mathUtils = require("../utils/mathUtils");
74049
74050var _colorUtils = require("../utils/colorUtils");
74051
74052function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
74053
74054function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
74055
74056function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
74057
74058function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
74059
74060function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
74061
74062function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
74063
74064function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
74065
74066function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
74067
74068function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
74069
74070function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
74071
74072function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
74073
74074var MIN_POSE_SCORE = 0.1;
74075var MIN_FACE_SCORE = 0.8;
74076var posePartNames = ['leftAnkle', 'leftKnee', 'leftHip', 'leftWrist', 'leftElbow', 'leftShoulder', 'rightAnkle', 'rightKnee', 'rightHip', 'rightWrist', 'rightElbow', 'rightShoulder', 'leftEar', 'rightEar']; // Mapping between face part names and their vertex indices in TF face mesh.
74077
74078var facePartName2Index = {
74079  'topMid': 10,
74080  'rightTop0': 67,
74081  'rightTop1': 54,
74082  'leftTop0': 297,
74083  'leftTop1': 284,
74084  'rightJaw0': 21,
74085  'rightJaw1': 162,
74086  'rightJaw2': 127,
74087  'rightJaw3': 234,
74088  'rightJaw4': 132,
74089  'rightJaw5': 172,
74090  'rightJaw6': 150,
74091  'rightJaw7': 176,
74092  'jawMid': 152,
74093  // 0 - 8
74094  'leftJaw7': 400,
74095  'leftJaw6': 379,
74096  'leftJaw5': 397,
74097  'leftJaw4': 361,
74098  'leftJaw3': 454,
74099  'leftJaw2': 356,
74100  'leftJaw1': 389,
74101  'leftJaw0': 251,
74102  // 9 - 16
74103  'rightBrow0': 46,
74104  'rightBrow1': 53,
74105  'rightBrow2': 52,
74106  'rightBrow3': 65,
74107  'rightBrow4': 55,
74108  // 17 - 21
74109  'leftBrow4': 285,
74110  'leftBrow3': 295,
74111  'leftBrow2': 282,
74112  'leftBrow1': 283,
74113  'leftBrow0': 276,
74114  // 22 - 26
74115  'nose0': 6,
74116  'nose1': 197,
74117  'nose2': 195,
74118  'nose3': 5,
74119  // 27 - 30
74120  'rightNose0': 48,
74121  'rightNose1': 220,
74122  'nose4': 4,
74123  'leftNose1': 440,
74124  'leftNose0': 278,
74125  // 31 - 35
74126  'rightEye0': 33,
74127  'rightEye1': 160,
74128  'rightEye2': 158,
74129  'rightEye3': 133,
74130  'rightEye4': 153,
74131  'rightEye5': 144,
74132  // 36 - 41
74133  'leftEye3': 362,
74134  'leftEye2': 385,
74135  'leftEye1': 387,
74136  'leftEye0': 263,
74137  'leftEye5': 373,
74138  'leftEye4': 380,
74139  // 42 - 47
74140  'rightMouthCorner': 61,
74141  'rightUpperLipTop0': 40,
74142  'rightUpperLipTop1': 37,
74143  'upperLipTopMid': 0,
74144  'leftUpperLipTop1': 267,
74145  'leftUpperLipTop0': 270,
74146  'leftMouthCorner': 291,
74147  // 48 - 54
74148  'leftLowerLipBottom0': 321,
74149  'leftLowerLipBottom1': 314,
74150  'lowerLipBottomMid': 17,
74151  'rightLowerLipBottom1': 84,
74152  'rightLowerLipBottom0': 91,
74153  // 55 - 59
74154  'rightMiddleLip': 78,
74155  'rightUpperLipBottom1': 81,
74156  'upperLipBottomMid': 13,
74157  'leftUpperLipBottom1': 311,
74158  'leftMiddleLip': 308,
74159  // 60 - 64
74160  'leftLowerLipTop0': 402,
74161  'lowerLipTopMid': 14,
74162  'rightLowerLipTop0': 178 // 65 - 67
74163
74164};
74165exports.facePartName2Index = facePartName2Index;
74166var facePartNames = ['topMid', 'rightTop0', 'rightTop1', 'leftTop0', 'leftTop1', 'rightJaw0', 'rightJaw1', 'rightJaw2', 'rightJaw3', 'rightJaw4', 'rightJaw5', 'rightJaw6', 'rightJaw7', 'jawMid', // 0 - 8
74167'leftJaw7', 'leftJaw6', 'leftJaw5', 'leftJaw4', 'leftJaw3', 'leftJaw2', 'leftJaw1', 'leftJaw0', // 9 - 16
74168'rightBrow0', 'rightBrow1', 'rightBrow2', 'rightBrow3', 'rightBrow4', // 17 - 21
74169'leftBrow4', 'leftBrow3', 'leftBrow2', 'leftBrow1', 'leftBrow0', // 22 - 26
74170'nose0', 'nose1', 'nose2', 'nose3', // 27 - 30
74171'rightNose0', 'rightNose1', 'nose4', 'leftNose1', 'leftNose0', // 31 - 35
74172'rightEye0', 'rightEye1', 'rightEye2', 'rightEye3', 'rightEye4', 'rightEye5', // 36 - 41
74173'leftEye3', 'leftEye2', 'leftEye1', 'leftEye0', 'leftEye5', 'leftEye4', // 42 - 47
74174'rightMouthCorner', 'rightUpperLipTop0', 'rightUpperLipTop1', 'upperLipTopMid', 'leftUpperLipTop1', 'leftUpperLipTop0', 'leftMouthCorner', // 48 - 54
74175'leftLowerLipBottom0', 'leftLowerLipBottom1', 'lowerLipBottomMid', 'rightLowerLipBottom1', 'rightLowerLipBottom0', // 55 - 59
74176'rightMiddleLip', 'rightUpperLipBottom1', 'upperLipBottomMid', 'leftUpperLipBottom1', 'leftMiddleLip', // 60 - 64
74177'leftLowerLipTop0', 'lowerLipTopMid', 'rightLowerLipTop0' // 65 - 67
74178];
74179var allPartNames = posePartNames.concat(facePartNames); // Represents a bone formed by two part keypoints.
74180
74181exports.allPartNames = allPartNames;
74182
74183var Bone = /*#__PURE__*/function () {
74184  function Bone() {
74185    _classCallCheck(this, Bone);
74186  }
74187
74188  _createClass(Bone, [{
74189    key: "set",
74190    value: function set(kp0, kp1, skeleton, type) {
74191      this.name = "".concat(kp0.name, "-").concat(kp1.name);
74192      this.kp0 = kp0;
74193      this.kp1 = kp1;
74194      this.skeleton = skeleton;
74195      this.type = type;
74196      this.boneColor = _colorUtils.ColorUtils.fromStringHash(this.name);
74197      this.boneColor.saturation += 0.5;
74198      return this;
74199    }
74200  }, {
74201    key: "getPointTransform",
74202    // Finds a point's bone transform.
74203    // Let anchor be the closest point on the bone to the point.
74204    // A point's bone transformation is the transformation from anchor to the point.
74205    value: function getPointTransform(p) {
74206      var dir = this.kp1.position.subtract(this.kp0.position).normalize();
74207      var n = dir.clone();
74208      n.angle += 90;
74209
74210      var closestP = _mathUtils.MathUtils.getClosestPointOnSegment(this.kp0.position, this.kp1.position, p);
74211
74212      var v = p.subtract(closestP);
74213      var dirProjD = v.dot(dir);
74214      var dirProjN = v.dot(n);
74215      var d = this.kp0.position.subtract(this.kp1.position).length;
74216      var anchorPerc = closestP.subtract(this.kp0.position).length / d;
74217      return {
74218        transform: new paper.default.Point(dirProjD, dirProjN),
74219        anchorPerc: anchorPerc
74220      };
74221    } // Finds a point's current position from the current bone position.
74222
74223  }, {
74224    key: "transform",
74225    value: function transform(trans) {
74226      if (!this.kp1.currentPosition || !this.kp0.currentPosition) {
74227        return;
74228      } // Scale distance from anchor point base on bone type.
74229      // All face bones will share one distance scale. All body bones share another.
74230
74231
74232      var scale = this.type === 'face' ? this.skeleton.currentFaceScale : this.skeleton.currentBodyScale;
74233      var dir = this.kp1.currentPosition.subtract(this.kp0.currentPosition).normalize();
74234      var n = dir.clone();
74235      n.angle += 90;
74236      var anchor = this.kp0.currentPosition.multiply(1 - trans.anchorPerc).add(this.kp1.currentPosition.multiply(trans.anchorPerc));
74237      var p = anchor.add(dir.multiply(trans.transform.x * scale)).add(n.multiply(trans.transform.y * scale));
74238      return p;
74239    }
74240  }]);
74241
74242  return Bone;
74243}();
74244
74245exports.Bone = Bone;
74246
74247function getKeyPointFromSVG(group, partName) {
74248  var shape = _svgUtils.SVGUtils.findFirstItemWithPrefix(group, partName);
74249
74250  return {
74251    position: shape.bounds.center,
74252    name: partName
74253  };
74254}
74255
74256function getPartFromPose(pose, name) {
74257  if (!pose || !pose.keypoints) {
74258    return null;
74259  }
74260
74261  var part = pose.keypoints.find(function (kp) {
74262    return kp.part === name;
74263  });
74264  return {
74265    position: new paper.default.Point(part.position.x, part.position.y),
74266    score: part.score
74267  };
74268}
74269
74270function getKeypointFromFaceFrame(face, i) {
74271  if (!face || !face.scaledMesh || !face.scaledMesh.length) ;
74272  return new paper.default.Point(face.positions[i * 2], face.positions[i * 2 + 1]);
74273} // Represents a full body skeleton.
74274
74275
74276var Skeleton = /*#__PURE__*/function () {
74277  function Skeleton(scope) {
74278    var _this = this;
74279
74280    _classCallCheck(this, Skeleton);
74281
74282    var skeletonGroup = _svgUtils.SVGUtils.findFirstItemWithPrefix(scope.project, 'skeleton'); // Pose
74283
74284
74285    var leftAnkle = getKeyPointFromSVG(skeletonGroup, 'leftAnkle');
74286    var leftKnee = getKeyPointFromSVG(skeletonGroup, 'leftKnee');
74287    var leftHip = getKeyPointFromSVG(skeletonGroup, 'leftHip');
74288    var leftWrist = getKeyPointFromSVG(skeletonGroup, 'leftWrist');
74289    var leftElbow = getKeyPointFromSVG(skeletonGroup, 'leftElbow');
74290    var leftShoulder = getKeyPointFromSVG(skeletonGroup, 'leftShoulder');
74291    var rightAnkle = getKeyPointFromSVG(skeletonGroup, 'rightAnkle');
74292    var rightKnee = getKeyPointFromSVG(skeletonGroup, 'rightKnee');
74293    var rightHip = getKeyPointFromSVG(skeletonGroup, 'rightHip');
74294    var rightWrist = getKeyPointFromSVG(skeletonGroup, 'rightWrist');
74295    var rightElbow = getKeyPointFromSVG(skeletonGroup, 'rightElbow');
74296    var rightShoulder = getKeyPointFromSVG(skeletonGroup, 'rightShoulder'); // Face
74297
74298    var topMid = getKeyPointFromSVG(skeletonGroup, 'topMid');
74299    var rightTop0 = getKeyPointFromSVG(skeletonGroup, 'rightTop0');
74300    var rightTop1 = getKeyPointFromSVG(skeletonGroup, 'rightTop1');
74301    var leftTop0 = getKeyPointFromSVG(skeletonGroup, 'leftTop0');
74302    var leftTop1 = getKeyPointFromSVG(skeletonGroup, 'leftTop1');
74303    var leftJaw2 = getKeyPointFromSVG(skeletonGroup, 'leftJaw2');
74304    var leftJaw3 = getKeyPointFromSVG(skeletonGroup, 'leftJaw3');
74305    var leftJaw4 = getKeyPointFromSVG(skeletonGroup, 'leftJaw4');
74306    var leftJaw5 = getKeyPointFromSVG(skeletonGroup, 'leftJaw5');
74307    var leftJaw6 = getKeyPointFromSVG(skeletonGroup, 'leftJaw6');
74308    var leftJaw7 = getKeyPointFromSVG(skeletonGroup, 'leftJaw7');
74309    var jawMid = getKeyPointFromSVG(skeletonGroup, 'jawMid');
74310    var rightJaw2 = getKeyPointFromSVG(skeletonGroup, 'rightJaw2');
74311    var rightJaw3 = getKeyPointFromSVG(skeletonGroup, 'rightJaw3');
74312    var rightJaw4 = getKeyPointFromSVG(skeletonGroup, 'rightJaw4');
74313    var rightJaw5 = getKeyPointFromSVG(skeletonGroup, 'rightJaw5');
74314    var rightJaw6 = getKeyPointFromSVG(skeletonGroup, 'rightJaw6');
74315    var rightJaw7 = getKeyPointFromSVG(skeletonGroup, 'rightJaw7');
74316    var nose0 = getKeyPointFromSVG(skeletonGroup, 'nose0');
74317    var nose1 = getKeyPointFromSVG(skeletonGroup, 'nose1');
74318    var nose2 = getKeyPointFromSVG(skeletonGroup, 'nose2');
74319    var nose3 = getKeyPointFromSVG(skeletonGroup, 'nose3');
74320    var nose4 = getKeyPointFromSVG(skeletonGroup, 'nose4');
74321    var leftNose0 = getKeyPointFromSVG(skeletonGroup, 'leftNose0');
74322    var leftNose1 = getKeyPointFromSVG(skeletonGroup, 'leftNose1');
74323    var rightNose0 = getKeyPointFromSVG(skeletonGroup, 'rightNose0');
74324    var rightNose1 = getKeyPointFromSVG(skeletonGroup, 'rightNose1');
74325    var leftEye0 = getKeyPointFromSVG(skeletonGroup, 'leftEye0');
74326    var leftEye1 = getKeyPointFromSVG(skeletonGroup, 'leftEye1');
74327    var leftEye2 = getKeyPointFromSVG(skeletonGroup, 'leftEye2');
74328    var leftEye3 = getKeyPointFromSVG(skeletonGroup, 'leftEye3');
74329    var leftEye4 = getKeyPointFromSVG(skeletonGroup, 'leftEye4');
74330    var leftEye5 = getKeyPointFromSVG(skeletonGroup, 'leftEye5');
74331    var rightEye0 = getKeyPointFromSVG(skeletonGroup, 'rightEye0');
74332    var rightEye1 = getKeyPointFromSVG(skeletonGroup, 'rightEye1');
74333    var rightEye2 = getKeyPointFromSVG(skeletonGroup, 'rightEye2');
74334    var rightEye3 = getKeyPointFromSVG(skeletonGroup, 'rightEye3');
74335    var rightEye4 = getKeyPointFromSVG(skeletonGroup, 'rightEye4');
74336    var rightEye5 = getKeyPointFromSVG(skeletonGroup, 'rightEye5');
74337    var leftBrow0 = getKeyPointFromSVG(skeletonGroup, 'leftBrow0');
74338    var leftBrow1 = getKeyPointFromSVG(skeletonGroup, 'leftBrow1');
74339    var leftBrow2 = getKeyPointFromSVG(skeletonGroup, 'leftBrow2');
74340    var leftBrow3 = getKeyPointFromSVG(skeletonGroup, 'leftBrow3');
74341    var leftBrow4 = getKeyPointFromSVG(skeletonGroup, 'leftBrow4');
74342    var rightBrow0 = getKeyPointFromSVG(skeletonGroup, 'rightBrow0');
74343    var rightBrow1 = getKeyPointFromSVG(skeletonGroup, 'rightBrow1');
74344    var rightBrow2 = getKeyPointFromSVG(skeletonGroup, 'rightBrow2');
74345    var rightBrow3 = getKeyPointFromSVG(skeletonGroup, 'rightBrow3');
74346    var rightBrow4 = getKeyPointFromSVG(skeletonGroup, 'rightBrow4');
74347    var leftMouthCorner = getKeyPointFromSVG(skeletonGroup, 'leftMouthCorner');
74348    var leftUpperLipTop0 = getKeyPointFromSVG(skeletonGroup, 'leftUpperLipTop0');
74349    var leftUpperLipTop1 = getKeyPointFromSVG(skeletonGroup, 'leftUpperLipTop1');
74350    var upperLipTopMid = getKeyPointFromSVG(skeletonGroup, 'upperLipTopMid');
74351    var rightMouthCorner = getKeyPointFromSVG(skeletonGroup, 'rightMouthCorner');
74352    var rightUpperLipTop0 = getKeyPointFromSVG(skeletonGroup, 'rightUpperLipTop0');
74353    var rightUpperLipTop1 = getKeyPointFromSVG(skeletonGroup, 'rightUpperLipTop1');
74354    var rightMiddleLip = getKeyPointFromSVG(skeletonGroup, 'rightMiddleLip');
74355    var rightUpperLipBottom1 = getKeyPointFromSVG(skeletonGroup, 'rightUpperLipBottom1');
74356    var leftMiddleLip = getKeyPointFromSVG(skeletonGroup, 'leftMiddleLip');
74357    var leftUpperLipBottom1 = getKeyPointFromSVG(skeletonGroup, 'leftUpperLipBottom1');
74358    var upperLipBottomMid = getKeyPointFromSVG(skeletonGroup, 'upperLipBottomMid');
74359    var rightLowerLipTop0 = getKeyPointFromSVG(skeletonGroup, 'rightLowerLipTop0');
74360    var leftLowerLipTop0 = getKeyPointFromSVG(skeletonGroup, 'leftLowerLipTop0');
74361    var lowerLipTopMid = getKeyPointFromSVG(skeletonGroup, 'lowerLipTopMid');
74362    var rightLowerLipBottom0 = getKeyPointFromSVG(skeletonGroup, 'rightLowerLipBottom0');
74363    var rightLowerLipBottom1 = getKeyPointFromSVG(skeletonGroup, 'rightLowerLipBottom1');
74364    var leftLowerLipBottom0 = getKeyPointFromSVG(skeletonGroup, 'leftLowerLipBottom0');
74365    var leftLowerLipBottom1 = getKeyPointFromSVG(skeletonGroup, 'leftLowerLipBottom1');
74366    var lowerLipBottomMid = getKeyPointFromSVG(skeletonGroup, 'lowerLipBottomMid');
74367    this.bLeftShoulderRightShoulder = new Bone().set(leftShoulder, rightShoulder, this, 'body');
74368    this.bRightShoulderRightHip = new Bone().set(rightShoulder, rightHip, this, 'body');
74369    this.bLeftHipRightHip = new Bone().set(leftHip, rightHip, this, 'body');
74370    this.bLeftShoulderLeftHip = new Bone().set(leftShoulder, leftHip, this, 'body');
74371    this.bLeftShoulderLeftElbow = new Bone().set(leftShoulder, leftElbow, this, 'body');
74372    this.bLeftElbowLeftWrist = new Bone().set(leftElbow, leftWrist, this, 'body');
74373    this.bRightShoulderRightElbow = new Bone().set(rightShoulder, rightElbow, this, 'body');
74374    this.bRightElbowRightWrist = new Bone().set(rightElbow, rightWrist, this, 'body');
74375    this.bLeftHipLeftKnee = new Bone().set(leftHip, leftKnee, this, 'body');
74376    this.bLeftKneeLeftAnkle = new Bone().set(leftKnee, leftAnkle, this, 'body');
74377    this.bRightHipRightKnee = new Bone().set(rightHip, rightKnee, this, 'body');
74378    this.bRightKneeRightAnkle = new Bone().set(rightKnee, rightAnkle, this, 'body');
74379    this.bTopMidRightTop0 = new Bone().set(topMid, rightTop0, this, 'face');
74380    this.bTopMidLeftTop0 = new Bone().set(topMid, leftTop0, this, 'face');
74381    this.bLeftTop0LeftTop1 = new Bone().set(leftTop0, leftTop1, this, 'face');
74382    this.bLeftTop1LeftJaw2 = new Bone().set(leftTop1, leftJaw2, this, 'face');
74383    this.bLeftJaw2LeftJaw3 = new Bone().set(leftJaw2, leftJaw3, this, 'face');
74384    this.bLeftJaw3LeftJaw4 = new Bone().set(leftJaw3, leftJaw4, this, 'face');
74385    this.bLeftJaw4LeftJaw5 = new Bone().set(leftJaw4, leftJaw5, this, 'face');
74386    this.bLeftJaw5LeftJaw6 = new Bone().set(leftJaw5, leftJaw6, this, 'face');
74387    this.bLeftJaw6LeftJaw7 = new Bone().set(leftJaw6, leftJaw7, this, 'face');
74388    this.bLeftJaw7JawMid = new Bone().set(leftJaw7, jawMid, this, 'face');
74389    this.bRightTop0RightTop1 = new Bone().set(rightTop0, rightTop1, this, 'face');
74390    this.bRightTop1RightJaw2 = new Bone().set(rightTop1, rightJaw2, this, 'face');
74391    this.bRightJaw2RightJaw3 = new Bone().set(rightJaw2, rightJaw3, this, 'face');
74392    this.bRightJaw3RightJaw4 = new Bone().set(rightJaw3, rightJaw4, this, 'face');
74393    this.bRightJaw4RightJaw5 = new Bone().set(rightJaw4, rightJaw5, this, 'face');
74394    this.bRightJaw5RightJaw6 = new Bone().set(rightJaw5, rightJaw6, this, 'face');
74395    this.bRightJaw6RightJaw7 = new Bone().set(rightJaw6, rightJaw7, this, 'face');
74396    this.bRightJaw7JawMid = new Bone().set(rightJaw7, jawMid, this, 'face');
74397    this.bLeftEye0LeftEye1 = new Bone().set(leftEye0, leftEye1, this, 'face');
74398    this.bLeftEye1LeftEye2 = new Bone().set(leftEye1, leftEye2, this, 'face');
74399    this.bLeftEye2LeftEye3 = new Bone().set(leftEye2, leftEye3, this, 'face');
74400    this.bLeftEye3LeftEye4 = new Bone().set(leftEye3, leftEye4, this, 'face');
74401    this.bLeftEye4LeftEye5 = new Bone().set(leftEye4, leftEye5, this, 'face');
74402    this.bLeftEye5LeftEye0 = new Bone().set(leftEye5, leftEye0, this, 'face');
74403    this.bRightEye0RightEye1 = new Bone().set(rightEye0, rightEye1, this, 'face');
74404    this.bRightEye1RightEye2 = new Bone().set(rightEye1, rightEye2, this, 'face');
74405    this.bRightEye2RightEye3 = new Bone().set(rightEye2, rightEye3, this, 'face');
74406    this.bRightEye3RightEye4 = new Bone().set(rightEye3, rightEye4, this, 'face');
74407    this.bRightEye4RightEye5 = new Bone().set(rightEye4, rightEye5, this, 'face');
74408    this.bRightEye5RightEye0 = new Bone().set(rightEye5, rightEye0, this, 'face');
74409    this.bLeftBrow0LeftBrow1 = new Bone().set(leftBrow0, leftBrow1, this, 'face');
74410    this.bLeftBrow1LeftBrow2 = new Bone().set(leftBrow1, leftBrow2, this, 'face');
74411    this.bLeftBrow2LeftBrow3 = new Bone().set(leftBrow2, leftBrow3, this, 'face');
74412    this.bLeftBrow3LeftBrow4 = new Bone().set(leftBrow3, leftBrow4, this, 'face');
74413    this.bRightBrow0RightBrow1 = new Bone().set(rightBrow0, rightBrow1, this, 'face');
74414    this.bRightBrow1RightBrow2 = new Bone().set(rightBrow1, rightBrow2, this, 'face');
74415    this.bRightBrow2RightBrow3 = new Bone().set(rightBrow2, rightBrow3, this, 'face');
74416    this.bRightBrow3RightBrow4 = new Bone().set(rightBrow3, rightBrow4, this, 'face');
74417    this.bNose0Nose1 = new Bone().set(nose0, nose1, this, 'face');
74418    this.bNose1Nose2 = new Bone().set(nose1, nose2, this, 'face');
74419    this.bNose2Nose3 = new Bone().set(nose2, nose3, this, 'face');
74420    this.bNose3Nose4 = new Bone().set(nose3, nose4, this, 'face');
74421    this.bLeftNose0LeftNose1 = new Bone().set(leftNose0, leftNose1, this, 'face');
74422    this.bLeftNose1Nose4 = new Bone().set(leftNose1, nose4, this, 'face');
74423    this.bRightNose0RightNose1 = new Bone().set(rightNose0, rightNose1, this, 'face');
74424    this.bRightNose1Nose4 = new Bone().set(rightNose1, nose4, this, 'face');
74425    this.bLeftMouthCornerLeftUpperLipTop0 = new Bone().set(leftMouthCorner, leftUpperLipTop0, this, 'face');
74426    this.bLeftUpperLipTop0LeftUpperLipTop1 = new Bone().set(leftUpperLipTop0, leftUpperLipTop1, this, 'face');
74427    this.bLeftUpperLipTop1UpperLipTopMid = new Bone().set(leftUpperLipTop1, upperLipTopMid, this, 'face');
74428    this.bRigthMouthCornerRigthUpperLipTop0 = new Bone().set(rightMouthCorner, rightUpperLipTop0, this, 'face');
74429    this.bRigthUpperLipTop0RigthUpperLipTop1 = new Bone().set(rightUpperLipTop0, rightUpperLipTop1, this, 'face');
74430    this.bRigthUpperLipTop1UpperLipTopMid = new Bone().set(rightUpperLipTop1, upperLipTopMid, this, 'face');
74431    this.bLeftMouthCornerLeftMiddleLip = new Bone().set(leftMouthCorner, leftMiddleLip, this, 'face');
74432    this.bLeftMiddleLipLeftUpperLipBottom1 = new Bone().set(leftMiddleLip, leftUpperLipBottom1, this, 'face');
74433    this.bLeftUpperLipBottom1UpperLipBottomMid = new Bone().set(leftUpperLipBottom1, upperLipBottomMid, this, 'face');
74434    this.bRightMouthCornerRightMiddleLip = new Bone().set(rightMouthCorner, rightMiddleLip, this, 'face');
74435    this.bRightMiddleLipRightUpperLipBottom1 = new Bone().set(rightMiddleLip, rightUpperLipBottom1, this, 'face');
74436    this.bRightUpperLipBottom1UpperLipBototmMid = new Bone().set(rightUpperLipBottom1, upperLipBottomMid, this, 'face');
74437    this.bLeftMiddleLipLeftLowerLipTop0 = new Bone().set(leftMiddleLip, leftLowerLipTop0, this, 'face');
74438    this.bLeftLowerLipTop0LowerLipTopMid = new Bone().set(leftLowerLipTop0, lowerLipTopMid, this, 'face');
74439    this.bRightMiddleLipRightLowerLipTop0 = new Bone().set(rightMiddleLip, rightLowerLipTop0, this, 'face');
74440    this.bRightLowerLipTop0LowerLipTopMid = new Bone().set(rightLowerLipTop0, lowerLipTopMid, this, 'face');
74441    this.bLeftMouthCornerLeftLowerLipBottom0 = new Bone().set(leftMouthCorner, leftLowerLipBottom0, this, 'face');
74442    this.bLeftLowerLipBottom0LeftLowerLipBottom1 = new Bone().set(leftLowerLipBottom0, leftLowerLipBottom1, this, 'face');
74443    this.bLeftLowerLipBottom1LowerLipBottomMid = new Bone().set(leftLowerLipBottom1, lowerLipBottomMid, this, 'face');
74444    this.bRightMouthCornerRightLowerLipBottom0 = new Bone().set(rightMouthCorner, rightLowerLipBottom0, this, 'face');
74445    this.bRightLowerLipBottom0RightLowerLipBottom1 = new Bone().set(rightLowerLipBottom0, rightLowerLipBottom1, this, 'face');
74446    this.bRightLowerLipBottom1LowerLipBottomMid = new Bone().set(rightLowerLipBottom1, lowerLipBottomMid, this, 'face');
74447    this.faceBones = [// Face
74448    this.bTopMidRightTop0, this.bRightTop0RightTop1, this.bTopMidLeftTop0, this.bLeftTop0LeftTop1, this.bLeftTop1LeftJaw2, this.bLeftJaw2LeftJaw3, this.bLeftJaw3LeftJaw4, this.bLeftJaw4LeftJaw5, this.bLeftJaw5LeftJaw6, this.bLeftJaw6LeftJaw7, this.bLeftJaw7JawMid, this.bRightTop1RightJaw2, this.bRightJaw2RightJaw3, this.bRightJaw3RightJaw4, this.bRightJaw4RightJaw5, this.bRightJaw5RightJaw6, this.bRightJaw6RightJaw7, this.bRightJaw7JawMid, this.bLeftEye0LeftEye1, this.bLeftEye1LeftEye2, this.bLeftEye2LeftEye3, this.bLeftEye3LeftEye4, this.bLeftEye4LeftEye5, this.bLeftEye5LeftEye0, this.bRightEye0RightEye1, this.bRightEye1RightEye2, this.bRightEye2RightEye3, this.bRightEye3RightEye4, this.bRightEye4RightEye5, this.bRightEye5RightEye0, this.bLeftBrow0LeftBrow1, this.bLeftBrow1LeftBrow2, this.bLeftBrow2LeftBrow3, this.bLeftBrow3LeftBrow4, this.bRightBrow0RightBrow1, this.bRightBrow1RightBrow2, this.bRightBrow2RightBrow3, this.bRightBrow3RightBrow4, this.bNose0Nose1, this.bNose1Nose2, this.bNose2Nose3, this.bNose3Nose4, this.bLeftNose0LeftNose1, this.bLeftNose1Nose4, this.bRightNose0RightNose1, this.bRightNose1Nose4, this.bLeftMouthCornerLeftUpperLipTop0, this.bLeftUpperLipTop0LeftUpperLipTop1, this.bLeftUpperLipTop1UpperLipTopMid, this.bRigthMouthCornerRigthUpperLipTop0, this.bRigthUpperLipTop0RigthUpperLipTop1, this.bRigthUpperLipTop1UpperLipTopMid, this.bLeftMouthCornerLeftMiddleLip, this.bLeftMiddleLipLeftUpperLipB
74448ottom1, this.bLeftUpperLipBottom1UpperLipBottomMid, this.bRightMouthCornerRightMiddleLip, this.bRightMiddleLipRightUpperLipBottom1, this.bRightUpperLipBottom1UpperLipBototmMid, this.bLeftMiddleLipLeftLowerLipTop0, this.bLeftLowerLipTop0LowerLipTopMid, this.bRightMiddleLipRightLowerLipTop0, this.bRightLowerLipTop0LowerLipTopMid, this.bLeftMouthCornerLeftLowerLipBottom0, this.bLeftLowerLipBottom0LeftLowerLipBottom1, this.bLeftLowerLipBottom1LowerLipBottomMid, this.bRightMouthCornerRightLowerLipBottom0, this.bRightLowerLipBottom0RightLowerLipBottom1, this.bRightLowerLipBottom1LowerLipBottomMid];
74449    this.bodyBones = [// Body
74450    this.bLeftShoulderRightShoulder, this.bRightShoulderRightHip, this.bLeftHipRightHip, this.bLeftShoulderLeftHip, this.bLeftShoulderLeftElbow, this.bLeftElbowLeftWrist, this.bRightShoulderRightElbow, this.bRightElbowRightWrist, this.bLeftHipLeftKnee, this.bLeftKneeLeftAnkle, this.bRightHipRightKnee, this.bRightKneeRightAnkle];
74451    this.bones = this.faceBones.concat(this.bodyBones);
74452    this.secondaryBones = [];
74453    this.parts = {};
74454    this.bodyLen0 = this.getTotalBoneLength(this.bodyBones);
74455    this.faceLen0 = this.getTotalBoneLength(this.faceBones);
74456    this.boneGroups = {
74457      'torso': [this.bLeftShoulderRightShoulder, this.bRightShoulderRightHip, this.bLeftHipRightHip, this.bLeftShoulderLeftHip],
74458      'leftLeg': [this.bLeftHipLeftKnee, this.bLeftKneeLeftAnkle],
74459      'rightLeg': [this.bRightHipRightKnee, this.bRightKneeRightAnkle],
74460      'leftArm': [this.bLeftShoulderLeftElbow, this.bLeftElbowLeftWrist],
74461      'rightArm': [this.bRightElbowRightWrist, this.bRightShoulderRightElbow],
74462      'face': this.faceBones
74463    };
74464    this.faceBones.forEach(function (bone) {
74465      var parts = [bone.kp0, bone.kp1];
74466      parts.forEach(function (part) {
74467        part.baseTransFunc = _mathUtils.MathUtils.getTransformFunc(_this.bLeftJaw2LeftJaw3.kp0.position, _this.bRightJaw2RightJaw3.kp0.position, part.position);
74468      });
74469    });
74470  }
74471
74472  _createClass(Skeleton, [{
74473    key: "update",
74474    value: function update(pose, face) {
74475      var _this2 = this;
74476
74477      if (pose.score < MIN_POSE_SCORE) {
74478        this.isValid = false;
74479        return;
74480      }
74481
74482      this.isValid = this.updatePoseParts(pose);
74483      if (!this.isValid) return;
74484      this.isValid = this.updateFaceParts(face);
74485      if (!this.isValid) return; // Update bones.
74486
74487      this.bones.forEach(function (bone) {
74488        var part0 = _this2.parts[bone.kp0.name];
74489        var part1 = _this2.parts[bone.kp1.name];
74490        bone.kp0.currentPosition = part0.position;
74491        bone.kp1.currentPosition = part1.position;
74492        bone.score = (part0.score + part1.score) / 2;
74493        bone.latestCenter = bone.kp1.currentPosition.add(bone.kp0.currentPosition).divide(2);
74494      }); // Update secondary bones.
74495
74496      var nosePos = this.bNose3Nose4.kp1.currentPosition;
74497      this.secondaryBones.forEach(function (bone) {
74498        bone.kp0.currentPosition = bone.kp0.transformFunc(bone.parent.kp0.currentPosition, nosePos);
74499        bone.kp1.currentPosition = bone.kp1.transformFunc(bone.parent.kp1.currentPosition, nosePos);
74500        bone.score = bone.parent.score;
74501        bone.latestCenter = bone.kp1.currentPosition.add(bone.kp0.currentPosition).divide(2);
74502      }); // Recompute face & body bone scale.
74503
74504      this.currentFaceScale = this.getTotalBoneLength(this.faceBones) / this.faceLen0;
74505      this.currentBodyScale = this.getTotalBoneLength(this.bodyBones) / this.bodyLen0;
74506      this.isValid = true;
74507    }
74508  }, {
74509    key: "updatePoseParts",
74510    value: function updatePoseParts(pose) {
74511      var _this3 = this;
74512
74513      posePartNames.forEach(function (partName) {
74514        // Use new and old pose's confidence scores as weights to compute the new part position.
74515        var part1 = getPartFromPose(pose, partName);
74516        var part0 = _this3.parts[partName] || part1;
74517        var weight0 = part0.score / (part1.score + part0.score);
74518        var weight1 = part1.score / (part1.score + part0.score);
74519        var pos = part0.position.multiply(weight0).add(part1.position.multiply(weight1));
74520        _this3.parts[partName] = {
74521          position: pos,
74522          score: part0.score * weight0 + part1.score * weight1
74523        };
74524      });
74525
74526      if (!this.parts['rightEar'] || !this.parts['leftEar']) {
74527        return false;
74528      }
74529
74530      return true;
74531    }
74532  }, {
74533    key: "updateFaceParts",
74534    value: function updateFaceParts(face) {
74535      var _this4 = this;
74536
74537      var posLeftEar = this.parts['leftEar'].position;
74538      var posRightEar = this.parts['rightEar'].position;
74539
74540      if (face && face.positions && face.positions.length && face.faceInViewConfidence > MIN_FACE_SCORE) {
74541        // Valid face results.
74542        for (var i = 0; i < facePartNames.length; i++) {
74543          var partName = facePartNames[i];
74544          var pos = getKeypointFromFaceFrame(face, i);
74545          if (!pos) continue;
74546          this.parts[partName] = {
74547            position: pos,
74548            score: face.faceInViewConfidence
74549          };
74550        } // Keep track of the transformation from pose ear positions to face ear positions.
74551        // This can be used to infer face position when face tracking is lost.
74552
74553
74554        this.leftEarP2FFunc = _mathUtils.MathUtils.getTransformFunc(posLeftEar, posRightEar, this.parts['leftJaw2'].position);
74555        this.rightEarP2FFunc = _mathUtils.MathUtils.getTransformFunc(posLeftEar, posRightEar, this.parts['rightJaw2'].position);
74556      } else {
74557        // Invalid face keypoints. Infer face keypoints from pose.
74558        var fLeftEar = this.leftEarP2FFunc ? this.leftEarP2FFunc(posLeftEar, posRightEar) : posLeftEar;
74559        var fRightEar = this.rightEarP2FFunc ? this.rightEarP2FFunc(posLeftEar, posRightEar) : posRightEar; // Also infer face scale from pose.
74560
74561        this.currentFaceScale = this.currentBodyScale;
74562        this.faceBones.forEach(function (bone) {
74563          var parts = [bone.kp0, bone.kp1];
74564          parts.forEach(function (part) {
74565            _this4.parts[part.name] = {
74566              position: part.baseTransFunc(fLeftEar, fRightEar),
74567              score: 1
74568            };
74569          });
74570        });
74571      }
74572
74573      return true;
74574    }
74575  }, {
74576    key: "findBoneGroup",
74577    value: function findBoneGroup(point) {
74578      var _this5 = this;
74579
74580      var minDistances = {};
74581      Object.keys(this.boneGroups).forEach(function (boneGroupKey) {
74582        var minDistance = Infinity;
74583        var boneGroup = _this5.boneGroups[boneGroupKey];
74584        boneGroup.forEach(function (bone) {
74585          var d = _mathUtils.MathUtils.getClosestPointOnSegment(bone.kp0.position, bone.kp1.position, point).getDistance(point);
74586
74587          minDistance = Math.min(minDistance, d);
74588        });
74589        minDistances[boneGroupKey] = minDistance;
74590      });
74591      var minDistance = Math.min.apply(Math, _toConsumableArray(Object.values(minDistances)));
74592      var selectedGroups = [];
74593      Object.keys(minDistances).forEach(function (key) {
74594        var distance = minDistances[key];
74595
74596        if (distance <= minDistance) {
74597          selectedGroups.push(_this5.boneGroups[key]);
74598        }
74599      });
74600      return selectedGroups.flatten();
74601    }
74602  }, {
74603    key: "getTotalBoneLength",
74604    value: function getTotalBoneLength(bones) {
74605      var totalLen = 0;
74606      bones.forEach(function (bone) {
74607        var d = (bone.kp0.currentPosition || bone.kp0.position).subtract(bone.kp1.currentPosition || bone.kp1.position);
74608        totalLen += d.length;
74609      });
74610      return totalLen;
74611    }
74612  }, {
74613    key: "debugDraw",
74614    value: function debugDraw(scope) {
74615      var group = new scope.Group();
74616      scope.project.activeLayer.addChild(group);
74617      this.bones.forEach(function (bone) {
74618        var path = new scope.Path({
74619          segments: [bone.kp0.currentPosition, bone.kp1.currentPosition],
74620          strokeWidth: 2,
74621          strokeColor: bone.boneColor
74622        });
74623        group.addChild(path);
74624      }); // this.secondaryBones.forEach(bone => {
74625      //     let path = new scope.Path({
74626      //         segments: [bone.kp0.currentPosition, bone.kp1.currentPosition],
74627      //         strokeColor: '#00ff00',
74628      //         strokeWidth: 5,
74629      //     });
74630      //     group.addChild(path);
74631      // });
74632    }
74633  }, {
74634    key: "debugDrawLabels",
74635    value: function debugDrawLabels(scope) {
74636      var group = new scope.Group();
74637      scope.project.activeLayer.addChild(group);
74638      this.bones.forEach(function (bone) {
74639        var addLabel = function addLabel(kp, name) {
74640          var text = new scope.PointText({
74641            point: [kp.currentPosition.x, kp.currentPosition.y],
74642            content: name,
74643            fillColor: 'black',
74644            fontSize: 7
74645          });
74646          group.addChild(text);
74647        };
74648
74649        addLabel(bone.kp0, bone.kp0.name);
74650        addLabel(bone.kp1, bone.kp1.name);
74651      });
74652    }
74653  }, {
74654    key: "reset",
74655    value: function reset() {
74656      this.parts = [];
74657    }
74658  }], [{
74659    key: "getCurrentPosition",
74660    value: function getCurrentPosition(segment) {
74661      var position = new paper.default.Point();
74662      Object.keys(segment.skinning).forEach(function (boneName) {
74663        var bt = segment.skinning[boneName];
74664        position = position.add(bt.bone.transform(bt.transform).multiply(bt.weight));
74665      });
74666      return position;
74667    }
74668  }, {
74669    key: "flipPose",
74670    value: function flipPose(pose) {
74671      pose.keypoints.forEach(function (kp) {
74672        if (kp.part && kp.part.startsWith('left')) {
74673          kp.part = 'right' + kp.part.substring('left'.length, kp.part.length);
74674        } else if (kp.part && kp.part.startsWith('right')) {
74675          kp.part = 'left' + kp.part.substring('right'.length, kp.part.length);
74676        }
74677      });
74678    }
74679  }, {
74680    key: "flipFace",
74681    value: function flipFace(face) {
74682      Object.keys(facePartName2Index).forEach(function (partName) {
74683        if (partName.startsWith('left')) {
74684          var rightName = 'right' + partName.substr('left'.length, partName.length);
74685          var temp = face.scaledMesh[facePartName2Index[partName]];
74686          face.scaledMesh[facePartName2Index[partName]] = face.scaledMesh[facePartName2Index[rightName]];
74687          face.scaledMesh[facePartName2Index[rightName]] = temp;
74688        }
74689      });
74690    }
74691  }, {
74692    key: "getBoundingBox",
74693    value: function getBoundingBox(pose) {
74694      var minX = 100000;
74695      var maxX = -100000;
74696      var minY = 100000;
74697      var maxY = -100000;
74698
74699      var updateMinMax = function updateMinMax(x, y) {
74700        minX = Math.min(x, minX);
74701        maxX = Math.max(x, maxX);
74702        minY = Math.min(y, minY);
74703        maxY = Math.max(y, maxY);
74704      };
74705
74706      pose.frames.forEach(function (frame) {
74707        frame.pose.keypoints.forEach(function (kp) {
74708          updateMinMax(kp.position.x, kp.position.y);
74709        });
74710        var faceKeypoints = frame.face.positions;
74711
74712        for (var i = 0; i < faceKeypoints.length; i += 2) {
74713          updateMinMax(faceKeypoints[i], faceKeypoints[i + 1]);
74714        }
74715      });
74716      return [minX, maxX, minY, maxY];
74717    }
74718  }, {
74719    key: "translatePose",
74720    value: function translatePose(pose, d) {
74721      pose.frames.forEach(function (frame) {
74722        frame.pose.keypoints.forEach(function (kp) {
74723          kp.position.x += d.x;
74724          kp.position.y += d.y;
74725        });
74726        var faceKeypoints = frame.face.positions;
74727
74728        for (var i = 0; i < faceKeypoints.length; i += 2) {
74729          faceKeypoints[i] += d.x;
74730          faceKeypoints[i + 1] += d.y;
74731        }
74732      });
74733    }
74734  }, {
74735    key: "resizePose",
74736    value: function resizePose(pose, origin, scale) {
74737      pose.frames.forEach(function (frame) {
74738        frame.pose.keypoints.forEach(function (kp) {
74739          kp.position.x = origin.x + (kp.position.x - origin.x) * scale.x;
74740          kp.position.y = origin.y + (kp.position.y - origin.y) * scale.y;
74741        });
74742        var faceKeypoints = frame.face.positions;
74743
74744        for (var i = 0; i < faceKeypoints.length; i += 2) {
74745          faceKeypoints[i] = origin.x + (faceKeypoints[i] - origin.x) * scale.x;
74746          faceKeypoints[i + 1] = origin.y + (faceKeypoints[i + 1] - origin.y) * scale.y;
74747        }
74748      });
74749    }
74750  }, {
74751    key: "toFaceFrame",
74752    value: function toFaceFrame(faceDetection) {
74753      var frame = {
74754        positions: [],
74755        faceInViewConfidence: faceDetection.faceInViewConfidence
74756      };
74757
74758      for (var i = 0; i < facePartNames.length; i++) {
74759        var partName = facePartNames[i];
74760        var p = faceDetection.scaledMesh[facePartName2Index[partName]];
74761        frame.positions.push(p[0]);
74762        frame.positions.push(p[1]);
74763      }
74764
74765      return frame;
74766    }
74767  }]);
74768
74769  return Skeleton;
74770}();
74771
74772exports.Skeleton = Skeleton;
74773},{"paper":"node_modules/paper/dist/paper-full.js","../utils/svgUtils":"utils/svgUtils.js","../utils/mathUtils":"utils/mathUtils.js","../utils/colorUtils":"utils/colorUtils.js"}],"illustrationGen/illustration.js":[function(require,module,exports) {
74774"use strict";
74775
74776Object.defineProperty(exports, "__esModule", {
74777  value: true
74778});
74779exports.PoseIllustration = void 0;
74780
74781var _skeleton = require("./skeleton");
74782
74783var _mathUtils = require("../utils/mathUtils");
74784
74785var _svgUtils = require("../utils/svgUtils");
74786
74787var _colorUtils = require("../utils/colorUtils");
74788
74789function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
74790
74791function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
74792
74793function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
74794
74795var allPartNamesMap = {};
74796
74797_skeleton.allPartNames.forEach(function (name) {
74798  return allPartNamesMap[name] = 1;
74799});
74800
74801var MIN_CONFIDENCE_PATH_SCORE = 0.3; // Represents a skinned illustration.
74802
74803var PoseIllustration = /*#__PURE__*/function () {
74804  function PoseIllustration(scope) {
74805    _classCallCheck(this, PoseIllustration);
74806
74807    this.scope = scope;
74808    this.frames = [];
74809  }
74810
74811  _createClass(PoseIllustration, [{
74812    key: "updateSkeleton",
74813    value: function updateSkeleton(pose, face) {
74814      this.pose = pose;
74815      this.face = face;
74816      this.skeleton.update(pose, face);
74817
74818      if (!this.skeleton.isValid) {
74819        return;
74820      }
74821
74822      var getConfidenceScore = function getConfidenceScore(p) {
74823        return Object.keys(p.skinning).reduce(function (totalScore, boneName) {
74824          var bt = p.skinning[boneName];
74825          return totalScore + bt.bone.score * bt.weight;
74826        }, 0);
74827      };
74828
74829      this.skinnedPaths.forEach(function (skinnedPath) {
74830        var confidenceScore = 0;
74831        skinnedPath.segments.forEach(function (seg) {
74832          // Compute confidence score.
74833          confidenceScore += getConfidenceScore(seg.point); // Compute new positions for curve point and handles.
74834
74835          seg.point.currentPosition = _skeleton.Skeleton.getCurrentPosition(seg.point);
74836
74837          if (seg.handleIn) {
74838            seg.handleIn.currentPosition = _skeleton.Skeleton.getCurrentPosition(seg.handleIn);
74839          }
74840
74841          if (seg.handleOut) {
74842            seg.handleOut.currentPosition = _skeleton.Skeleton.getCurrentPosition(seg.handleOut);
74843          }
74844        });
74845        skinnedPath.confidenceScore = confidenceScore / (skinnedPath.segments.length || 1);
74846      });
74847    }
74848  }, {
74849    key: "draw",
74850    value: function draw() {
74851      if (!this.skeleton.isValid) {
74852        return;
74853      }
74854
74855      var scope = this.scope; // Add paths
74856
74857      this.skinnedPaths.forEach(function (skinnedPath) {
74858        // Do not render paths with low confidence scores.
74859        if (!skinnedPath.confidenceScore || skinnedPath.confidenceScore < MIN_CONFIDENCE_PATH_SCORE) {
74860          return;
74861        }
74862
74863        var path = new scope.Path({
74864          fillColor: skinnedPath.fillColor,
74865          strokeColor: skinnedPath.strokeColor,
74866          strokeWidth: skinnedPath.strokeWidth,
74867          closed: skinnedPath.closed
74868        });
74869        skinnedPath.segments.forEach(function (seg) {
74870          path.addSegment(seg.point.currentPosition, seg.handleIn ? seg.handleIn.currentPosition.subtract(seg.point.currentPosition) : null, seg.handleOut ? seg.handleOut.currentPosition.subtract(seg.point.currentPosition) : null);
74871        });
74872
74873        if (skinnedPath.closed) {
74874          path.closePath();
74875        }
74876
74877        scope.project.activeLayer.addChild(path);
74878      });
74879    }
74880  }, {
74881    key: "debugDraw",
74882    value: function debugDraw() {
74883      var scope = this.scope;
74884      var group = new scope.Group();
74885      scope.project.activeLayer.addChild(group);
74886
74887      var drawCircle = function drawCircle(p) {
74888        var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
74889        group.addChild(new scope.Path.Circle({
74890          center: [p.x, p.y],
74891          radius: opt.radius || 2,
74892          fillColor: opt.fillColor || 'red'
74893        }));
74894      };
74895
74896      var drawLine = function drawLine(p0, p1) {
74897        var opt = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
74898        group.addChild(new scope.Path({
74899          segments: [p0, p1],
74900          strokeColor: opt.strokeColor || 'red',
74901          strokeWidth: opt.strokeWidth || 1
74902        }));
74903      }; // Draw skeleton.
74904
74905
74906      this.skeleton.debugDraw(scope); // Draw curve and handles.
74907
74908      this.skinnedPaths.forEach(function (skinnedPath) {
74909        skinnedPath.segments.forEach(function (seg) {
74910          // Color represents weight influence from bones.
74911          var color = new scope.Color(0);
74912          Object.keys(seg.point.skinning).forEach(function (boneName) {
74913            var bt = seg.point.skinning[boneName];
74914
74915            _colorUtils.ColorUtils.addRGB(color, bt.weight * bt.bone.boneColor.red, bt.weight * bt.bone.boneColor.green, bt.weight * bt.bone.boneColor.blue);
74916
74917            var anchor = bt.bone.kp0.currentPosition.multiply(1 - bt.transform.anchorPerc).add(bt.bone.kp1.currentPosition.multiply(bt.transform.anchorPerc));
74918            drawLine(anchor, seg.point.currentPosition, {
74919              strokeColor: 'blue',
74920              strokeWidth: bt.weight
74921            });
74922          });
74923          drawCircle(seg.point.currentPosition, {
74924            fillColor: color
74925          });
74926          drawCircle(seg.handleIn.currentPosition, {
74927            fillColor: color
74928          });
74929          drawLine(seg.point.currentPosition, seg.handleIn.currentPosition, {
74930            strokeColor: color
74931          });
74932          drawCircle(seg.handleOut.currentPosition, {
74933            fillColor: color
74934          }, {
74935            strokeColor: color
74936          });
74937          drawLine(seg.point.currentPosition, seg.handleOut.currentPosition);
74938        });
74939      });
74940    }
74941  }, {
74942    key: "debugDrawLabel",
74943    value: function debugDrawLabel(scope) {
74944      this.skeleton.debugDrawLabels(scope);
74945    }
74946  }, {
74947    key: "bindSkeleton",
74948    value: function bindSkeleton(skeleton, skeletonScope) {
74949      var items = skeletonScope.project.getItems({
74950        recursive: true
74951      });
74952      items = items.filter(function (item) {
74953        return item.parent && item.parent.name && item.parent.name.startsWith('illustration');
74954      });
74955      this.skeleton = skeleton;
74956      this.skinnedPaths = []; // Only support rendering path and shapes for now.
74957
74958      for (var i = 0; i < items.length; i++) {
74959        var item = items[i];
74960
74961        if (_svgUtils.SVGUtils.isGroup(item)) {
74962          this.bindGroup(item, skeleton);
74963        } else if (_svgUtils.SVGUtils.isPath(item)) {
74964          this.bindPathToBones(item);
74965        } else if (_svgUtils.SVGUtils.isShape(item)) {
74966          this.bindPathToBones(item.toPath());
74967        }
74968      }
74969    }
74970  }, {
74971    key: "bindGroup",
74972    value: function bindGroup(group, skeleton) {
74973      var _this = this;
74974
74975      var paths = [];
74976      var keypoints = {};
74977      var items = group.getItems({
74978        recursive: true
74979      }); // Find all paths and included keypoints.
74980
74981      items.forEach(function (item) {
74982        var partName = item.name ? _skeleton.allPartNames.find(function (partName) {
74983          return item.name.startsWith(partName);
74984        }) : null;
74985
74986        if (partName) {
74987          keypoints[partName] = {
74988            position: item.bounds.center,
74989            name: partName
74990          };
74991        } else if (_svgUtils.SVGUtils.isPath(item)) {
74992          paths.push(item);
74993        } else if (_svgUtils.SVGUtils.isShape(item)) {
74994          paths.push(item.toPath());
74995        }
74996      });
74997      var secondaryBones = []; // Find all parent bones of the included keypoints.
74998
74999      var parentBones = skeleton.bones.filter(function (bone) {
75000        return keypoints[bone.kp0.name] && keypoints[bone.kp1.name];
75001      });
75002      var nosePos = skeleton.bNose3Nose4.kp1.position;
75003
75004      if (!parentBones.length) {
75005        return;
75006      } // Crete secondary bones for the included keypoints.
75007
75008
75009      parentBones.forEach(function (parentBone) {
75010        var kp0 = keypoints[parentBone.kp0.name];
75011        var kp1 = keypoints[parentBone.kp1.name];
75012        var secondaryBone = new _skeleton.Bone().set(kp0, kp1, parentBone.skeleton, parentBone.type);
75013        kp0.transformFunc = _mathUtils.MathUtils.getTransformFunc(parentBone.kp0.position, nosePos, kp0.position);
75014        kp1.transformFunc = _mathUtils.MathUtils.getTransformFunc(parentBone.kp1.position, nosePos, kp1.position);
75015        secondaryBone.parent = parentBone;
75016        secondaryBones.push(secondaryBone);
75017      });
75018      skeleton.secondaryBones = skeleton.secondaryBones.concat(secondaryBones);
75019      paths.forEach(function (path) {
75020        _this.bindPathToBones(path, secondaryBones);
75021      });
75022    } // Assign weights from bones for point.
75023    // Weight calculation is roughly based on linear blend skinning model.
75024
75025  }, {
75026    key: "getWeights",
75027    value: function getWeights(point, bones) {
75028      var totalW = 0;
75029      var weights = {};
75030      bones.forEach(function (bone) {
75031        var d = _mathUtils.MathUtils.getClosestPointOnSegment(bone.kp0.position, bone.kp1.position, point).getDistance(point); // Absolute weight = 1 / (distance * distance)
75032
75033
75034        var w = 1 / (d * d);
75035        weights[bone.name] = {
75036          value: w,
75037          bone: bone
75038        };
75039      });
75040      var values = Object.values(weights).sort(function (v0, v1) {
75041        return v1.value - v0.value;
75042      });
75043      weights = {};
75044      totalW = 0;
75045      values.forEach(function (v) {
75046        weights[v.bone.name] = v;
75047        totalW += v.value;
75048      });
75049
75050      if (totalW === 0) {
75051        // Point is outside of the influence zone of all bones. It will not be influence by any bone.
75052        return {};
75053      } // Normalize weights to sum up to 1.
75054
75055
75056      Object.values(weights).forEach(function (weight) {
75057        weight.value /= totalW;
75058      });
75059      return weights;
75060    } // Binds a path to bones by compute weight contribution from each bones for each path segment.
75061    // If selectedBones are set, bind directly to the selected bones. Otherwise auto select the bone group closest to each segment.
75062
75063  }, {
75064    key: "bindPathToBones",
75065    value: function bindPathToBones(path, selectedBones) {
75066      var _this2 = this;
75067
75068      // Compute bone weights for each segment.
75069      var segs = path.segments.map(function (s) {
75070        // Check if control points are collinear.
75071        // If so, use the middle point's weight for all three points (curve point, handleIn, handleOut).
75072        // This makes sure smooth curves remain smooth after deformation.
75073        var collinear = _mathUtils.MathUtils.isCollinear(s.handleIn, s.handleOut);
75074
75075        var bones = selectedBones || _this2.skeleton.findBoneGroup(s.point);
75076
75077        var weightsP = _this2.getWeights(s.point, bones);
75078
75079        var segment = {
75080          point: _this2.getSkinning(s.point, weightsP)
75081        }; // For handles, compute transformation in world space.
75082
75083        if (s.handleIn) {
75084          var pHandleIn = s.handleIn.add(s.point);
75085          segment.handleIn = _this2.getSkinning(pHandleIn, collinear ? weightsP : _this2.getWeights(pHandleIn, bones));
75086        }
75087
75088        if (s.handleOut) {
75089          var pHandleOut = s.handleOut.add(s.point);
75090          segment.handleOut = _this2.getSkinning(pHandleOut, collinear ? weightsP : _this2.getWeights(pHandleOut, bones));
75091        }
75092
75093        return segment;
75094      });
75095      this.skinnedPaths.push({
75096        segments: segs,
75097        fillColor: path.fillColor,
75098        strokeColor: path.strokeColor,
75099        strokeWidth: path.strokeWidth,
75100        closed: path.closed
75101      });
75102    }
75103  }, {
75104    key: "getSkinning",
75105    value: function getSkinning(point, weights) {
75106      var skinning = {};
75107      Object.keys(weights).forEach(function (boneName) {
75108        skinning[boneName] = {
75109          bone: weights[boneName].bone,
75110          weight: weights[boneName].value,
75111          transform: weights[boneName].bone.getPointTransform(point)
75112        };
75113      });
75114      return {
75115        skinning: skinning,
75116        position: point,
75117        currentPosition: new this.scope.Point(0, 0)
75118      };
75119    }
75120  }]);
75121
75122  return PoseIllustration;
75123}();
75124
75125exports.PoseIllustration = PoseIllustration;
75126},{"./skeleton":"illustrationGen/skeleton.js","../utils/mathUtils":"utils/mathUtils.js","../utils/svgUtils":"utils/svgUtils.js","../utils/colorUtils":"utils/colorUtils.js"}],"utils/fileUtils.js":[function(require,module,exports) {
75127"use strict";
75128
75129Object.defineProperty(exports, "__esModule", {
75130  value: true
75131});
75132exports.FileUtils = void 0;
75133
75134function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
75135
75136function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
75137
75138function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
75139
75140/**
75141 * @license
75142 * Copyright 2020 Google Inc. All Rights Reserved.
75143 * Licensed under the Apache License, Version 2.0 (the "License");
75144 * you may not use this file except in compliance with the License.
75145 * You may obtain a copy of the License at
75146 *
75147 * https://www.apache.org/licenses/LICENSE-2.0
75148 *
75149 * Unless required by applicable law or agreed to in writing, software
75150 * distributed under the License is distributed on an "AS IS" BASIS,
75151 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
75152 * See the License for the specific language governing permissions and
75153 * limitations under the License.
75154 * =============================================================================
75155 */
75156var FileUtils = /*#__PURE__*/function () {
75157  function FileUtils() {
75158    _classCallCheck(this, FileUtils);
75159  }
75160
75161  _createClass(FileUtils, null, [{
75162    key: "setDragDropHandler",
75163    value: function setDragDropHandler(handler) {
75164      window.addEventListener("dragover", function (e) {
75165        e = e || event;
75166        e.preventDefault();
75167      }, false);
75168      window.addEventListener("drop", function (e) {
75169        e = e || event;
75170        e.preventDefault();
75171
75172        if (e.dataTransfer.items) {
75173          var files = e.dataTransfer.items;
75174
75175          if (files.length < 1) {
75176            return;
75177          }
75178
75179          var reader = new FileReader();
75180
75181          reader.onload = function (event) {
75182            handler(event.target.result);
75183          };
75184
75185          reader.readAsText(e.dataTransfer.files[0]);
75186        }
75187      }, false);
75188    }
75189  }]);
75190
75191  return FileUtils;
75192}();
75193
75194exports.FileUtils = FileUtils;
75195},{}],"resources/illustration/girl.svg":[function(require,module,exports) {
75196module.exports = "/girl.9fcd92b4.svg";
75197},{}],"resources/illustration/boy.svg":[function(require,module,exports) {
75198module.exports = "/boy.f9d3081d.svg";
75199},{}],"camera.js":[function(require,module,exports) {
75200"use strict";
75201
75202Object.defineProperty(exports, "__esModule", {
75203  value: true
75204});
75205exports.bindPage = bindPage;
75206
75207var posenet_module = _interopRequireWildcard(require("@tensorflow-models/posenet"));
75208
75209var facemesh_module = _interopRequireWildcard(require("@tensorflow-models/facemesh"));
75210
75211var tf = _interopRequireWildcard(require("@tensorflow/tfjs"));
75212
75213var paper = _interopRequireWildcard(require("paper"));
75214
75215var _dat = _interopRequireDefault(require("dat.gui"));
75216
75217var _stats = _interopRequireDefault(require("stats.js"));
75218
75219require("babel-polyfill");
75220
75221var _demoUtils = require("./utils/demoUtils");
75222
75223var _svgUtils = require("./utils/svgUtils");
75224
75225var _illustration = require("./illustrationGen/illustration");
75226
75227var _skeleton = require("./illustrationGen/skeleton");
75228
75229var _fileUtils = require("./utils/fileUtils");
75230
75231var girlSVG = _interopRequireWildcard(require("./resources/illustration/girl.svg"));
75232
75233var boySVG = _interopRequireWildcard(require("./resources/illustration/boy.svg"));
75234
75235function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
75236
75237function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
75238
75239function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
75240
75241function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
75242
75243function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
75244
75245// Camera stream video element
75246var video;
75247var videoWidth = 300;
75248var videoHeight = 300; // Canvas
75249
75250var faceDetection = null;
75251var illustration = null;
75252var canvasScope;
75253var canvasWidth = 800;
75254var canvasHeight = 800; // ML models
75255
75256var facemesh;
75257var posenet;
75258var minPoseConfidence = 0.15;
75259var minPartConfidence = 0.1;
75260var nmsRadius = 30.0; // Misc
75261
75262var mobile = false;
75263var stats = new _stats.default();
75264var avatarSvgs = {
75265  'girl': girlSVG.default,
75266  'boy': boySVG.default
75267};
75268/**
75269 * Loads a the camera to be used in the demo
75270 *
75271 */
75272
75273function setupCamera() {
75274  return _setupCamera.apply(this, arguments);
75275}
75276
75277function _setupCamera() {
75278  _setupCamera = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
75279    var video, stream;
75280    return regeneratorRuntime.wrap(function _callee2$(_context2) {
75281      while (1) {
75282        switch (_context2.prev = _context2.next) {
75283          case 0:
75284            if (!(!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia)) {
75285              _context2.next = 2;
75286              break;
75287            }
75288
75289            throw new Error('Browser API navigator.mediaDevices.getUserMedia not available');
75290
75291          case 2:
75292            video = document.getElementById('video');
75293            video.width = videoWidth;
75294            video.height = videoHeight;
75295            _context2.next = 7;
75296            return navigator.mediaDevices.getUserMedia({
75297              'audio': false,
75298              'video': {
75299                facingMode: 'user',
75300                width: videoWidth,
75301                height: videoHeight
75302              }
75303            });
75304
75305          case 7:
75306            stream = _context2.sent;
75307            video.srcObject = stream;
75308            return _context2.abrupt("return", new Promise(function (resolve) {
75309              video.onloadedmetadata = function () {
75310                resolve(video);
75311              };
75312            }));
75313
75314          case 10:
75315          case "end":
75316            return _context2.stop();
75317        }
75318      }
75319    }, _callee2);
75320  }));
75321  return _setupCamera.apply(this, arguments);
75322}
75323
75324function loadVideo() {
75325  return _loadVideo.apply(this, arguments);
75326}
75327
75328function _loadVideo() {
75329  _loadVideo = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
75330    var video;
75331    return regeneratorRuntime.wrap(function _callee3$(_context3) {
75332      while (1) {
75333        switch (_context3.prev = _context3.next) {
75334          case 0:
75335            _context3.next = 2;
75336            return setupCamera();
75337
75338          case 2:
75339            video = _context3.sent;
75340            video.play();
75341            return _context3.abrupt("return", video);
75342
75343          case 5:
75344          case "end":
75345            return _context3.stop();
75346        }
75347      }
75348    }, _callee3);
75349  }));
75350  return _loadVideo.apply(this, arguments);
75351}
75352
75353var defaultPoseNetArchitecture = 'MobileNetV1';
75354var defaultQuantBytes = 2;
75355var defaultMultiplier = 1.0;
75356var defaultStride = 16;
75357var defaultInputResolution = 200;
75358var guiState = {
75359  avatarSVG: Object.keys(avatarSvgs)[0],
75360  debug: {
75361    showDetectionDebug: true,
75362    showIllustrationDebug: false
75363  }
75364};
75365/**
75366 * Sets up dat.gui controller on the top-right of the window
75367 */
75368
75369function setupGui(cameras) {
75370  if (cameras.length > 0) {
75371    guiState.camera = cameras[0].deviceId;
75372  }
75373
75374  var gui = new _dat.default.GUI({
75375    width: 300
75376  });
75377  var multi = gui.addFolder('Image');
75378  gui.add(guiState, 'avatarSVG', Object.keys(avatarSvgs)).onChange(function () {
75379    return parseSVG(avatarSvgs[guiState.avatarSVG]);
75380  });
75381  multi.open();
75382  var output = gui.addFolder('Debug control');
75383  output.add(guiState.debug, 'showDetectionDebug');
75384  output.add(guiState.debug, 'showIllustrationDebug');
75385  output.open();
75386}
75387/**
75388 * Sets up a frames per second panel on the top-left of the window
75389 */
75390
75391
75392function setupFPS() {
75393  stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
75394
75395  document.getElementById('main').appendChild(stats.dom);
75396}
75397/**
75398 * Feeds an image to posenet to estimate poses - this is where the magic
75399 * happens. This function loops with a requestAnimationFrame method.
75400 */
75401
75402
75403function detectPoseInRealTime(video) {
75404  var canvas = document.getElementById('output');
75405  var keypointCanvas = document.getElementById('keypoints');
75406  var videoCtx = canvas.getContext('2d');
75407  var keypointCtx = keypointCanvas.getContext('2d');
75408  canvas.width = videoWidth;
75409  canvas.height = videoHeight;
75410  keypointCanvas.width = videoWidth;
75411  keypointCanvas.height = videoHeight;
75412
75413  function poseDetectionFrame() {
75414    return _poseDetectionFrame.apply(this, arguments);
75415  }
75416
75417  function _poseDetectionFrame() {
75418    _poseDetectionFrame = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
75419      var poses, input, all_poses, face;
75420      return regeneratorRuntime.wrap(function _callee$(_context) {
75421        while (1) {
75422          switch (_context.prev = _context.next) {
75423            case 0:
75424              // Begin monitoring code for frames per second
75425              stats.begin();
75426              poses = [];
75427              videoCtx.clearRect(0, 0, videoWidth, videoHeight); // Draw video
75428
75429              videoCtx.save();
75430              videoCtx.scale(-1, 1);
75431              videoCtx.translate(-videoWidth, 0);
75432              videoCtx.drawImage(video, 0, 0, videoWidth, videoHeight);
75433              videoCtx.restore(); // Creates a tensor from an image
75434
75435              input = tf.browser.fromPixels(canvas);
75436              _context.next = 11;
75437              return facemesh.estimateFaces(input, false, false);
75438
75439            case 11:
75440              faceDetection = _context.sent;
75441              _context.next = 14;
75442              return posenet.estimatePoses(video, {
75443                flipHorizontal: true,
75444                decodingMethod: 'multi-person',
75445                maxDetections: 1,
75446                scoreThreshold: minPartConfidence,
75447                nmsRadius: nmsRadius
75448              });
75449
75450            case 14:
75451              all_poses = _context.sent;
75452              poses = poses.concat(all_poses);
75453              input.dispose();
75454              keypointCtx.clearRect(0, 0, videoWidth, videoHeight);
75455
75456              if (guiState.debug.showDetectionDebug) {
75457                poses.forEach(function (_ref) {
75458                  var score = _ref.score,
75459                      keypoints = _ref.keypoints;
75460
75461                  if (score >= minPoseConfidence) {
75462                    (0, _demoUtils.drawKeypoints)(keypoints, minPartConfidence, keypointCtx);
75463                    (0, _demoUtils.drawSkeleton)(keypoints, minPartConfidence, keypointCtx);
75464                  }
75465                });
75466                faceDetection.forEach(function (face) {
75467                  Object.values(_skeleton.facePartName2Index).forEach(function (index) {
75468                    var p = face.scaledMesh[index];
75469                    (0, _demoUtils.drawPoint)(keypointCtx, p[1], p[0], 2, 'red');
75470                  });
75471                });
75472              }
75473
75474              canvasScope.project.clear();
75475
75476              if (poses.length >= 1 && illustration) {
75477                _skeleton.Skeleton.flipPose(poses[0]);
75478
75479                if (faceDetection && faceDetection.length > 0) {
75480                  face = _skeleton.Skeleton.toFaceFrame(faceDetection[0]);
75481                  illustration.updateSkeleton(poses[0], face);
75482                } else {
75483                  illustration.updateSkeleton(poses[0], null);
75484                }
75485
75486                illustration.draw(canvasScope, videoWidth, videoHeight);
75487
75488                if (guiState.debug.showIllustrationDebug) {
75489                  illustration.debugDraw(canvasScope);
75490                }
75491              }
75492
75493              canvasScope.project.activeLayer.scale(canvasWidth / videoWidth, canvasHeight / videoHeight, new canvasScope.Point(0, 0)); // End monitoring code for frames per second
75494
75495              stats.end();
75496              requestAnimationFrame(poseDetectionFrame);
75497
75498            case 24:
75499            case "end":
75500              return _context.stop();
75501          }
75502        }
75503      }, _callee);
75504    }));
75505    return _poseDetectionFrame.apply(this, arguments);
75506  }
75507
75508  poseDetectionFrame();
75509}
75510
75511function setupCanvas() {
75512  mobile = (0, _demoUtils.isMobile)();
75513
75514  if (mobile) {
75515    canvasWidth = Math.min(window.innerWidth, window.innerHeight);
75516    canvasHeight = canvasWidth;
75517    videoWidth *= 0.7;
75518    videoHeight *= 0.7;
75519  }
75520
75521  canvasScope = paper.default;
75522  var canvas = document.querySelector('.illustration-canvas');
75523  ;
75524  canvas.width = canvasWidth;
75525  canvas.height = canvasHeight;
75526  canvasScope.setup(canvas);
75527}
75528/**
75529 * Kicks off the demo by loading the posenet model, finding and loading
75530 * available camera devices, and setting off the detectPoseInRealTime function.
75531 */
75532
75533
75534function bindPage() {
75535  return _bindPage.apply(this, arguments);
75536}
75537
75538function _bindPage() {
75539  _bindPage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
75540    var t0, info;
75541    return regeneratorRuntime.wrap(function _callee4$(_context4) {
75542      while (1) {
75543        switch (_context4.prev = _context4.next) {
75544          case 0:
75545            setupCanvas();
75546            (0, _demoUtils.toggleLoadingUI)(true);
75547            (0, _demoUtils.setStatusText)('Loading PoseNet model...');
75548            _context4.next = 5;
75549            return posenet_module.load({
75550              architecture: defaultPoseNetArchitecture,
75551              outputStride: defaultStride,
75552              inputResolution: defaultInputResolution,
75553              multiplier: defaultMultiplier,
75554              quantBytes: defaultQuantBytes
75555            });
75556
75557          case 5:
75558            posenet = _context4.sent;
75559            (0, _demoUtils.setStatusText)('Loading FaceMesh model...');
75560            _context4.next = 9;
75561            return facemesh_module.load();
75562
75563          case 9:
75564            facemesh = _context4.sent;
75565            (0, _demoUtils.setStatusText)('Loading Avatar file...');
75566            t0 = new Date();
75567            _context4.next = 14;
75568            return parseSVG(Object.values(avatarSvgs)[0]);
75569
75570          case 14:
75571            (0, _demoUtils.setStatusText)('Setting up camera...');
75572            _context4.prev = 15;
75573            _context4.next = 18;
75574            return loadVideo();
75575
75576          case 18:
75577            video = _context4.sent;
75578            _context4.next = 27;
75579            break;
75580
75581          case 21:
75582            _context4.prev = 21;
75583            _context4.t0 = _context4["catch"](15);
75584            info = document.getElementById('info');
75585            info.textContent = 'this device type is not supported yet, ' + 'or this browser does not support video capture: ' + _context4.t0.toString();
75586            info.style.display = 'block';
75587            throw _context4.t0;
75588
75589          case 27:
75590            setupGui([], posenet);
75591            setupFPS();
75592            (0, _demoUtils.toggleLoadingUI)(false);
75593            detectPoseInRealTime(video, posenet);
75594
75595          case 31:
75596          case "end":
75597            return _context4.stop();
75598        }
75599      }
75600    }, _callee4, null, [[15, 21]]);
75601  }));
75602  return _bindPage.apply(this, arguments);
75603}
75604
75605navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
75606
75607_fileUtils.FileUtils.setDragDropHandler(function (result) {
75608  parseSVG(result);
75609});
75610
75611function parseSVG(_x) {
75612  return _parseSVG.apply(this, arguments);
75613}
75614
75615function _parseSVG() {
75616  _parseSVG = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(target) {
75617    var svgScope, skeleton;
75618    return regeneratorRuntime.wrap(function _callee5$(_context5) {
75619      while (1) {
75620        switch (_context5.prev = _context5.next) {
75621          case 0:
75622            _context5.next = 2;
75623            return _svgUtils.SVGUtils.importSVG(target
75624            /* SVG string or file path */
75625            );
75626
75627          case 2:
75628            svgScope = _context5.sent;
75629            skeleton = new _skeleton.Skeleton(svgScope);
75630            illustration = new _illustration.PoseIllustration(canvasScope);
75631            illustration.bindSkeleton(skeleton, svgScope);
75632
75633          case 6:
75634          case "end":
75635            return _context5.stop();
75636        }
75637      }
75638    }, _callee5);
75639  }));
75640  return _parseSVG.apply(this, arguments);
75641}
75642
75643bindPage();
75644},{"@tensorflow-models/posenet":"node_modules/@tensorflow-models/posenet/dist/posenet.esm.js","@tensorflow-models/facemesh":"node_modules/@tensorflow-models/facemesh/dist/facemesh.esm.js","@tensorflow/tfjs":"node_modules/@tensorflow/tfjs/dist/tf.esm.js","paper":"node_modules/paper/dist/paper-full.js","dat.gui":"node_modules/dat.gui/build/dat.gui.module.js","
75644stats.js":"node_modules/stats.js/build/stats.min.js","babel-polyfill":"node_modules/babel-polyfill/lib/index.js","./utils/demoUtils":"utils/demoUtils.js","./utils/svgUtils":"utils/svgUtils.js","./illustrationGen/illustration":"illustrationGen/illustration.js","./illustrationGen/skeleton":"illustrationGen/skeleton.js","./utils/fileUtils":"utils/fileUtils.js","./resources/illustration/girl.svg":"resources/illustration/girl.svg","./resources/illustration/boy.svg":"resources/illustration/boy.svg"}]},{},["camera.js"], null)
75645//# sourceMappingURL=/camera.283d5d54.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.